Centos7搭建redis集群及安装sentinel

准备三个节点,系统版本为CentOS7.3

11.0.8.15   master
11.0.8.16   slave01
11.0.8.17   slave02

1、安装redis

# yum install -y redis

2、修改redis的配置文件

# vim /etc/redis.conf
#bind 127.0.0.1
protected-mode no
daemonize yes
appendonly yes
slaveof 11.0.8.15 6379    #从节点需要开启这条指令

3、启动redis服务

# systemctl start redis && systemctl enable redis

4、查看复制信息

# redis-cli -h 11.0.8.15 
11.0.8.15:6379> set name keith
OK
11.0.8.15:6379> get name
"keith"
11.0.8.15:6379> keys *
1) "name"

11.0.8.15:6379> info replication
# Replication
role:master
connected_slaves:2
slave0:ip=11.0.8.16,port=6379,state=online,offset=128,lag=1
slave1:ip=11.0.8.17,port=6379,state=online,offset=142,lag=1
master_repl_offset:142
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:141

5、修改sentinel的配置文件

# vim /etc/redis-sentinel.conf 
sentinel monitor mymaster 11.0.8.15 6379 2

6、启动sentinel服务

# systemctl start redis-sentinel && systemctl enable redis-sentinel
# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:26379           0.0.0.0:*               LISTEN      41288/redis-sentine 
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      41220/redis-server  
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      932/dnsmasq         
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1555/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1178/master         
tcp6       0      0 :::26379                :::*                    LISTEN      41288/redis-sentine 
tcp6       0      0 :::6379                 :::*                    LISTEN      41220/redis-server  
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::53                   :::*                    LISTEN      932/dnsmasq         
tcp6       0      0 :::22                   :::*                    LISTEN      1555/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1178/master

转载于:https://www.cnblogs.com/keithtt/p/6719532.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值