Linux虚拟机系统中进行redis的哨兵模式配置

一、配置步骤

开一台虚拟机
1.创建三个redis配置文件:/etc/redis下
pidfile "/var/run/redis6380.pid" redis的id号
port 6380
logfile "6380.log" //redis开启后产生的日志文件
dbfilename "dump6380.rdb" //rdb持久化文件
#bin 127.0.0.1 // 注释掉
protected-mode no //yes改成no
2.启动
redis-server /etc/配置文件
查看命令:ps -ef | grep redis
关闭redis:
root 1552 1 0 17:23 ? 00:00:01 /usr/local/bin/redis-server 127.0.0.1:6379
root 2006 1 0 17:52 ? 00:00:00 redis-server 127.0.0.1:6380
root 2013 1 0 17:52 ? 00:00:00 redis-server 127.0.0.1:6381
[root@localhost redis]# kill 1552
[root@localhost redis]# kill 2006
[root@localhost redis]# kill 2013

3.客服端访问
redis-cli -p 端口号 -h 主机ip

[root@localhost redis]# redis-cli -p 6379 -h 192.168.208.128
192.168.208.128:6379> slaveof 192.168.208.128 6381
OK
[root@localhost redis]# redis-cli -p 6380 -h 192.168.208.128
4.设置一个主节点
启动机器 slaveof 主机点的ip 端口号
192.168.208.128:6380> slaveof 192.168.208.128 6381
OK

5.配置模式。sentinel.conf 放在主节点下。一定要注意防火墙
[root@localhost redis]# redis-sentinel /etc/redis/sentinel.conf

sentinel.conf中的配置内容
protected-mode no #关闭保护模式,不关闭的话,外网链接不上
sentinel monitor mymaster 192.168.70.128 6381 1

二、截图

 

猜你喜欢

转载自www.cnblogs.com/sitian2050/p/11852989.html