21.21-21.25 redis主从配置,集群介绍、搭建配置,操作

  • 21.21 redis主从配置 

  • 21.22 redis集群介绍 

  • 21.23-24 redis集群搭建配置

  • 21.25 redis集群操作

21.21 redis主从配置

1 为了节省资源,我们可以在一台机器上启动两个redis服务

cp /etc/redis.conf  /etc/redis2.conf
vim /etc/redis2.conf
port 6380
dir /data/redis2
pidfile /var/run/redis_6380.pid
logfile "/var/log/redis2.log"
#每个文件都需要修改port,dir,pidfile,logfile
#还要增加一行
# slaveof <masterip> <masterport> 参考格式
slaveof 127.0.0.1 6379

如果主上设置了密码,还需要增加记录设置主的密码:

参考:# masterauth <master-password>

格式:masterauth 密码

启动之前不要忘记创建新的dir目录

mkdir /data/redis2

 

2 启动从,6380端口启动

redis-server /etc/redis2.conf
redis-cli -h 127.0.0.1 -p 6380
127.0.0.1:6380>

3 测试:在主上创建新的key,在从上查看

127.0.0.1:6380> keys *
 1) "set1"
 2) "PHPREDIS_SESSION:url4j8mtr8j0m0ql874552tem7"
 3) "key1"
 4) "list11"
 5) "hash1"
 6) "PHPREDIS_SESSION:thrfeuq728o51vpucnl0nrjnt1"
 7) "set2"
 8) "zseta"
 9) "PHPREDIS_SESSION:lu4uq50i27qcd8ne81t8jpsbc1"
10) "key10"
11) "key3"
12) "key2"
13) "seta"
14) "list1"
15) "set3"
16) "PHPREDIS_SESSION:ks5pdipag3gqlmh1rulobps8b3"
17) "PHPREDIS_SESSION:psugne742rjjsi82maqu7urrv2"
18) "PHPREDIS_SESSION:5oni0crm9bc38jcju2o9qjb4o5"


同样,返回到主(6379)查看keys,是一样的数据

127.0.0.1:6379> keys *
 1) "PHPREDIS_SESSION:thrfeuq728o51vpucnl0nrjnt1"
 2) "key1"
 3) "PHPREDIS_SESSION:ks5pdipag3gqlmh1rulobps8b3"
 4) "key2"
 5) "list1"
 6) "PHPREDIS_SESSION:lu4uq50i27qcd8ne81t8jpsbc1"
 7) "set3"
 8) "PHPREDIS_SESSION:5oni0crm9bc38jcju2o9qjb4o5"
 9) "list11"
10) "set1"
11) "zseta"
12) "PHPREDIS_SESSION:psugne742rjjsi82maqu7urrv2"
13) "hash1"
14) "seta"
15) "PHPREDIS_SESSION:url4j8mtr8j0m0ql874552tem7"
16) "key10"
17) "key3"
18) "set2"

注意:

redis主从和mysql主从不一样,redis主从不用事先同步数据,它会自动同步过去

默认,从是不能进行写的动作,因为设定了只读参数

redis2.conf中的 slave-read-only yes

如果要改成可写,把yes改成no即可


21.22 redis集群介绍

  • 多个redis节点网络互联,数据共享

  • 所有的节点都是一主一从(可以是多个从),其中从不提供服务,仅作为备用

  • 不支持同时处理多个键(如mset/mget),因为redis需要把键均匀分布在各个节点上,并发量很高的情况下同时创建键值会降低性能并导致不可预测的行为。

  • 支持在线增加、删除节点

  • 客户端可以连任何一个主节点进行读写


22.23 Redis集群搭建配置(上)


场景设置:

  • 两台机器A(192.88.29.250) ,B(192.88.29.200)

  • 两台机器,分别开启三个Redis服务(端口)

  • 两台机器上都要编译安装redis,然后编辑并复制3个不同的redis.conf,分别设置不同的端口号、dir等参数,还需要增加cluster相关参数,然后分别启动6个redis服务


操作设置:

1 A机器上三个端口7000,7002,7004,全部为主

编辑redis_7000.conf,加入如下参数:

