redhat7搭建redis哨兵模式

redhat7搭建redis哨兵模式

1.下载redis ,解压

2.redis在Linux安装需要用到gcc 所以在安装之前保证Linux系统有gcc相关包及可编译环境 如果没有则需要 yum install gcc 即可 (注 redhat 7的yum功能需要注册 订阅 如果没有需要卸载自定义yum 安装centos的yum)
3. make & make install(注意 权限问题)
4. 编译完成没有报错后会在/etc/local/bin/下生成几个redis的文件
5. 启动解压后的redis即可 cd redis安装目录下/ ./src/redis-server redis.conf
6.配置1主2 从3哨兵 说明 :由于我们是在Linux通一台机器下启动多个redis所以需要将现有redis进行复制即可
1) 主redis服务
① cp redis-版本号 redis-master
② 修改配置redis.conf
修改内容
#bind 127.0.0.1
protected-mode no #保护模式 NO
daemonize yes # 允许静默运行
2)从1redis服务
① cp redis-master redis-slave1
② 修改配置redis.conf
修改内容
#bind 127.0.0.1
port 6380
protected-mode no #保护模式 NO
daemonize yes # 允许静默运行
slaveof 主IP 主端口
pidfile pidfile /var/run/redis_6380.pid #需要修改 不同的db存储在不同的地方
3)从2redis服务
① cp redis-master redis-slave2
② 修改配置redis.conf
修改内容
#bind 127.0.0.1
port 6381
protected-mode no #保护模式 NO
daemonize yes # 允许静默运行
slaveof 主IP 主端口
pidfile pidfile /var/run/redis_6381.pid #需要修改 不同的db存储在不同的地方
4) 哨兵1redis服务
① cp redis-版本号 sentinel1
② 修改配置sentinel.conf
修改内容
#bind 127.0.0.1
port 26379
daemonize yes # 允许静默运行
sentinel monitor mymaster 主IP 主端口 2 #2是配置决策机制
5) 哨兵2redis服务
① cp sentinel1 sentinel2
② 修改配置sentinel.conf
修改内容
#bind 127.0.0.1
port 26380
daemonize yes # 允许静默运行
sentinel monitor mymaster 主IP 主端口 2 #2是配置决策机制
6) 哨兵3redis服务
① cp sentinel1 sentinel3
② 修改配置sentinel.conf
修改内容
#bind 127.0.0.1
port 26381
daemonize yes # 允许静默运行
sentinel monitor mymaster 主IP 主端口 2 #2是配置决策机制
7. 配置完成后启动
1)启动主服务
cd /路径/redis-master ./src/redis-server redis.conf
2)启动从服务
cd /路径/redis-slave1 ./src/redis-server redis.conf
3)启动从服务
cd /路径/redis-slave2 ./src/redis-server redis.conf
4)启动哨兵服务
cd /路径/sentinel1 ./src/redis-sentinel sentinel.conf
5)启动哨兵服务
cd /路径/sentinel2 ./src/redis-sentinel sentinel.conf
6)启动哨兵服务
cd /路径/sentinel3 ./src/redis-sentinel sentinel.conf
8.验证 连接

提示:如有问题请指指正,谢谢!


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值