redis集群(Ubuntu)
1、运行命令:sudo mkdir 7001 7002 7003 7004 7005 7006
在/usr/local/redis_4.0(redis安装目录)目录中创建文件夹:7001 7002 7003 7004 7005 7006
2、复制配置文件到文件夹中
3、打开配置文件,修改配置项
port 7001 //六个节点配置文件分别是7001-7006
daemonize yes //redis后台运行
pidfile /var/run/redis_7001.pid //pidfile文件对应7001-7006
cluster-enabled yes //开启集群
cluster-config-file nodes_7001.conf //保存节点配置,自动创建,自动更新对应7001-7006
cluster-node-timeout 5000 //集群超时时间,节点超过这个时间没反应就断定是宕机
appendonly yes //存储方式,aof,将写操作记录保存到日志中
bind 172.168.10.11 //ip地址
4、修改完成之后依次启动服务:sudo bin/redis-server 7006/redis.conf
查看进程,看服务是否启动成功
5、复制redis-trib.rb到bin目录下(必须跟redis-server在一个文件夹下)
6、运行命令,创建集群:
sudo redis-trib.rb create --replicas 1 172.168.10.25:7001 172.168.10.25:7002 172.168.10.25:7003 172.168.10.25:7004 172.168.10.25:7005 172.168.10.25:7006
7、实验一下
成功!!!!