标签:rmi 无法创建 扩容 open har 网上 cti idf 安装
*** 集群对应的主从节点如果同时down,则整个redis集群无法工作
*** 部分是对网上资源的整理,部分是安装过程中存在问题的总结
centos1:192.168.215.156 A
centos2:192.168.215.157 B
yum -y install zlib ruby rubygems
gem install redis
查看ruby安装的软件的结合
gem list
[root@A opt]# tar -zxvf redis-3.2.2.tar.gz
[root@A opt]# cd redis-3.2.2
[root@A redis-3.2.2]# cd src/
[root@A src]# make && make install
[root@A redis-3.2.2]# mkdir cluster/
[root@A cluster]# mkdir 7000
[root@A cluster]# mkdir 7001
[root@A cluster]# mkdir 7002
[root@B cluster]# mkdir 7003
[root@B cluster]# mkdir 7004
[root@B cluster]# mkdir 7005
[root@A 7000]# cat redis.conf
port 7000
#端口7000,7002,7003
bind 192.168.215.156
#默认ip为127.0.0.1 需要改为其他节点机器可访问的ip或者网段,否则创建集群时无法访问对应的端口,无法创建集群
daemonize yes
#redis后台运行
pidfile /var/run/redis_7000.pid
#pidfile文件对应7000,7001,7002
cluster-enabled yes
#开启集群 把注释#去掉
cluster-config-file nodes_7000.conf
#集群的配置 配置文件首次启动自动生成 7000,7001,7002
cluster-node-timeout 15000
#请求超时 默认15秒,可自行设置
appendonly yes
#数据存放AOF
[root@A redis-3.2.2]# redis-server cluster/7000/redis.conf
[root@skycloud1 redis-3.2.2]# ps -ef|grep redis
root 11302 1 0 11:41 ? 00:00:03 redis-server 192.168.215.156:7000 [cluster]
root 11306 1 0 11:41 ? 00:00:03 redis-server 192.168.215.156:7001 [cluster]
root 11310 1 0 11:41 ? 00:00:03 redis-server 192.168.215.156:7002 [cluster]
root 12125 2558 0 12:00 pts/4 00:00:00 redis-cli -h 192.168.215.156 -c -p 7000
root 12135 5806 0 12:15 pts/0 00:00:00 grep redis
例如:6379端口,需要放开6379和16379;6380需要开放6380和16380端口
原则上+10000
保护模式需要修改:protected-mode no
[root@A redis-3.2.2]# redis-trib.rb create --replicas 1 A:7000 A:7001 A:7002 B:7003 B:7004 B:7005
----replicas 1 标识主节点下有1个从节点
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.215.157:7003
192.168.215.156:7000
192.168.215.157:7004
.
.
.
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
集群的链接redis-cli -h host -c -p port
[root@A cluster]# redis-cli -h 192.168.215.156 -c -p 7000
[root@A redis-3.2.2]# redis-cli -h 192.168.215.157 -c -p 7003
192.168.215.157:7003> SET "xiaozhang" "男"
-> Redirected to slot [6387] located at 192.168.215.156:7000
OK
192.168.215.156:7000> KEYS *
1) "xiaozhang"
192.168.215.156:7000> get "xiaozhang"
"\xe7\x94\xb7"
./redis-trib.rb add-node IP:7006 IP:7000
./redis-trib.rb add-node --slave --master-id 226d1af3c95bf0798ea9fed86373b89347f889da 127.0.0.1:7007 127.0.0.1:7000
查看:
? src ./redis-trib.rb info 127.0.0.1:7000
127.0.0.1:7000 (0b7e0d53...) -> 4 keys | 5461 slots | 1 slaves.
127.0.0.1:7001 (e0e8dfdd...) -> 4 keys | 5462 slots | 1 slaves.
127.0.0.1:7006 (226d1af3...) -> 0 keys | 0 slots | 1 slaves. #7006上完全没有slot
127.0.0.1:7002 (ec964a7c...) -> 9 keys | 5461 slots | 1 slaves.
[OK] 17 keys in 4 masters.
0.00 keys per slot on average.
./redis-trib.rb reshard 127.0.0.1:7000
./redis-trib.rb del-node 127.0.0.1:7006 88e16f91609c03277f2ee6ce5285932f58c221c1
标签:rmi 无法创建 扩容 open har 网上 cti idf 安装
原文地址:http://www.cnblogs.com/suy-bb/p/7297988.html