Docker之搭建Redis主从集群

摘要

基于docker快捷搭建redis主从集群

Node1 10.10.243.82 master

Node2 10.10.243.83 slave

Node3 10.10.243.84 slave

一、部署环境

1、Node1上操作

[[email protected] ~]# docker pull benyoo/redis:3.2.5
[[email protected] ~]# echo 'bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 8
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /data/redis
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

masterauth ZDU0NTlkNDY5NWZi
requirepass ZDU0NTlkNDY5NWZi' >/etc/redis.conf
[[email protected] ~]# iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp -m comment --comment "REDIS_SERVER" -m multiport --dports 6379 -j ACCEPT
[[email protected] ~]# iptables -nvxL --lin
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num      pkts      bytes target     prot opt in     out     source               destination         
1       13519 25681312 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
2           2      132 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
3           1       60 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
4           1       52 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
5           0        0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp /* REDIS_SERVER */ multiport dports 6379
6       65992  8123814 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num      pkts      bytes target     prot opt in     out     source               destination         
1       67226 64909690 DOCKER-ISOLATION  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
2       44597 63998363 DOCKER     all  --  *      docker0  0.0.0.0/0            0.0.0.0/0           
3       44597 63998363 ACCEPT     all  --  *      docker0  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
4       22629   911327 ACCEPT     all  --  docker0 !docker0  0.0.0.0/0            0.0.0.0/0           
5           0        0 ACCEPT     all  --  docker0 docker0  0.0.0.0/0            0.0.0.0/0           
6           0        0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT 18 packets, 1708 bytes)
num      pkts      bytes target     prot opt in     out     source               destination         

Chain DOCKER (1 references)
num      pkts      bytes target     prot opt in     out     source               destination         

Chain DOCKER-ISOLATION (1 references)
num      pkts      bytes target     prot opt in     out     source               destination         
1       67226 64909690 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           
[[email protected] ~]# 

2、启动Node1上Redis

[[email protected] ~]# docker run -d \
--privileged --name redis \
--network host \
-v /etc/redis.conf:/etc/redis.conf \
-v /etc/localtime:/etc/localtime \
benyoo/redis:3.2.5

3、Node2上操作

[[email protected] ~]# docker pull benyoo/redis:3.2.5
[[email protected] ~]# echo 'bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 8
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /data/redis
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

slaveof 10.10.243.82 6379
masterauth ZDU0NTlkNDY5NWZi
requirepass ZDU0NTlkNDY5NWZi' >/etc/redis.conf
[[email protected] ~]# iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp -m comment --comment "REDIS_SERVER" -m multiport --dports 6379 -j ACCEPT
[[email protected] ~]# iptables -nvxL --lin
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num      pkts      bytes target     prot opt in     out     source               destination         
1       13519 25681312 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
2           2      132 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
3           1       60 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
4           1       52 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
5           0        0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp /* REDIS_SERVER */ multiport dports 6379
6       65992  8123814 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num      pkts      bytes target     prot opt in     out     source               destination         
1       67226 64909690 DOCKER-ISOLATION  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
2       44597 63998363 DOCKER     all  --  *      docker0  0.0.0.0/0            0.0.0.0/0           
3       44597 63998363 ACCEPT     all  --  *      docker0  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
4       22629   911327 ACCEPT     all  --  docker0 !docker0  0.0.0.0/0            0.0.0.0/0           
5           0        0 ACCEPT     all  --  docker0 docker0  0.0.0.0/0            0.0.0.0/0           
6           0        0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT 18 packets, 1708 bytes)
num      pkts      bytes target     prot opt in     out     source               destination         

Chain DOCKER (1 references)
num      pkts      bytes target     prot opt in     out     source               destination         

Chain DOCKER-ISOLATION (1 references)
num      pkts      bytes target     prot opt in     out     source               destination         
1       67226 64909690 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           
[[email protected] ~]# 

4、启动Node2上Redis

[[email protected] ~]# docker run -d \
--privileged --name redis \
--network host \
-v /etc/redis.conf:/etc/redis.conf \
-v /etc/localtime:/etc/localtime \
benyoo/redis:3.2.5

5、Node3上操作

[[email protected] ~]# docker pull benyoo/redis:3.2.5
[[email protected] ~]# echo 'bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 8
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /data/redis
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

