Redis 3.0集群搭建/设备/FAQ

·声明


1,已官网中文教程为根蒂根基,边看边学,连络景象近况搭建。


2,哥对Ruby不酷爱、不熟悉、不感冒,所述内容如有疑义请谅解。


3,3.0官说集群还在测试中,其实用用也还算马忽略虎,对外集群API至心少,望有识之士可以或许出力。


 


·筹办材料


VM9,CentOS 6.4_x86_64(2.6+),SecureCRT,CentOS-6.4-x86_64-bin-DVD1.iso


redis官网:redis-3.0.0-beta1.tar.gz


ruby官网:rubygems-2.0.7.zip


rubygem官网:redis-3.0.7.gem


 


·下锅


1,把一些根蒂根基包装一下,后面会用到


service iptables stop


放入DVD1-


yum install –y gcc*


yum install –y ruby


yum install –y ruby-rdoc


2,装redis


tar -xvf redis-3.0.0-beta1.tar.gz


cd redis-3.0.0-beta


make


make install


ll /usr/local/bin


3,设备集群(假定 ¥REDIS_HOME=/root/soft/redis,就像ORACLE_HOME一样)


cd ¥REDIS_HOME


mkdir cluster-test


cd cluster-test


mkdir 7000 7001 7002 7003 7004 7005


vim redis.conf,批改内容如下:


port 7000 个性化



cluster-enabled yes

cluster-config-file nodes.7000.conf 个性化
cluster-node-timeout 5000
appendonly yes
appendfilename "appendonly.7000.aof" 个性化
deamonize yes
pidfile 个性化
log 个性化


 


cp ../redis.conf ./7000


cp ../redis.conf ./7001


cp ../redis.conf ./7002


cp ../redis.conf ./7003


cp ../redis.conf ./7004


cp ../redis.conf ./7005


cp /usr/local/bin/redis-server ./7000


cp /usr/local/bin/redis-server ./7001


cp /usr/local/bin/redis-server ./7002


cp /usr/local/bin/redis-server ./7003


cp /usr/local/bin/redis-server ./7004


cp /usr/local/bin/redis-server ./7005


/root/soft/redis/cluster-test/redis-server /root/soft/redis/cluster-test/7000/redis.conf


/root/soft/redis/cluster-test/redis-server /root/soft/redis/cluster-test/7001/redis.conf


/root/soft/redis/cluster-test/redis-server /root/soft/redis/cluster-test/7002/redis.conf


/root/soft/redis/cluster-test/redis-server /root/soft/redis/cluster-test/7003/redis.conf


/root/soft/redis/cluster-test/redis-server /root/soft/redis/cluster-test/7004/redis.conf


/root/soft/redis/cluster-test/redis-server /root/soft/redis/cluster-test/7005/redis.conf


若是须要看一看:ps –ef|grep redis


若是须要杀一杀:ps -ef|grep redis|egrep -v grep|awk -F "" "" ""{print ¥2}""|xargs kill -9


4,设备ruby集群脚本


cd /root/soft/rubygems


ruby setup.rb


到redis-3.0.7.gem路径下


gem install -l redis(不消L的话,走ruby官网,95%被WALL,你懂得,本身改source吧)


./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7002 127.0.0.3:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7005(半路记得“yes"一下)



>>> 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
127.0.0.1:7000 replica #1 is 127.0.0.1:7003
127.0.0.1:7001 replica #1 is 127.0.0.1:7004
127.0.0.1:7002 replica #1 is 127.0.0.1:7005
M: bc66d90ca24eb6b69a3b375a4e242fef00de2052 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: bc66d90ca24eb6b69a3b375a4e242fef00de2052 127.0.0.1:7001
slots:5461-10921 (5461 slots) master
M: bc66d90ca24eb6b69a3b375a4e242fef00de2052 127.0.0.1:7002
slots:10922-16383 (5462 slots) master
S: bc66d90ca24eb6b69a3b375a4e242fef00de2052 127.0.0.1:7003
replicates bc66d90ca24eb6b69a3b375a4e242fef00de2052
S: bc66d90ca24eb6b69a3b375a4e242fef00de2052 127.0.0.1:7004
replicates bc66d90ca24eb6b69a3b375a4e242fef00de2052
S: bc66d90ca24eb6b69a3b375a4e242fef00de2052 127.0.0.1:7005
replicates bc66d90ca24eb6b69a3b375a4e242fef00de2052
Can I set the above configuration? (type ""yes"" to accept): yes
>>> Nodes configuration d
>>> 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: 75bab28893c3536aecdb9879df97db89b24ce21e 127.0.0.1:7000
slots:5461-10921 (5461 slots) master
M: cfc344721cad8a5ddb7a8d675eb3a4d6e5b9d1c1 127.0.0.1:7002
slots:10922-16383 (5462 slots) master
M: 01b3977a3f592fd1538e8c83f86bbba37d0c1058 127.0.0.3:7003
slots:0-5460 (5461 slots) master
M: df59fce238a1c538933bdc170edb27835d0b7cc7 127.0.0.1:7004
slots: (0 slots) master
replicates 01b3977a3f592fd1538e8c83f86bbba37d0c1058
M: b6bdb2d309aa7f0b810288f24e975230419f25b1 127.0.0.1:7005
slots: (0 slots) master
replicates 75bab28893c3536aecdb9879df97db89b24ce21e
M: b6bdb2d309aa7f0b810288f24e975230419f25b1 127.0.0.1:7005
slots: (0 slots) master
replicates cfc344721cad8a5ddb7a8d675eb3a4d6e5b9d1c1
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.


  redis-cli -c -p 7000



127.0.0.1:7000> set b c

-> Redirected to slot [3300] located at 127.0.0.1:7003
OK
127.0.0.1:7003> set hello world
OK
127.0.0.1:7003> get foo
-> Redirected to slot [12182] located at 127.0.0.1:7002
(nil)
127.0.0.1:7002> get hello
-> Redirected to slot [866] located at 127.0.0.1:7003
"world"
127.0.0.1:7003> get b
"c"
127.0.0.1:7003>


 


·FAQ



*** ERROR: Invalid configuration for cluster creation.


*** Redis Cluster requires at least 3 master nodes.

*** This is not possible with 4 nodes and 1 replicas per node.

*** At least 6 nodes are required.


 


·Redis官说,至少3+3,还延续着Master-Slave的设计理念,这点上小我感觉Cassandra的一致性确切了得。


 



Either the node already knows other nodes


 


·因为报错是ruby报的,不太可以或许懂得其意思,因为我之前做了些单机压测,可能直接叠上集群会有垃圾数据,所以把/var/db/和/var/log/下能清空的都清空了。


 



[13321] 09 Mar 08:09:24.290 # Handshake error: we already know node bc66d90ca24eb6b69a3b375a4e242fef00de2052, updating the address if needed.


 


·同样事理,ruby报的错,一开端一向在join被我ctrl+c之后开端报错,用上方的办法无果。把所有app目次清空然后redis重装。大师测试时,最后事先vmware快照一下或者redis现网数据备份一下。


 


·OK,本身爽一下吧

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值