redis3.0集群部署方案
redis1:192.168.1.10:6379
192.168.1.10:6380
redis2:192.168.1.11:6379
192.168.1.11:6380
redis3:192.168.1.12:6379
192.168.1.12:6380
关闭 selinux ,防火墙允许6379 6380端口通过, 先启动各服务器的redis节点在制作集群
redis1配置:
yum -y insall gcc ruby rubygems
tar xf redis-3.0.3.tar.gz
mv redis-3.0.3 /storage/local/redis-3.0.3
cd /storage/local/redis-3.0.3
make MALLOC=libc && make install
mkdir -pv /storage/local/redis-3.0.3/cluster/6379
mkdir -pv /storage/local/redis-3.0.3/cluster/6380
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6379/
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6380/
vi /storage/local/redis-3.0.3/cluster/6379/redis.conf
bind 192.168.1.10
port 6379
daemonize yes
clusterenabled yes
cluster-config-file nodes-6379.conf
appendonly yes
vi /storage/local/redis-3.0.3/cluster/6380/redis.conf
bind 192.168.1.10
port 6380
daemonize yes
clusterenabled yes
cluster-config-file nodes-6380.conf
appendonly yes
redis-server /storage/local/redis-3.0.3/cluster/6379/redis.conf
redis-server /storage/local/redis-3.0.3/cluster/6380/redis.conf
ps aux|grep redis
root 1872 0.2 0.5 129408 2600 ? Ssl 05:06 0:03 redis-server 192.168.1.10:6379 [cluster]
root 1876 0.2 0.5 128356 2560 ? Ssl 05:06 0:03 redis-server 192.168.1.10:6380 [cluster]
root 1887 0.0 0.1 103248 872 pts/0 S+ 05:32 0:00 grep redis
集群制作:
gem install redis
添加集群:
./redis-trib.rb create --replicas 1 192.168.1.10:6379 192.168.10:6380 192.168.1.11:6379 192.168.1.11:6380 192.168.1.12:6379 192.168.1.12:6380
[root@bogon src]# ./redis-trib.rb create --replicas 1 192.168.1.11:6379 192.168.1.11:6380 192.168.1.10:6379 192.168.1.10:6380 192.168.1.12:6379 192.168.1.12:6380
>>> Creating cluster
Connecting to node 192.168.1.11:6379: OK
Connecting to node 192.168.1.11:6380: OK
Connecting to node 192.168.1.10:6379: OK
Connecting to node 192.168.1.10:6380: OK
Connecting to node 192.168.1.12:6379: OK
Connecting to node 192.168.1.12:6380: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.1.12:6379
192.168.1.10:6379
192.168.1.11:6379
Adding replica 192.168.1.10:6380 to 192.168.1.12:6379
Adding replica 192.168.1.12:6380 to 192.168.1.10:6379
Adding replica 192.168.1.11:6380 to 192.168.1.11:6379
M: 7076b413fa9885596f9ac75e30a67ac3f90843dc 192.168.1.11:6379
slots:10923-16383 (5461 slots) master
S: c06e6872a5ccc2f6460b7c003eb71a5af06eb71b 192.168.1.11:6380
replicates 7076b413fa9885596f9ac75e30a67ac3f90843dc
M: 1b86444581dc2c063fba34920d8b49c3b891fdba 192.168.1.10:6379
slots:5461-10922 (5462 slots) master
S: 285f179196dd573d34098b012ed82f341c960141 192.168.1.10:6380
replicates b0fb54cf38c497a93d0853d2a20bdccd5b8de1db
M: b0fb54cf38c497a93d0853d2a20bdccd5b8de1db 192.168.1.12:6379
slots:0-5460 (5461 slots) master
S: 9804509811db5b3dc5cb5594408016b0f4aabed9 192.168.1.12:6380
replicates 1b86444581dc2c063fba34920d8b49c3b891fdba
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.168.1.11:6379)
M: 7076b413fa9885596f9ac75e30a67ac3f90843dc 192.168.1.11:6379
slots:10923-16383 (5461 slots) master
M: c06e6872a5ccc2f6460b7c003eb71a5af06eb71b 192.168.1.11:6380
slots: (0 slots) master
replicates 7076b413fa9885596f9ac75e30a67ac3f90843dc
M: 1b86444581dc2c063fba34920d8b49c3b891fdba 192.168.1.10:6379
slots:5461-10922 (5462 slots) master
M: 285f179196dd573d34098b012ed82f341c960141 192.168.1.10:6380
slots: (0 slots) master
replicates b0fb54cf38c497a93d0853d2a20bdccd5b8de1db
M: b0fb54cf38c497a93d0853d2a20bdccd5b8de1db 192.168.1.12:6379
slots:0-5460 (5461 slots) master
M: 9804509811db5b3dc5cb5594408016b0f4aabed9 192.168.1.12:6380
slots: (0 slots) master
replicates 1b86444581dc2c063fba34920d8b49c3b891fdba
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
redis2配置:
yum -y insall gcc ruby rubygems
tar xf redis-3.0.3.tar.gz
mv redis-3.0.3 /storage/local/redis-3.0.3
cd /storage/local/redis-3.0.3
make MALLOC=libc && make install
mkdir -pv /storage/local/redis-3.0.3/cluster/6379
mkdir -pv /storage/local/redis-3.0.3/cluster/6380
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6379/
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6380/
vi /storage/local/redis-3.0.3/cluster/6379/redis.conf
bind 192.168.1.11
port 6379
daemonize yes
clusterenabled yes
cluster-config-file nodes-6379.conf
appendonly yes
vi /storage/local/redis-3.0.3/cluster/6380/redis.conf
bind 192.168.1.11
port 6380
daemonize yes
clusterenabled yes
cluster-config-file nodes-6380.conf
appendonly yes
redis-server /storage/local/redis-3.0.3/cluster/6379/redis.conf
redis-server /storage/local/redis-3.0.3/cluster/6380/redis.conf
ps aux|grep redis
root 1872 0.2 0.5 129408 2600 ? Ssl 05:06 0:03 redis-server 192.168.1.11:6379 [cluster]
root 1876 0.2 0.5 128356 2560 ? Ssl 05:06 0:03 redis-server 192.168.1.11:6380 [cluster]
root 1887 0.0 0.1 103248 872 pts/0 S+ 05:32 0:00 grep redis
redis3配置:
yum -y insall gcc ruby rubygems
tar xf redis-3.0.3.tar.gz
mv redis-3.0.3 /storage/local/redis-3.0.3
cd /storage/local/redis-3.0.3
make MALLOC=libc && make install
mkdir -pv /storage/local/redis-3.0.3/cluster/6379
mkdir -pv /storage/local/redis-3.0.3/cluster/6380
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6379/
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6380/
vi /storage/local/redis-3.0.3/cluster/6379/redis.conf
bind 192.168.1.12
port 6379
daemonize yes
clusterenabled yes
cluster-config-file nodes-6379.conf
appendonly yes
vi /storage/local/redis-3.0.3/cluster/6380/redis.conf
bind 192.168.1.12
port 6380
daemonize yes
clusterenabled yes
cluster-config-file nodes-6380.conf
appendonly yes
redis-server /storage/local/redis-3.0.3/cluster/6379/redis.conf
redis-server /storage/local/redis-3.0.3/cluster/6380/redis.conf
ps aux|grep redis
root 1872 0.2 0.5 129408 2600 ? Ssl 05:06 0:03 redis-server 192.168.1.12:6379 [cluster]
root 1876 0.2 0.5 128356 2560 ? Ssl 05:06 0:03 redis-server 192.168.1.12:6380 [cluster]
redis1:192.168.1.10:6379
192.168.1.10:6380
redis2:192.168.1.11:6379
192.168.1.11:6380
redis3:192.168.1.12:6379
192.168.1.12:6380
关闭 selinux ,防火墙允许6379 6380端口通过, 先启动各服务器的redis节点在制作集群
redis1配置:
yum -y insall gcc ruby rubygems
tar xf redis-3.0.3.tar.gz
mv redis-3.0.3 /storage/local/redis-3.0.3
cd /storage/local/redis-3.0.3
make MALLOC=libc && make install
mkdir -pv /storage/local/redis-3.0.3/cluster/6379
mkdir -pv /storage/local/redis-3.0.3/cluster/6380
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6379/
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6380/
vi /storage/local/redis-3.0.3/cluster/6379/redis.conf
bind 192.168.1.10
port 6379
daemonize yes
clusterenabled yes
cluster-config-file nodes-6379.conf
appendonly yes
vi /storage/local/redis-3.0.3/cluster/6380/redis.conf
bind 192.168.1.10
port 6380
daemonize yes
clusterenabled yes
cluster-config-file nodes-6380.conf
appendonly yes
redis-server /storage/local/redis-3.0.3/cluster/6379/redis.conf
redis-server /storage/local/redis-3.0.3/cluster/6380/redis.conf
ps aux|grep redis
root 1872 0.2 0.5 129408 2600 ? Ssl 05:06 0:03 redis-server 192.168.1.10:6379 [cluster]
root 1876 0.2 0.5 128356 2560 ? Ssl 05:06 0:03 redis-server 192.168.1.10:6380 [cluster]
root 1887 0.0 0.1 103248 872 pts/0 S+ 05:32 0:00 grep redis
集群制作:
gem install redis
添加集群:
./redis-trib.rb create --replicas 1 192.168.1.10:6379 192.168.10:6380 192.168.1.11:6379 192.168.1.11:6380 192.168.1.12:6379 192.168.1.12:6380
[root@bogon src]# ./redis-trib.rb create --replicas 1 192.168.1.11:6379 192.168.1.11:6380 192.168.1.10:6379 192.168.1.10:6380 192.168.1.12:6379 192.168.1.12:6380
>>> Creating cluster
Connecting to node 192.168.1.11:6379: OK
Connecting to node 192.168.1.11:6380: OK
Connecting to node 192.168.1.10:6379: OK
Connecting to node 192.168.1.10:6380: OK
Connecting to node 192.168.1.12:6379: OK
Connecting to node 192.168.1.12:6380: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.1.12:6379
192.168.1.10:6379
192.168.1.11:6379
Adding replica 192.168.1.10:6380 to 192.168.1.12:6379
Adding replica 192.168.1.12:6380 to 192.168.1.10:6379
Adding replica 192.168.1.11:6380 to 192.168.1.11:6379
M: 7076b413fa9885596f9ac75e30a67ac3f90843dc 192.168.1.11:6379
slots:10923-16383 (5461 slots) master
S: c06e6872a5ccc2f6460b7c003eb71a5af06eb71b 192.168.1.11:6380
replicates 7076b413fa9885596f9ac75e30a67ac3f90843dc
M: 1b86444581dc2c063fba34920d8b49c3b891fdba 192.168.1.10:6379
slots:5461-10922 (5462 slots) master
S: 285f179196dd573d34098b012ed82f341c960141 192.168.1.10:6380
replicates b0fb54cf38c497a93d0853d2a20bdccd5b8de1db
M: b0fb54cf38c497a93d0853d2a20bdccd5b8de1db 192.168.1.12:6379
slots:0-5460 (5461 slots) master
S: 9804509811db5b3dc5cb5594408016b0f4aabed9 192.168.1.12:6380
replicates 1b86444581dc2c063fba34920d8b49c3b891fdba
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.168.1.11:6379)
M: 7076b413fa9885596f9ac75e30a67ac3f90843dc 192.168.1.11:6379
slots:10923-16383 (5461 slots) master
M: c06e6872a5ccc2f6460b7c003eb71a5af06eb71b 192.168.1.11:6380
slots: (0 slots) master
replicates 7076b413fa9885596f9ac75e30a67ac3f90843dc
M: 1b86444581dc2c063fba34920d8b49c3b891fdba 192.168.1.10:6379
slots:5461-10922 (5462 slots) master
M: 285f179196dd573d34098b012ed82f341c960141 192.168.1.10:6380
slots: (0 slots) master
replicates b0fb54cf38c497a93d0853d2a20bdccd5b8de1db
M: b0fb54cf38c497a93d0853d2a20bdccd5b8de1db 192.168.1.12:6379
slots:0-5460 (5461 slots) master
M: 9804509811db5b3dc5cb5594408016b0f4aabed9 192.168.1.12:6380
slots: (0 slots) master
replicates 1b86444581dc2c063fba34920d8b49c3b891fdba
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
redis2配置:
yum -y insall gcc ruby rubygems
tar xf redis-3.0.3.tar.gz
mv redis-3.0.3 /storage/local/redis-3.0.3
cd /storage/local/redis-3.0.3
make MALLOC=libc && make install
mkdir -pv /storage/local/redis-3.0.3/cluster/6379
mkdir -pv /storage/local/redis-3.0.3/cluster/6380
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6379/
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6380/
vi /storage/local/redis-3.0.3/cluster/6379/redis.conf
bind 192.168.1.11
port 6379
daemonize yes
clusterenabled yes
cluster-config-file nodes-6379.conf
appendonly yes
vi /storage/local/redis-3.0.3/cluster/6380/redis.conf
bind 192.168.1.11
port 6380
daemonize yes
clusterenabled yes
cluster-config-file nodes-6380.conf
appendonly yes
redis-server /storage/local/redis-3.0.3/cluster/6379/redis.conf
redis-server /storage/local/redis-3.0.3/cluster/6380/redis.conf
ps aux|grep redis
root 1872 0.2 0.5 129408 2600 ? Ssl 05:06 0:03 redis-server 192.168.1.11:6379 [cluster]
root 1876 0.2 0.5 128356 2560 ? Ssl 05:06 0:03 redis-server 192.168.1.11:6380 [cluster]
root 1887 0.0 0.1 103248 872 pts/0 S+ 05:32 0:00 grep redis
redis3配置:
yum -y insall gcc ruby rubygems
tar xf redis-3.0.3.tar.gz
mv redis-3.0.3 /storage/local/redis-3.0.3
cd /storage/local/redis-3.0.3
make MALLOC=libc && make install
mkdir -pv /storage/local/redis-3.0.3/cluster/6379
mkdir -pv /storage/local/redis-3.0.3/cluster/6380
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6379/
cp /storage/local/redis-3.0.3/redis.conf /storage/local/redis-3.0.3/cluster/6380/
vi /storage/local/redis-3.0.3/cluster/6379/redis.conf
bind 192.168.1.12
port 6379
daemonize yes
clusterenabled yes
cluster-config-file nodes-6379.conf
appendonly yes
vi /storage/local/redis-3.0.3/cluster/6380/redis.conf
bind 192.168.1.12
port 6380
daemonize yes
clusterenabled yes
cluster-config-file nodes-6380.conf
appendonly yes
redis-server /storage/local/redis-3.0.3/cluster/6379/redis.conf
redis-server /storage/local/redis-3.0.3/cluster/6380/redis.conf
ps aux|grep redis
root 1872 0.2 0.5 129408 2600 ? Ssl 05:06 0:03 redis-server 192.168.1.12:6379 [cluster]
root 1876 0.2 0.5 128356 2560 ? Ssl 05:06 0:03 redis-server 192.168.1.12:6380 [cluster]
root 1887 0.0 0.1 103248 872 pts/0 S+ 05:32 0:00 grep redis
本文转自 msj0905 51CTO博客,原文链接:http://blog.51cto.com/sky66/1694639