Redis3.0.3集群安装
cd /home/redis#把软件下载到/home/redis/software目录下,将应用安装到/home/redis目录下。mkdir cluster #创建cluster存放集群软件
cd cluser
mkdir 7000 7001 7002 7003 7004 7005 #创建6个目录,里面分别部署一个redis,三个master,三个slave
cp /home/redis/software/redis.conf ./ #复制一份配置文件
cp /home/redis/software/src/redis-trib.rb ./ #复制集群启动脚本
cp /home/redis/software/src/redis-server ./ #复制redis server
cp /home/redis/software/src/redis-cli ./ #复制redis client
vim redis.conf#修改如下配置
daemonize yes
port 7000 #把redis.conf分别复制到6个目录后,此处端口值修改为对应的目录名
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
#将redis.conf分别复制到6个目录下并修改port的值为目录名
cp redis.conf 7000
cp redis.conf 7001
cp redis.conf 7002
cp redis.conf 7003
cp redis.conf 7004
cp redis.conf 7005
#分别启动6个redis
cd 7000
../redis-server ./redis.conf
cd ../7001
../redis-server ./redis.conf
cd ../7002
../redis-server ./redis.conf
cd ../7003
../redis-server ./redis.conf
cd ../7004
../redis-server ./redis.conf
cd ../7005
../redis-server ./redis.conf
#创建redis集群
./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 \
127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
#启动成功后会有如下信息输出:
>>> Creating cluster
Connecting to node 127.0.0.1:7000: OK
Connecting to node 127.0.0.1:7001: OK
Connecting to node 127.0.0.1:7002: OK
Connecting to node 127.0.0.1:7003: OK
Connecting to node 127.0.0.1:7004: OK
Connecting to node 127.0.0.1:7005: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
Adding replica 127.0.0.1:7003 to 127.0.0.1:7000
Adding replica 127.0.0.1:7004 to 127.0.0.1:7001
Adding replica 127.0.0.1:7005 to 127.0.0.1:7002
M: 20aa266add02caae98dc0446259cb5f2e37336f1 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: c258baee22bee15698be3c85908a2103c36eb9ce 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: 33e1731b173eb8c47d268c5c681887580e517ef1 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
S: f74bdac74b19919e9975dbd84db47fcb887f34d4 127.0.0.1:7003
replicates 20aa266add02caae98dc0446259cb5f2e37336f1
S: 32f7aa6f13ca0d50214b5fcafa50470bbe35edad 127.0.0.1:7004
replicates c258baee22bee15698be3c85908a2103c36eb9ce
S: ed604701d8c7b85970dbced11541d339614e8338 127.0.0.1:7005
replicates 33e1731b173eb8c47d268c5c681887580e517ef1
Can I set the above configuration? (type 'yes' to accept): yes #输入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 127.0.0.1:7000)
M: 20aa266add02caae98dc0446259cb5f2e37336f1 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: c258baee22bee15698be3c85908a2103c36eb9ce 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: 33e1731b173eb8c47d268c5c681887580e517ef1 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
M: f74bdac74b19919e9975dbd84db47fcb887f34d4 127.0.0.1:7003
slots: (0 slots) master
replicates 20aa266add02caae98dc0446259cb5f2e37336f1
M: 32f7aa6f13ca0d50214b5fcafa50470bbe35edad 127.0.0.1:7004
slots: (0 slots) master
replicates c258baee22bee15698be3c85908a2103c36eb9ce
M: ed604701d8c7b85970dbced11541d339614e8338 127.0.0.1:7005
slots: (0 slots) master
replicates 33e1731b173eb8c47d268c5c681887580e517ef1
All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
All 16384 slots covered.
页:
[1]