vim redis_7000.conf
port 7000
bind 192.88.29.250
daemonize yes
pidfile /var/run/redis_7000.pid
dir /data/redis_data/7000
cluster-enabled yes
cluster-config-file nodes_7000.conf
cluster-node-timeout 10100
appendonly yes

2 由于7002,7004的配置都差不多,只是端口号和pid等等发生对应变化,其他不变,所以将其复制7000的配置文件,然后修改对应参数即可。

复制配置对应文件

cp redis_7000.conf redis_7002.conf
cp redis_7002.conf redis_7004.conf

修改相关参数,此处将7000分别改成7002和7004即可

sed -i 's/7000/7002/g' redis_7002.conf
sed -i 's/7000/7004/g' redis_7004.conf


3 检查是否修改正确

# cat redis_7002.conf
port 7002
bind 192.88.29.250
daemonize yes
pidfile /var/run/redis_7002.pid
dir /data/redis_data/7002
cluster-enabled yes
cluster-config-file nodes_7002.conf
cluster-node-timeout 10100
appendonly yes

——————————————————————

# cat redis_7004.conf
port 7004
bind 192.88.29.250
daemonize yes
pidfile /var/run/redis_7004.pid
dir /data/redis_data/7004
cluster-enabled yes
cluster-config-file nodes_7004.conf
cluster-node-timeout 10100
appendonly yes

4 B机器上三个端口7001,7003,7005,全部为从

加入B机器上面没有安装redis,可以从A机器上scp过来,然后再进去redis的源码包make && make install即可

方法跟A机器操作差不多,配置文件也是,只是B机器需要更改一下bind 的ip:192.88.29.200


5 确保已关闭防火墙(iptables,selinux)

A机器

