//master
intellif@segment1:/tmp$ tail -fn 100 redis.log
35470:C 16 Jul 16:05:32.969 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
35470:C 16 Jul 16:05:32.969 # Redis version=4.0.13, bits=64, commit=00000000, modified=0, pid=35470, just started
35470:C 16 Jul 16:05:32.969 # Configuration loaded
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.13 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 35471
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
35471:M 16 Jul 16:05:32.973 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
35471:M 16 Jul 16:05:32.973 # Server initialized
35471:M 16 Jul 16:05:32.973 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
35471:M 16 Jul 16:05:32.974 * DB loaded from append only file: 0.000 seconds
35471:M 16 Jul 16:05:32.974 * Ready to accept connections
35471:M 16 Jul 16:12:54.071 * Slave 192.168.13.53:6379 asks for synchronization
35471:M 16 Jul 16:12:54.071 * Full resync requested by slave 192.168.13.53:6379
35471:M 16 Jul 16:12:54.072 * Starting BGSAVE for SYNC with target: disk
35471:M 16 Jul 16:12:54.073 * Background saving started by pid 35613
35613:C 16 Jul 16:12:54.075 * DB saved on disk
35613:C 16 Jul 16:12:54.075 * RDB: 6 MB of memory used by copy-on-write
35471:M 16 Jul 16:12:54.093 * Background saving terminated with success
35471:M 16 Jul 16:12:54.093 * Synchronization with slave 192.168.13.53:6379 succeeded
//slave
intellif@segment2:/tmp$ tail -fn 100 redis.log
44963:C 16 Jul 16:12:54.116 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
44963:C 16 Jul 16:12:54.116 # Redis version=4.0.13, bits=64, commit=00000000, modified=0, pid=44963, just started
44963:C 16 Jul 16:12:54.116 # Configuration loaded
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.13 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 44964
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
44964:S 16 Jul 16:12:54.121 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
44964:S 16 Jul 16:12:54.121 # Server initialized
44964:S 16 Jul 16:12:54.121 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
44964:S 16 Jul 16:12:54.121 * DB loaded from disk: 0.000 seconds
44964:S 16 Jul 16:12:54.121 * Ready to accept connections
44964:S 16 Jul 16:12:54.121 * Connecting to MASTER 192.168.13.52:6379
44964:S 16 Jul 16:12:54.121 * MASTER <-> SLAVE sync started
44964:S 16 Jul 16:12:54.121 * Non blocking connect for SYNC fired the event.
44964:S 16 Jul 16:12:54.121 * Master replied to PING, replication can continue...
44964:S 16 Jul 16:12:54.122 * Partial resynchronization not possible (no cached master)
44964:S 16 Jul 16:12:54.125 * Full resync from master: fd8fca61fd8a7a36f1dd29a53e429e7268b291f2:0
44964:S 16 Jul 16:12:54.144 * MASTER <-> SLAVE sync: receiving 195 bytes from master
44964:S 16 Jul 16:12:54.144 * MASTER <-> SLAVE sync: Flushing old data
44964:S 16 Jul 16:12:54.144 * MASTER <-> SLAVE sync: Loading DB in memory
44964:S 16 Jul 16:12:54.145 * MASTER <-> SLAVE sync: Finished with success
我们看到master有:Slave 192.168.13.53:6379 asks for synchronization,然后开始执行save命令,之后Synchronization with slave 192.168.13.53:6379 succeeded。从copy-on-write看出redis使用到了写时复制的机制。
在slave:Connecting to MASTER 192.168.13.52:6379,然后Flushing old data,最后Loading DB in memory,并且成功了。