一.命令模式启动从服务器
1.启动从服务器
./redis-server --port 6380 --slaveof 127.0.0.1 6379
主从同步成功
90677:S 06 May 07:33:08.594 * MASTER <-> SLAVE sync: receiving 254 bytes from master
90677:S 06 May 07:33:08.594 * MASTER <-> SLAVE sync: Flushing old data
90677:S 06 May 07:33:08.594 * MASTER <-> SLAVE sync: Loading DB in memory
90677:S 06 May 07:33:08.594 * MASTER <-> SLAVE sync: Finished with success
注意:从redis默认无法执行写入操作.
127.0.0.1:6380> set ee 22
(error) READONLY You can't write against a read only slave.
2.从服务器切换主服务器
slaveof no one 不是任何服务器的从服务器