#tail -f redis.log
……………………
10370:M 12 Oct 11:02:25.148 # Server started, Redis version 3.0.7
10370:M 12 Oct 11:02:25.148 * DB loaded from append only file: 0.000 seconds
10370:M 12 Oct 11:02:25.148 * The server is now ready to accept connections on port 6379
10370:M 12 Oct 11:02:45.243 * Slave 10.0.18.146:6379 asks for synchronization
10370:M 12 Oct 11:02:45.243 * Full resync requested by slave 10.0.18.146:6379
10370:M 12 Oct 11:02:45.243 * Starting BGSAVE for SYNC with target: disk
10370:M 12 Oct 11:02:45.244 * Background saving started by pid 10384
10384:C 12 Oct 11:02:45.254 * DB saved on disk
10384:C 12 Oct 11:02:45.255 * RDB: 0 MB of memory used by copy-on-write
10370:M 12 Oct 11:02:45.303 * Background saving terminated with success
10370:M 12 Oct 11:02:45.303 * Synchronization with slave 10.0.18.146:6379 succeeded
在slave 上查看日志,如下:
#tail -f redis.log
………………
20825:S 12 Oct 11:02:44.278 * DB loaded from append only file: 0.000 seconds
20825:S 12 Oct 11:02:44.278 * The server is now ready to accept connections on port 6379
20825:S 12 Oct 11:02:45.278 * Connecting to MASTER 10.0.18.145:6379
20825:S 12 Oct 11:02:45.278 * MASTER <-> SLAVE sync started
20825:S 12 Oct 11:02:45.279 * Non blocking connect for SYNC fired the event.
20825:S 12 Oct 11:02:45.280 * Master replied to PING, replication can continue...
20825:S 12 Oct 11:02:45.282 * Partial resynchronization not possible (no cached master)
20825:S 12 Oct 11:02:45.284 * Full resync from master: 80508d50892115ab7d158c643c6ee68cb9282c76:1
20825:S 12 Oct 11:02:45.343 * MASTER <-> SLAVE sync: receiving 46 bytes from master
20825:S 12 Oct 11:02:45.344 * MASTER <-> SLAVE sync: Flushing old data
20825:S 12 Oct 11:02:45.344 * MASTER <-> SLAVE sync: Loading DB in memory
20825:S 12 Oct 11:02:45.344 * MASTER <-> SLAVE sync: Finished with success
20825:S 12 Oct 11:02:45.345 * Background append only file rewriting started by pid 20828
20825:S 12 Oct 11:02:45.370 * AOF rewrite child asks to stop sending diffs.
20828:C 12 Oct 11:02:45.370 * Parent agreed to stop sending diffs. Finalizing AOF...
20828:C 12 Oct 11:02:45.370 * Concatenating 0.00 MB of AOF diff received from parent.
20828:C 12 Oct 11:02:45.371 * SYNC append only file rewrite performed
20828:C 12 Oct 11:02:45.371 * AOF rewrite: 0 MB of memory used by copy-on-write
20825:S 12 Oct 11:02:45.379 * Background AOF rewrite terminated with success
20825:S 12 Oct 11:02:45.379 * Residual parent diff successfully flushed to the rewritten AOF (0.00 MB)
20825:S 12 Oct 11:02:45.379 * Background AOF rewrite finished successfully
如果都可以正常启动,测试数据可以复制,表示主从复制就配置OK了!
注意:进入redis之后,需要认证后才能进去操作
#./redis-cli -h 10.0.18.145
10.0.18.145:6379> info
NOAUTH Authentication required.
10.0.18.145:6379> auth abcd123 #输入密码
ok
7、查看复制信息
在master查看:
1
2
3
4
5
6
7
8
9
10
11
12
13
#./redis-cli -h 10.0.18.145
10.0.18.145:6379> auth abcd123
OK
10.0.18.145:6379> info replication
# Replication
role:master
connected_slaves:1
slave0:ip=10.0.18.146,port=6379,state=online,offset=14967,lag=0
master_repl_offset:14967
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:742