slaveof 10.10.243.82 6379
masterauth ZDU0NTlkNDY5NWZi
requirepass ZDU0NTlkNDY5NWZi' >/etc/redis.conf
[[email protected] ~]# iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp -m comment --comment "REDIS_SERVER" -m multiport --dports 6379 -j ACCEPT
[[email protected] ~]# iptables -nvxL --lin
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num      pkts      bytes target     prot opt in     out     source               destination         
1       13519 25681312 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
2           2      132 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           
3           1       60 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0           
4           1       52 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp dpt:22
5           0        0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0            state NEW tcp /* REDIS_SERVER */ multiport dports 6379
6       65992  8123814 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num      pkts      bytes target     prot opt in     out     source               destination         
1       67226 64909690 DOCKER-ISOLATION  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
2       44597 63998363 DOCKER     all  --  *      docker0  0.0.0.0/0            0.0.0.0/0           
3       44597 63998363 ACCEPT     all  --  *      docker0  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
4       22629   911327 ACCEPT     all  --  docker0 !docker0  0.0.0.0/0            0.0.0.0/0           
5           0        0 ACCEPT     all  --  docker0 docker0  0.0.0.0/0            0.0.0.0/0           
6           0        0 REJECT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT 18 packets, 1708 bytes)
num      pkts      bytes target     prot opt in     out     source               destination         

Chain DOCKER (1 references)
num      pkts      bytes target     prot opt in     out     source               destination         

Chain DOCKER-ISOLATION (1 references)
num      pkts      bytes target     prot opt in     out     source               destination         
1       67226 64909690 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           
[[email protected] ~]# 

6、启动Node3上Redis

[[email protected] ~]# docker run -d \
--privileged --name redis \
--network host \
-v /etc/redis.conf:/etc/redis.conf \
-v /etc/localtime:/etc/localtime \
benyoo/redis:3.2.5

二、测试环境
先来看看主从集群

[[email protected] ~]# docker logs redis 
net.core.somaxconn = 8192
vm.overcommit_memory = 1
never
Redis Server Auth Password : ZDU0NTlkNDY5NWZi
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

1:M 30 Oct 23:46:11.683 # Server started, Redis version 3.2.5
1:M 30 Oct 23:46:11.683 * The server is now ready to accept connections on port 6379
1:M 30 Oct 23:56:12.852 * Slave 10.10.243.83:6379 asks for synchronization
1:M 30 Oct 23:56:12.852 * Full resync requested by slave 10.10.243.83:6379
1:M 30 Oct 23:56:12.852 * Starting BGSAVE for SYNC with target: disk
1:M 30 Oct 23:56:12.852 * Background saving started by pid 31
31:C 30 Oct 23:56:12.854 * DB saved on disk
31:C 30 Oct 23:56:12.854 * RDB: 0 MB of memory used by copy-on-write
1:M 30 Oct 23:56:12.889 * Background saving terminated with success
1:M 30 Oct 23:56:12.889 * Synchronization with slave 10.10.243.83:6379 succeeded
1:M 30 Oct 23:57:00.361 * Slave 10.10.243.84:6379 asks for synchronization
1:M 30 Oct 23:57:00.361 * Full resync requested by slave 10.10.243.84:6379
1:M 30 Oct 23:57:00.361 * Starting BGSAVE for SYNC with target: disk
1:M 30 Oct 23:57:00.361 * Background saving started by pid 32
32:C 30 Oct 23:57:00.362 * DB saved on disk
32:C 30 Oct 23:57:00.362 * RDB: 0 MB of memory used by copy-on-write
1:M 30 Oct 23:57:00.403 * Background saving terminated with success
1:M 30 Oct 23:57:00.403 * Synchronization with slave 10.10.243.84:6379 succeeded
1:M 31 Oct 00:12:01.067 * 1 changes in 900 seconds. Saving...
1:M 31 Oct 00:12:01.067 * Background saving started by pid 36
36:C 31 Oct 00:12:01.068 * DB saved on disk
36:C 31 Oct 00:12:01.068 * RDB: 0 MB of memory used by copy-on-write
1:M 31 Oct 00:12:01.168 * Background saving terminated with success
[[email protected] ~]# 
[[email protected] ~]# docker logs redis
net.core.somaxconn = 8192
vm.overcommit_memory = 1
never
Redis Server Auth Password : ZDU0NTlkNDY5NWZi
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

1:S 31 Oct 07:56:12.664 # Server started, Redis version 3.2.5
1:S 31 Oct 07:56:12.664 * The server is now ready to accept connections on port 6379
1:S 31 Oct 07:56:12.675 * Connecting to MASTER 10.10.243.82:6379
1:S 31 Oct 07:56:12.675 * MASTER <-> SLAVE sync started
1:S 31 Oct 07:56:12.675 * Non blocking connect for SYNC fired the event.
1:S 31 Oct 07:56:12.676 * Master replied to PING, replication can continue...
1:S 31 Oct 07:56:12.676 * Partial resynchronization not possible (no cached master)
1:S 31 Oct 07:56:12.676 * Full resync from master: 5eb604bb178f45e8af4dab009003677f4ac5ade0:1
1:S 31 Oct 07:56:12.713 * MASTER <-> SLAVE sync: receiving 86 bytes from master
1:S 31 Oct 07:56:12.713 * MASTER <-> SLAVE sync: Flushing old data
1:S 31 Oct 07:56:12.713 * MASTER <-> SLAVE sync: Loading DB in memory
1:S 31 Oct 07:56:12.713 * MASTER <-> SLAVE sync: Finished with success
1:S 31 Oct 08:11:40.250 * 1 changes in 900 seconds. Saving...
1:S 31 Oct 08:11:40.251 * Background saving started by pid 37
37:C 31 Oct 08:11:40.253 * DB saved on disk
37:C 31 Oct 08:11:40.253 * RDB: 0 MB of memory used by copy-on-write
1:S 31 Oct 08:11:40.351 * Background saving terminated with success
[[email protected] ~]# 
[[email protected] ~]# docker logs redis
net.core.somaxconn = 8192
vm.overcommit_memory = 1
never
Redis Server Auth Password : ZDU0NTlkNDY5NWZi
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.2.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

