集群配置
准备工作
cd /am/usr/redismkdir cluster-testcd cluster-testmkdir 7000 7001 7002 7003 7004 7005cd /am/usr/redis/redis-3.0.7cp src/redis-server /am/usr/redis/cluster-testcp src/redis-config /am/usr/redis/cluster-testcp src/redis-trib.rb /am/usr/redis/cluster-testcd /am/usr/redis/cluster-testcp redis.config /am/usr/redis/cluster-test/redis-7000.config//-- ... 7001 7002 7003 7004 7005
启用集群配置
cd /am/usr/redis/cluster-testvim redis-xxx.config//-- 修改配置如下: daemonize yes port 7000 logfile "/am/usr/redis/cluster-test/7000/redis.log" dir /am/usr/redis/cluster-test/7000 appendonly yes cluster-enabled yes cluster-config-file nodes-7000.conf cluster-node-timeout 15000vim redis-cluster-start//-- 内容如下 #!/bin/sh ./redis-server redis-7000.conf ./redis-server redis-7001.conf ./redis-server redis-7002.conf ./redis-server redis-7003.conf ./redis-server redis-7004.conf ./redis-server redis-7005.confchmod +x redis-cluster-start
配置集群
//-- 集群配置指令依赖rubyyum install rubyyum install rubygemsgem install redis//-- 安装完ruby相关指令后使用 redis-trib.rb create --replicas X ....配置集群//-- Redis Cluster requires at least 3 master nodes./redis-trib.rb create --replicas 1 192.168.197.128:7000 192.168.197.128:7001 192.168.197.128:7002 192.168.197.128:7003 192.168.197.128:7004 192.168.197.128:7005//-- Adding replica 192.168.197.128:7003 to 192.168.197.128:7000//-- Adding replica 192.168.197.128:7004 to 192.168.197.128:7001//-- Adding replica 192.168.197.128:7005 to 192.168.197.128:7002
访问集群
//-- 使用-c参数以集群模式连接redis-cli -c -p 7000 --raw//-- 集群下不能使用select指令