[root@9F-VM1 etc]# iptables -nvL
Chain INPUT (policy ACCEPT 2309K packets, 148M bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain OUTPUT (policy ACCEPT 1795K packets, 176M bytes)
 pkts bytes target     prot opt in     out     source               destination
 [root@9F-VM1 etc]# getenforce
Disabled

B机器

[root@9F-VM2 redis-4.0.1]# iptables -nvL
Chain INPUT (policy ACCEPT 2286K packets, 209M bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain OUTPUT (policy ACCEPT 1858K packets, 108M bytes)
 pkts bytes target     prot opt in     out     source               destination
[root@9F-VM2 redis-4.0.1]# getenforce
Disabled

6 启动redis

6.1 创建/data/reids各端口目录

 A:
 mkdir /data/redis_data/{7000,7002,7004}
 B:
 mkdir /data/redis_data/{7001,7003,7005}

6.2启动redis

A机器

[root@9F-VM1 etc]# redis-server /etc/redis_7000.conf
14543:C 27 Aug 17:07:36.458 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
14543:C 27 Aug 17:07:36.458 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=14543, just started
14543:C 27 Aug 17:07:36.459 # Configuration loaded
[root@9F-VM1 etc]# redis-server /etc/redis_7002.conf
14552:C 27 Aug 17:07:41.539 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
14552:C 27 Aug 17:07:41.540 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=14552, just started
14552:C 27 Aug 17:07:41.540 # Configuration loaded
[root@9F-VM1 etc]# redis-server /etc/redis_7004.conf
14557:C 27 Aug 17:07:44.212 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
14557:C 27 Aug 17:07:44.212 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=14557, just started
14557:C 27 Aug 17:07:44.212 # Configuration loaded

B机器

[root@9F-VM2 etc]# redis-server /etc/redis_7001.conf
46960:C 27 Aug 17:08:51.600 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
46960:C 27 Aug 17:08:51.600 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=46960, just started
46960:C 27 Aug 17:08:51.600 # Configuration loaded
[root@9F-VM2 etc]# redis-server /etc/redis_7003.conf
46965:C 27 Aug 17:08:56.567 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
46965:C 27 Aug 17:08:56.567 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=46965, just started
46965:C 27 Aug 17:08:56.567 # Configuration loaded
[root@9F-VM2 etc]# redis-server /etc/redis_7005.conf
46970:C 27 Aug 17:08:58.543 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
46970:C 27 Aug 17:08:58.543 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=46970, just started
46970:C 27 Aug 17:08:58.543 # Configuration loaded

21.24 Redis集群搭建配置(下)

 #安装ruby2.2 (只需要一台机器上运行)
 yum -y groupinstall "Development Tools"
 yum -y install gdbm-devel libdb4-devel libffi-devel libyaml libyaml-devel ncurses-devel openssl-devel readline-devel tcl-devel
 cd /root/
 mkdir -p rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
 wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.3.tar.gz -P rpmbuild/SOURCES
 wget https://raw.githubusercontent.com/tjinjin/automate-ruby-rpm/master/ruby22x.spec -P rpmbuild/SPECS
 rpmbuild -bb rpmbuild/SPECS/ruby22x.spec
 yum -y localinstall rpmbuild/RPMS/x86_64/ruby-2.2.3-1.el7.centos.x86_64.rpm
 gem install redis
 cp /usr/local/src/redis-4.0.1/src/redis-trib.rb  /usr/bin/
 redis-trib.rb create --replicas 1 192.88.29.250:7000 192.88.29.250:7002 192.88.29.250:7004 192.88.29.200:7001 192.88.29.200:7003 192.88.29.200:7005
 #创建redis cluster 
# redis-trib.rb create --replicas 1 192.88.29.250:7000 192.88.29.250:7002 192.88.29.250:7004 192.88.29.200:7001 192.88.29.200:7003 192.88.29.200:7005
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.88.29.250:7000
192.88.29.200:7001
192.88.29.250:7002
Adding replica 192.88.29.200:7003 to 192.88.29.250:7000
Adding replica 192.88.29.250:7004 to 192.88.29.200:7001
Adding replica 192.88.29.200:7005 to 192.88.29.250:7002
M: fd815645707134eb8b83a0e7514ab9024ed7b6da 192.88.29.250:7000
   slots:0-5460 (5461 slots) master
M: eafad428987282d9abc2764b11f599f5e7bbe0c8 192.88.29.250:7002
   slots:10923-16383 (5461 slots) master
S: fa1d015f3f72fe7b0d8ec9c54dd3e8b874009725 192.88.29.250:7004
   replicates aaea373f41c98067e7783e452cecd9d9d145a273
M: aaea373f41c98067e7783e452cecd9d9d145a273 192.88.29.200:7001
   slots:5461-10922 (5462 slots) master
S: cad78846d6e8d3a47c3adeee2409b1433207b559 192.88.29.200:7003
   replicates fd815645707134eb8b83a0e7514ab9024ed7b6da
S: b95c0e5ad24f3cf707d3ffc71bf9e3686e3e4b93 192.88.29.200:7005
   replicates eafad428987282d9abc2764b11f599f5e7bbe0c8
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join....
>>> Performing Cluster Check (using node 192.88.29.250:7000)
M: fd815645707134eb8b83a0e7514ab9024ed7b6da 192.88.29.250:7000
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: fa1d015f3f72fe7b0d8ec9c54dd3e8b874009725 192.88.29.250:7004
   slots: (0 slots) slave
   replicates aaea373f41c98067e7783e452cecd9d9d145a273
S: b95c0e5ad24f3cf707d3ffc71bf9e3686e3e4b93 192.88.29.200:7005
   slots: (0 slots) slave
   replicates eafad428987282d9abc2764b11f599f5e7bbe0c8
M: aaea373f41c98067e7783e452cecd9d9d145a273 192.88.29.200:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
M: eafad428987282d9abc2764b11f599f5e7bbe0c8 192.88.29.250:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: cad78846d6e8d3a47c3adeee2409b1433207b559 192.88.29.200:7003
   slots: (0 slots) slave
   replicates fd815645707134eb8b83a0e7514ab9024ed7b6da
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

解释:

redis-trib.rb create --replicas 1 192.88.29.250:7000 192.88.29.250:7002 192.88.29.250:7004 192.88.29.200:7001 192.88.29.200:7003 192.88.29.200:7005

#分配6个端口,写在最前面的3个端口为主,其余的3个为从

>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.88.29.250:7000
192.88.29.200:7001
192.88.29.250:7002
Adding replica 192.88.29.200:7003 to 192.88.29.250:7000
Adding replica 192.88.29.250:7004 to 192.88.29.200:7001
Adding replica 192.88.29.200:7005 to 192.88.29.250:7002


21.25 redis集群操作


#检查 集群状态 

redis-trib.rb check  192.168.133.130:7000

# redis-trib.rb check 192.88.29.250:7000
>>> Performing Cluster Check (using node 192.88.29.250:7000)
M: fd815645707134eb8b83a0e7514ab9024ed7b6da 192.88.29.250:7000
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: fa1d015f3f72fe7b0d8ec9c54dd3e8b874009725 192.88.29.250:7004
   slots: (0 slots) slave
   replicates aaea373f41c98067e7783e452cecd9d9d145a273
S: b95c0e5ad24f3cf707d3ffc71bf9e3686e3e4b93 192.88.29.200:7005
   slots: (0 slots) slave
   replicates eafad428987282d9abc2764b11f599f5e7bbe0c8
S: d4ea65e82c1d10192bc8a0c8a21f390485a88cf8 192.88.29.250:7006
   slots: (0 slots) slave
   replicates 1f0c8bcf5405b85b49d51d55809c1f1b1aa08f9c
M: 1f0c8bcf5405b85b49d51d55809c1f1b1aa08f9c 192.88.29.200:7007
   slots: (0 slots) master
   1 additional replica(s)
M: aaea373f41c98067e7783e452cecd9d9d145a273 192.88.29.200:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
M: eafad428987282d9abc2764b11f599f5e7bbe0c8 192.88.29.250:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: cad78846d6e8d3a47c3adeee2409b1433207b559 192.88.29.200:7003
   slots: (0 slots) slave
   replicates fd815645707134eb8b83a0e7514ab9024ed7b6da
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

 redis-cli -c -h 192.88.29.250 -p 7000     //-c说明以集群的方式登录

 # redis-cli -c -h 192.88.29.250 -p 7000
192.88.29.250:7000> set key1 123
-> Redirected to slot [9189] located at 192.88.29.200:7001
OK
#located at 是指key指向后接的ip:port
192.88.29.200:7001> set key2 234
-> Redirected to slot [4998] located at 192.88.29.250:7000
OK
192.88.29.250:7000> set key3 345
OK
#当没有出现located at的ip的时候,那么key就是存在本机了


 任意一个节点都可以创建key,或者查看key(演示)

 redis-trib.rb check  192.88.29.250:7000//检测集群状态
 # redis-trib.rb check 192.88.29.250:7000
>>> Performing Cluster Check (using node 192.88.29.250:7000)
M: fd815645707134eb8b83a0e7514ab9024ed7b6da 192.88.29.250:7000
   slots:0-5460 (5461 slots) master
   1 additional replica(s)
S: fa1d015f3f72fe7b0d8ec9c54dd3e8b874009725 192.88.29.250:7004
   slots: (0 slots) slave
   replicates aaea373f41c98067e7783e452cecd9d9d145a273
S: b95c0e5ad24f3cf707d3ffc71bf9e3686e3e4b93 192.88.29.200:7005
   slots: (0 slots) slave
   replicates eafad428987282d9abc2764b11f599f5e7bbe0c8
M: aaea373f41c98067e7783e452cecd9d9d145a273 192.88.29.200:7001
   slots:5461-10922 (5462 slots) master
   1 additional replica(s)
M: eafad428987282d9abc2764b11f599f5e7bbe0c8 192.88.29.250:7002
   slots:10923-16383 (5461 slots) master
   1 additional replica(s)
S: cad78846d6e8d3a47c3adeee2409b1433207b559 192.88.29.200:7003
   slots: (0 slots) slave
   replicates fd815645707134eb8b83a0e7514ab9024ed7b6da
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

解释:

  • M表示master

  • S表示salve

  • 查看任意一个ip:port也是输出同样信息,只要在同一个cluster即可。


关于cluster相关的命令

cluster nodes//列出节点 

# redis-cli -c -h 192.88.29.250 -p 7000
192.88.29.250:7000> CLUSTER NODES
fa1d015f3f72fe7b0d8ec9c54dd3e8b874009725 192.88.29.250:7004@17004 slave aaea373f41c98067e7783e452cecd9d9d145a273 0 1535423473000 4 connected
b95c0e5ad24f3cf707d3ffc71bf9e3686e3e4b93 192.88.29.200:7005@17005 slave eafad428987282d9abc2764b11f599f5e7bbe0c8 0 1535423473000 6 connected
aaea373f41c98067e7783e452cecd9d9d145a273 192.88.29.200:7001@17001 master - 0 1535423472175 4 connected 5461-10922
eafad428987282d9abc2764b11f599f5e7bbe0c8 192.88.29.250:7002@17002 master - 0 1535423473193 2 connected 10923-16383
cad78846d6e8d3a47c3adeee2409b1433207b559 192.88.29.200:7003@17003 slave fd815645707134eb8b83a0e7514ab9024ed7b6da 0 1535423474215 5 connected
fd815645707134eb8b83a0e7514ab9024ed7b6da 192.88.29.250:7000@17000 myself,master - 0 1535423472000 1 connected 0-5460

解释:

行首位置的字符串,与其他行中的master,slave后接的字符串是匹配的,匹配是指主从角色。

例如

b95c0e5ad24f3cf707d3ffc71bf9e3686e3e4b93 192.88.29.200:7005@17005 slave eafad428987282d9abc2764b11f599f5e7bbe0c8 0 1535423473000 6 connected
eafad428987282d9abc2764b11f599f5e7bbe0c8 192.88.29.250:7002@17002 master - 0 1535423473193 2 connected 10923-16383

当看到slave  

eafad428987282d9abc2764b11f599f5e7bbe0c8
#可以理解他是eafad428987282d9abc2764b11f599f5e7bbe0c8的从,那么eafad428987282d9abc2764b11f599f5e7bbe0c8就是 192.88.29.250:7002


#查看集群信息

cluster info
192.88.29.250:7000>
192.88.29.250:7000> CLUSTER INFO
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:1
cluster_stats_messages_ping_sent:62371
cluster_stats_messages_pong_sent:65332
cluster_stats_messages_sent:127703
cluster_stats_messages_ping_received:65327
cluster_stats_messages_pong_received:62371
cluster_stats_messages_meet_received:5
cluster_stats_messages_received:127703

#添加节点

 cluster meet ip port 
 192.88.29.250:7000> CLUSTER MEET 192.88.29.200 7007
OK
 192.88.29.250:7000> CLUSTER MEET 192.88.29.250 7006
OK
192.88.29.250:7000> CLUSTER NODES
fa1d015f3f72fe7b0d8ec9c54dd3e8b874009725 192.88.29.250:7004@17004 slave aaea373f41c98067e7783e452cecd9d9d145a273 0 1535425488606 4 connected
b95c0e5ad24f3cf707d3ffc71bf9e3686e3e4b93 192.88.29.200:7005@17005 slave eafad428987282d9abc2764b11f599f5e7bbe0c8 0 1535425486000 6 connected
d4ea65e82c1d10192bc8a0c8a21f390485a88cf8 192.88.29.250:7006@17006 master - 0 1535425487690 0 connected
1f0c8bcf5405b85b49d51d55809c1f1b1aa08f9c 192.88.29.200:7007@17007 master - 0 1535425486565 0 connected
aaea373f41c98067e7783e452cecd9d9d145a273 192.88.29.200:7001@17001 master - 0 1535425485543 4 connected 5461-10922
eafad428987282d9abc2764b11f599f5e7bbe0c8 192.88.29.250:7002@17002 master - 0 1535425487586 2 connected 10923-16383
cad78846d6e8d3a47c3adeee2409b1433207b559 192.88.29.200:7003@17003 slave fd815645707134eb8b83a0e7514ab9024ed7b6da 0 1535425486000 5 connected
fd815645707134eb8b83a0e7514ab9024ed7b6da 192.88.29.250:7000@17000 myself,master - 0 1535425487000 1 connected 0-5460
#发现新增的2个port都是默认master

 cluster forget node_id //移除某个节点

 注意:

  •  不能移除当前节点--》登录到别的port进行移除指定节点

  •  不能移除master--》除非是将master设为salve才可以进行移除

     

 #将当前节点设置为指定节点的从 

 #cluster replicate node_id
例如,现在要将7006设为7007的从
登录需要设置为从的ip:port 
然后指定7007的node_id
# redis-cli -c -h 192.88.29.250 -p 7006
192.88.29.250:7006> CLUSTER NODES
 d4ea65e82c1d10192bc8a0c8a21f390485a88cf8 192.88.29.250:7006@17006 myself,master - 0 1535426333000 0 connected
1f0c8bcf5405b85b49d51d55809c1f1b1aa08f9c 192.88.29.200:7007@17007 master - 0 1535426335861 7 connected
#找到对应的2个port之后,记住7007的node id号,接下来要指定主从角色
192.88.29.250:7006> CLUSTER REPLICATE 1f0c8bcf5405b85b49d51d55809c1f1b1aa08f9c
OK
#将7006为7007的从
#输出值是理想效果
192.88.29.250:7006> CLUSTER NODES
 d4ea65e82c1d10192bc8a0c8a21f390485a88cf8 192.88.29.250:7006@17006 myself,slave 1f0c8bcf5405b85b49d51d55809c1f1b1aa08f9c 0 1535426370000 0 connected
1f0c8bcf5405b85b49d51d55809c1f1b1aa08f9c 192.88.29.200:7007@17007 master - 0 1535426371686 7 connected

#保存配置文件

cluster saveconfig 
192.88.29.250:7000> CLUSTER SAVECONFIG
OK
保存好的配置文件,在设置好的数据目录
#ls /data/redis_data/7000/nodes_7000.conf
/data/redis_data/7000/nodes_7000.conf
# cat /data/redis_data/7000/nodes_7000.conf
fa1d015f3f72fe7b0d8ec9c54dd3e8b874009725 192.88.29.250:7004@17004 slave aaea373f41c98067e7783e452cecd9d9d145a273 0 1535426979316 4 connected
b95c0e5ad24f3cf707d3ffc71bf9e3686e3e4b93 192.88.29.200:7005@17005 slave eafad428987282d9abc2764b11f599f5e7bbe0c8 0 1535426977081 6 connected
d4ea65e82c1d10192bc8a0c8a21f390485a88cf8 192.88.29.250:7006@17006 slave 1f0c8bcf5405b85b49d51d55809c1f1b1aa08f9c 0 1535426979000 7 connected
1f0c8bcf5405b85b49d51d55809c1f1b1aa08f9c 192.88.29.200:7007@17007 master - 0 1535426977282 7 connected
aaea373f41c98067e7783e452cecd9d9d145a273 192.88.29.200:7001@17001 master - 0 1535426978301 4 connected 5461-10922
eafad428987282d9abc2764b11f599f5e7bbe0c8 192.88.29.250:7002@17002 master - 0 1535426975000 2 connected 10923-16383
cad78846d6e8d3a47c3adeee2409b1433207b559 192.88.29.200:7003@17003 slave fd815645707134eb8b83a0e7514ab9024ed7b6da 0 1535426978099 5 connected
fd815645707134eb8b83a0e7514ab9024ed7b6da 192.88.29.250:7000@17000 myself,master - 0 1535426974000 1 connected 0-5460
vars currentEpoch 7 lastVoteEpoch 0

!!!当保存cluster配置文件后每个端口都会生成一个配置文件

tree /data/redis_data/
/data/redis_data/
├── 7000
│   ├── appendonly.aof
│   ├── dump.rdb
│   └── nodes_7000.conf
├── 7002
│   ├── appendonly.aof
│   ├── dump.rdb
│   └── nodes_7002.conf
├── 7004
│   ├── appendonly.aof
│   ├── dump.rdb
│   └── nodes_7004.conf
└── 7006
    ├── appendonly.aof
    ├── dump.rdb
    └── nodes_7006.conf


猜你喜欢

转载自blog.51cto.com/13578154/2165855