1:S 31 Oct 07:57:00.371 # Server started, Redis version 3.2.5
1:S 31 Oct 07:57:00.371 * The server is now ready to accept connections on port 6379
1:S 31 Oct 07:57:00.374 * Connecting to MASTER 10.10.243.82:6379
1:S 31 Oct 07:57:00.375 * MASTER <-> SLAVE sync started
1:S 31 Oct 07:57:00.384 * Non blocking connect for SYNC fired the event.
1:S 31 Oct 07:57:00.385 * Master replied to PING, replication can continue...
1:S 31 Oct 07:57:00.385 * Partial resynchronization not possible (no cached master)
1:S 31 Oct 07:57:00.386 * Full resync from master: 5eb604bb178f45e8af4dab009003677f4ac5ade0:71
1:S 31 Oct 07:57:00.427 * MASTER <-> SLAVE sync: receiving 86 bytes from master
1:S 31 Oct 07:57:00.427 * MASTER <-> SLAVE sync: Flushing old data
1:S 31 Oct 07:57:00.427 * MASTER <-> SLAVE sync: Loading DB in memory
1:S 31 Oct 07:57:00.427 * MASTER <-> SLAVE sync: Finished with success
1:S 31 Oct 08:12:01.082 * 1 changes in 900 seconds. Saving...
1:S 31 Oct 08:12:01.082 * Background saving started by pid 37
37:C 31 Oct 08:12:01.084 * DB saved on disk
37:C 31 Oct 08:12:01.084 * RDB: 0 MB of memory used by copy-on-write
1:S 31 Oct 08:12:01.183 * Background saving terminated with success
[[email protected] ~]# 
[[email protected] ~]# docker exec -it redis redis-cli -h 10.10.243.82 -a ZDU0NTlkNDY5NWZi info replication
# Replication
role:master
connected_slaves:2
slave0:ip=10.10.243.83,port=6379,state=online,offset=1738,lag=1
slave1:ip=10.10.243.84,port=6379,state=online,offset=1738,lag=0
master_repl_offset:1738
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:1737
[[email protected] ~]# docker exec -it redis redis-cli -h 10.10.243.83 -a ZDU0NTlkNDY5NWZi info replication
# Replication
role:slave
master_host:10.10.243.82
master_port:6379
master_link_status:up
master_last_io_seconds_ago:3
master_sync_in_progress:0
slave_repl_offset:1752
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
[[email protected] ~]# docker exec -it redis redis-cli -h 10.10.243.84 -a ZDU0NTlkNDY5NWZi info replication
# Replication
role:slave
master_host:10.10.243.82
master_port:6379
master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
slave_repl_offset:1752
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
[[email protected] ~]# 

三、验证同步
1、主从同步测试

[[email protected] ~]# docker exec -it redis redis-cli -h 10.10.243.82 -a ZDU0NTlkNDY5NWZi set Test_Write_Key www.dwhd.org
OK
[[email protected] ~]# docker exec -it redis redis-cli -h 10.10.243.83 -a ZDU0NTlkNDY5NWZi get Test_Write_Key
"www.dwhd.org"
[[email protected] ~]# docker exec -it redis redis-cli -h 10.10.243.84 -a ZDU0NTlkNDY5NWZi get Test_Write_Key
"www.dwhd.org"
[[email protected] ~]# 

2、验证从节点只读不能写

[[email protected] ~]# docker exec -it redis redis-cli -h 10.10.243.84 -a ZDU0NTlkNDY5NWZi set Test_Write_Key_Slave www.dwhd.org
(error) READONLY You can't write against a read only slave.
[[email protected] ~]# docker exec -it redis redis-cli -h 10.10.243.83 -a ZDU0NTlkNDY5NWZi set Test_Write_Key_Slave www.dwhd.org
(error) READONLY You can't write against a read only slave.
[[email protected] ~]# 
  • 本文由 发表于 2016年10月31日08:22:11
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: