블로그 이미지
BJcomm
bjcomm

공지사항

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

calendar

1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
03-29 05:13

redis 데이터 새서버로 이전하기

2016. 12. 1. 17:02 | Posted by bjcomm

새로운 서버에 redis를 설치 실행후 명령프롬프트에서 cli진입.

 

]# ./redis-cli

127.0.0.1:6379> auth mypasswd

127.0.0.1:6379> config set masterauth 'masterpasswd'

127.0.0.1:6379> slaveof masterip 6379

 

마스터 데이터를 슬레이브로 이전 완료는 redis.log 확인.

 

15980:S 01 Dec 16:50:10.688 * Full resync from master: 6809f08c019504dc5694c44444522bb7254eb1ab:1492880883459
15980:S 01 Dec 16:50:11.343 * MASTER <-> SLAVE sync: receiving 31023457 bytes from master
15980:S 01 Dec 16:50:12.172 * MASTER <-> SLAVE sync: Flushing old data
15980:S 01 Dec 16:50:12.172 * MASTER <-> SLAVE sync: Loading DB in memory
15980:S 01 Dec 16:50:12.652 * MASTER <-> SLAVE sync: Finished with success

 

Finished with success 후에 슬레이브에서 마스터연결을 끊고 슬레이브를 마스터로 지정

 

127.0.0.1:6379> auth mypasswd

OK
127.0.0.1:6379> slaveof no one
OK

 

log를 확인해보면 다음과 같다.

 

15980:M 01 Dec 16:52:36.894 # Connection with master lost.
15980:M 01 Dec 16:52:36.894 * Caching the disconnected master state.
15980:M 01 Dec 16:52:36.895 * Discarding previously cached master state.
15980:M 01 Dec 16:52:36.895 * MASTER MODE enabled (user request from 'id=281 addr=127.0.0.1:55297 fd=6 name= age=5 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=slaveof')

 

이후 master 장비는 빼도 된다. 단, 서비스에서 빠졌을때.