1、安装(略)
可以参考我之前博客:
2、服务器说明
IP 192.168.1.231
系统 CentOS 6.5 64bit
内存 1G
硬盘 20G
redis 3.0.5
redis监听 7000-7006
3 集群配置
3.1 创建配置目录
cd /etc/redis/mkdir 7000mkdir 7001mkdir 7002mkdir 7003mkdir 7004mkdir 7005mkdir 7006
3.2 模版配置文件
root@redis01 redis]# cat redis_node.conf #redis node configport 7000logfile /opt/redis/log/redis_7000.logdbfilename dump_7000.rdbappendfilename appendonly7000.aofsyslog-ident redis7000Cluster-config-file /etc/redis/7000/nodes_7000.confinclude /etc/redis/redis_cluster.conf
3.3 配置集群
cat /etc/redis/redis_cluster.conf#redis conf filedaemonize yestimeout 300save 900 1save 300 10save 60 10000rdbcompression yesdir /opt/redis/datamaxclients 1280appendonly yesappendfsync everysec #集群选项Cluster-enabled yesCluster-config-file /etc/redis/nodes_7000.confCluster-node-timeout 5000Cluster-slave-validity-factor 10
3.4 创建配置文件
cat redis_node.conf |sed -e 's/7000/7000/'>/etc/redis/7000/redis_node.confcat redis_node.conf |sed -e 's/7000/7001/'>/etc/redis/7001/redis_node.confcat redis_node.conf |sed -e 's/7000/7002/'>/etc/redis/7002/redis_node.confcat redis_node.conf |sed -e 's/7000/7003/'>/etc/redis/7003/redis_node.confcat redis_node.conf |sed -e 's/7000/7004/'>/etc/redis/7004/redis_node.confcat redis_node.conf |sed -e 's/7000/7005/'>/etc/redis/7005/redis_node.confcat redis_node.conf |sed -e 's/7000/7006/'>/etc/redis/7006/redis_node.conf
3.5 启动服务
redis-server /etc/redis/7000/redis_node.confredis-server /etc/redis/7001/redis_node.confredis-server /etc/redis/7002/redis_node.confredis-server /etc/redis/7003/redis_node.confredis-server /etc/redis/7004/redis_node.confredis-server /etc/redis/7005/redis_node.confredis-server /etc/redis/7006/redis_node.conf
3.6 启动集群
redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 127.0.0.1:7006
3.7 测试集群
[root@redis01 redis]# redis-cli -c -p 7000127.0.0.1:7000> get ooo1o-> Redirected to slot [11694] located at 127.0.0.1:7002"sldkfekrwe"127.0.0.1:7000> get ooo1o-> Redirected to slot [11694] located at 127.0.0.1:7005"sldkfekrwe"