1、安装(略)
可以参考我之前博客:http://mydbs.blog.51cto.com/513727/1745300
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 7000 mkdir 7001 mkdir 7002 mkdir 7003 mkdir 7004 mkdir 7005 mkdir 7006
3.2 模版配置文件
[email protected] redis]# cat redis_node.conf #redis node config port 7000 logfile /opt/redis/log/redis_7000.log dbfilename dump_7000.rdb appendfilename appendonly7000.aof syslog-ident redis7000 Cluster-config-file /etc/redis/7000/nodes_7000.conf include /etc/redis/redis_cluster.conf
3.3 配置集群
cat /etc/redis/redis_cluster.conf #redis conf file daemonize yes timeout 300 save 900 1 save 300 10 save 60 10000 rdbcompression yes dir /opt/redis/data maxclients 1280 appendonly yes appendfsync everysec #集群选项 Cluster-enabled yes Cluster-config-file /etc/redis/nodes_7000.conf Cluster-node-timeout 5000 Cluster-slave-validity-factor 10
3.4 创建配置文件
cat redis_node.conf |sed -e ‘s/7000/7000/‘>/etc/redis/7000/redis_node.conf cat redis_node.conf |sed -e ‘s/7000/7001/‘>/etc/redis/7001/redis_node.conf cat redis_node.conf |sed -e ‘s/7000/7002/‘>/etc/redis/7002/redis_node.conf cat redis_node.conf |sed -e ‘s/7000/7003/‘>/etc/redis/7003/redis_node.conf cat redis_node.conf |sed -e ‘s/7000/7004/‘>/etc/redis/7004/redis_node.conf cat redis_node.conf |sed -e ‘s/7000/7005/‘>/etc/redis/7005/redis_node.conf cat redis_node.conf |sed -e ‘s/7000/7006/‘>/etc/redis/7006/redis_node.conf
3.5 启动服务
redis-server /etc/redis/7000/redis_node.conf redis-server /etc/redis/7001/redis_node.conf redis-server /etc/redis/7002/redis_node.conf redis-server /etc/redis/7003/redis_node.conf redis-server /etc/redis/7004/redis_node.conf redis-server /etc/redis/7005/redis_node.conf redis-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 测试集群
[[email protected] redis]# redis-cli -c -p 7000 127.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"
时间: 2024-12-24 16:20:55