Master-slave replication
192.168.1.106 Master Machine
Mkdir-p/data/redis
Cp/etc/redis/redis.conf/etc/redis/redis-6379.conf
Vim/etc/redis/redis-6379.conf
Daemonize Yes
Pidfile/var/run/redis-6379.pid
Port 6379
LogFile "6379.log"
Dbfilename "Dump-6379.rdb"
Dir "/data/redis"
AppendOnly Yes
Appendfilename "Appendonly-6379.aof"
192.168.1.107 slave Machine
Mkdir-p/data/redis
Cp/etc/redis/redis.conf/etc/redis/redis-6381.conf
Vim/etc/redis/redis-6381.conf
Daemonize Yes
Pidfile/var/run/redis-6381.pid
Port 6381
LogFile "6381.log"
Dbfilename "Dump-6381.rdb"
Dir "/data/redis"
AppendOnly Yes
Appendfilename "Appendonly-6381.aof"
Connect from server
[Root@slave redis]# redis-cli-p 6381
127.0.0.1:6381>
127.0.0.1:6381> dbsize
(integer) 0
127.0.0.1:6381> slaveof 192.168.1.106 6379
127.0.0.1:6381> Get Hello
"World"
127.0.0.1:6381> Info Replication
# Replication
Role:slave
master_host:192.168.1.106
master_port:6379
Master_link_status:up
Master_last_io_seconds_ago:9
master_sync_in_progress:0
slave_repl_offset:773
slave_priority:100
Slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
[Root@slave redis]# redis-cli-p 6381
127.0.0.1:6381> slaveof 192.168.1.106 6379
127.0.0.1:6381> Config rewrite
Then configure one from the server
[Root@slave redis]# cd/etc/redis/
[root@slave redis]# ls
redis-6379.conf redis-6381.conf
[ Root@slave redis]# sed ' s/6381/6382/g ' redis-6381.conf > redis-6382.conf
[root@slave, redis]# redis-server/etc/ redis/redis-6382.conf
[root@slave redis]# redis-cli-p 6382
127.0.0.1:6382> get Hello
' world '
127.0.0.1:6382> info Replication
# replication
Role:slave
master_host:192.168.1.106
Master_port : 6379
Master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
Slave_repl_ offset:3026
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
Repl_ backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6382>