CentOS7 redis5.0.5集群搭建

3台centos7虚拟机

s1 192.168.175.11 7000,7001,7002
s2 192.168.175.12 7000,7001,7002
s3 192.168.175.13 7000,7001,7002

3台虚拟机都要操作

$ systemctl stop firewalld #关闭防火墙
$ firewall-cmd –state #查看防火墙状态
not running
$ mkdir -p /system/redis/redis-cluster
$ mkdir software
$ cd software

$ wget http://download.redis.io/releases/redis-5.0.5.tar.gz
$ tar zxvf redis-5.0.5.tar.gz
$ cd redis-5.0.5
$ yun install gcc
make distclean && make
$ cd src
$ cp redis-server /usr/sbin/redis-server
$ cp redis-cli /usr/sbin/redis-cli
$ mkdir -p /system/redis/redis-cluster/{7000,7001,7002}
$ for i in {0..2}; do cp /root/software/redis-5.0.5/redis.conf /system/redis/redis-cluster/700$i/; done

3台机器都要修改配置文件

* port 7000 #端口7000,7001,7002
* bind 192.168.175.11/12/13
* daemonize yes
* pidfile /var/run/redis_7000.pid
* cluster-enabled yes
* cluster-config-file nodes_7000.conf
* cluster-node-timeout 15000 #请求超时,默认15秒,可自行设置
* appendonly yes #aof日志开启,有需要就开启,它会每次写操作都记录一条日志

最重要的事情

进入每台机器的每个配置文件的目录中运行redis-server redis.conf

 

随便找一台机器

redis-cli -\-cluster create 192.168.175.11:7000 192.168.175.11:7001 192.168.175.11:7002 192.168.175.12:7000 192.168.175.12:7001 192.168.175.12:7002 192.168.175.13:7000 192.168.175.13:7001 192.168.175.13:7002 -\-cluster-replicas 1

输入yes

搞定

 

修改所有redis集群中的redis.conf文件加入:
masterauth passwd123
requirepass passwd123

redis-cli -a passwd123 -\-cluster create 192.168.175.11:7000 192.168.175.11:7001 192.168.175.11:7002 192.168.175.12:7000 192.168.175.12:7001 192.168.175.12:7002 192.168.175.13:7000 192.168.175.13:7001 192.168.175.13:7002 -\-cluster-replicas 1

-\-替换为2个英文减号

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据