Redis集群配置

1.进入Redis
cd /user/redis-3.2.5

2.进入Redis集群
redis-cli -c -h 192.168.0.242 -p 7001
redis-cli:表示客户端 -c:表示集群 -h:host,表示ip -p:表示端口

set test 222 放值
get test 取值
del test 删除

netstat -nlp |grep LISTEN //查看当前所有监听端口·
netstat -nlp |grep 80 //查看所有80端口使用情况·
netstat -an | grep 3306 //查看所有3306端口使用情况·

3.Redis出现问题时,重启步骤
(1)redis-cli -h 192.168.0.242 -p 7001 shutdown
redis-cli -h 192.168.0.242 -p 7002 shutdown
redis-cli -h 192.168.0.242 -p 7003 shutdown
redis-cli -h 192.168.0.242 -p 7004 shutdown
redis-cli -h 192.168.0.242 -p 7005 shutdown
redis-cli -h 192.168.0.242 -p 7006 shutdown
(2)查看监听的端口 是否被监听
lsof -i:7001
lsof -i:7002
lsof -i:7003
lsof -i:7004
lsof -i:7005
lsof -i:7006

(3) 删除文件 rm -rf nodes-700*
nodes-7001.conf
nodes-7002.conf
nodes-7003.conf
nodes-7004.conf
nodes-7005.conf
nodes-7006.conf

(4)启动
redis-server 7001.conf
redis-server 7002.conf
redis-server 7003.conf
redis-server 7004.conf
redis-server 7005.conf
redis-server 7006.conf
(5)查看监听的端口 是否被监听
lsof -i:7001
lsof -i:7002
lsof -i:7003
lsof -i:7004
lsof -i:7005
lsof -i:7006
(6)清除索引
redis-cli -h 192.168.0.242 -p 7001
FLUSHALL

redis-cli -h 192.168.0.242 -p 7002
FLUSHALL

redis-cli -h 192.168.0.242 -p 7003
FLUSHALL

redis-cli -h 192.168.0.242 -p 7004
FLUSHALL

redis-cli -h 192.168.0.242 -p 7005
FLUSHALL

redis-cli -h 192.168.0.242 -p 7006
FLUSHALL

(7)redis-cli -h 192.168.0.242 -p 7001 shutdown
redis-cli -h 192.168.0.242 -p 7002 shutdown
redis-cli -h 192.168.0.242 -p 7003 shutdown
redis-cli -h 192.168.0.242 -p 7004 shutdown
redis-cli -h 192.168.0.242 -p 7005 shutdown
redis-cli -h 192.168.0.242 -p 7006 shutdown
(8)删除文件 rm -rf nodes-700*
nodes-7001.conf
nodes-7002.conf
nodes-7003.conf
nodes-7004.conf
nodes-7005.conf
nodes-7006.conf
(9)启动
redis-server 7001.conf
redis-server 7002.conf
redis-server 7003.conf
redis-server 7004.conf
redis-server 7005.conf
redis-server 7006.conf

redis-server cluster/7001/redis.conf
redis-server cluster/7002/redis.conf
redis-server cluster/7003/redis.conf
redis-server cluster/7004/redis.conf
redis-server cluster/7005/redis.conf
redis-server cluster/7006/redis.conf

(8)集群设置
cd src(必须进入)

./redis-trib.rb create --replicas 1 192.168.0.242:7001 192.168.0.242:7002 192.168.0.242:7003 192.168.0.242:7004 192.168.0.242:7005 192.168.0.242:7006


另一种方式:src/redis-cli --cluster create 172.28.18.73:7001 172.28.18.73:7002 172.28.18.73:7003 172.28.18.74:7004 172.28.18.74:7005 172.28.18.74:7006 --cluster-replicas 1


2.艾麒企信通Redis重启

cd /user/redis-3.2.3
(1)删除文件 rm -rf nodes-6379

3.海航正式企信通Redis重启

cd /user/redis-4.0.2
(1)redis-cli -h 10.72.83.147 -p 6379 shutdown
redis-cli -h 10.72.83.148 -p 6379 shutdown
redis-cli -h 10.72.83.149 -p 6379 shutdown
redis-cli -h 10.72.83.137 -p 6379 shutdown
redis-cli -h 10.72.83.164 -p 6379 shutdown
redis-cli -h 10.72.83.165 -p 6379 shutdown
(2)查看监听的端口 是否被监听
lsof -i:6379
(3) 删除文件 rm -rf nodes-6379.conf

(4)启动
redis-server redis.conf

(5)查看监听的端口 是否被监听
lsof -i:6379

(6)清除索引
redis-cli -h 10.72.83.147 -p 6379
FLUSHALL

redis-cli -h 10.72.83.148 -p 6379
FLUSHALL

redis-cli -h 10.72.83.149 -p 6379
FLUSHALL

redis-cli -h 10.72.83.137 -p 6379
FLUSHALL

redis-cli -h 10.72.83.164 -p 6379
FLUSHALL

redis-cli -h 10.72.83.165 -p 6379
FLUSHALL

(7)redis-cli -h 10.72.83.147 -p 6379 shutdown
redis-cli -h 10.72.83.148 -p 6379 shutdown
redis-cli -h 10.72.83.149 -p 6379 shutdown
redis-cli -h 10.72.83.137 -p 6379 shutdown
redis-cli -h 10.72.83.164 -p 6379 shutdown
redis-cli -h 10.72.83.165 -p 6379 shutdown
(8)删除文件 rm -rf nodes-6379.conf

(9)启动
redis-server redis.conf

(8)集群设置
cd src(必须进入)

./redis-trib.rb create --replicas 1 10.72.83.147:6379 10.72.83.148:6379 10.72.83.149:6379 10.72.83.137:6379 10.72.83.164:6379 10.72.83.165:6379

进入Redis集群
redis-cli -c -h 10.72.83.147 -p 6379
redis-cli:表示客户端 -c:表示集群 -h:host,表示ip -p:表示端口

set test 222 放值
get test 取值
del test 删除

 

从集群中删除主节点和从节点
redis-trib.rb del-node 10.72.83.147:6379 a085032b9ca43ba87df354bbb4f1594961f06119

posted @ 2020-03-13 10:22  一个小达达  阅读(91)  评论(0)    收藏  举报