美文网首页
redis 主从哨兵生产环境

redis 主从哨兵生产环境

作者: 程序男保姆 | 来源:发表于2022-04-13 13:32 被阅读0次

[linux 安装redis 完整步骤]

(一)主从搭建

1.获取redis资源

wget http://download.redis.io/releases/redis-6.0.8.tar.gz

2.解压

tar xzvf redis-6.0.8.tar.gz

3.安装

cd redis-6.0.8
make
cd src
make install PREFIX=/usr/local/redis
查看gcc版本
gcc -v
# 解决办法
## 升级到 5.3及以上版本
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils 
scl enable devtoolset-9 bash
#注意:scl命令启用只是临时的,推出xshell或者重启就会恢复到原来的gcc版本。
#如果要长期生效的话,执行如下:
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

4.移动配置文件到安装目录下

# 配置文件
mkdir /usr/local/redis/conf
# 持久化文件
 mkdir /usr/local/redis/data
# pid
mkdir /usr/local/redis/pid
# log
mkdir /usr/local/redis/log
# tmp
mkdir /usr/local/redis/tmp
cp redis.conf /usr/local/redis/conf

5.配置redis.conf

# NETWORK
bind 0.0.0.0

# GENERAL
# pid 路径
pidfile /usr/local/redis/pid/redis_6379.pid

# SNAPSHOTTING
# 数据持久路径
dir /usr/local/redis/data

# REPLICATION
# 主服务器连接地址 (只有从服务器配置)
 replicaof 5.3.6.139 6379
# 主服务器连接密码 (只有从服务器配置)
 masterauth shoioqehroqewwurqdfasd

# SECURITY
# redis 密码
 requirepass shoioqehroqewwurqdfasd

6.将redis加入到开机启动

  vi /etc/rc.local //在里面添加内容:/usr/local/redis/bin/redis-server 
      /usr/local/redis/etc/redis.conf (意思就是开机调用这段开启redis的命令)

7.开启redis

  /usr/local/redis/bin/redis-server /usr/local/redis/conf/redis.conf 

8.将redis-cli,redis-server拷贝到bin下,让redis-cli指令可以在任意目录下直接使用

  cp /usr/local/redis/bin/redis-server /usr/local/bin/
  cp /usr/local/redis/bin/redis-cli /usr/local/bin/

检测

#检测后台进程是否存在
ps -ef |grep redis
#检测6379端口是否在监听
netstat -lntp | grep 6379
# 检测主从
127.0.0.0> info

(二)哨兵配置

sentinel.conf 所有哨兵服务器配置都一样

# 禁止保护模式
protected-mode no
# 后台启动
daemonize yes
# 配置启动端口
port 27001
# 哨兵选举日志
logfile "/usr/local/redis/log/sentinel_log"
# pid
pidfile /usr/local/redis/pid/redis-sentinel.pid
# 
dir /usr/local/redis/tmp

# 配置监听的主服务器,这里sentinel monitor代表监控,mymaster代表服务器的名称,可以自定义,192.168.11.128代表监控的主服务器,6379代表端口,2代表只有两个或两个以上的哨兵认为主服务器不可用的时候,才会进行failover操作。
sentinel monitor mymaster 192.168.11.128 6379 2
# sentinel author-pass定义服务的密码,mymaster是服务名称,123456是Redis服务器密码
sentinel auth-pass mymaster yuan
# 
sentinel down-after-milliseconds mymaster 3000

# 启动哨兵
 bin/redis-sentinel conf/sentinel.conf 

相关文章

  • redis 主从哨兵生产环境

    [linux 安装redis 完整步骤] (一)主从搭建 1.获取redis资源 2.解压 3.安装 4.移动配置...

  • redis(二)

    Redis用户认证 禁用危险命令 主从复制的过程 主从复制的部署 哨兵 Redis哨兵+主从+密码 Redis哨兵...

  • Redis:集群方案

    单实例往往不能满足生产环境的需求,需要引入Redis集群,比较常见的Redis集群方案有主从复制、哨兵模式、官网的...

  • redis集群

    本章要点 Redis主从 Redis哨兵 Redis集群 主从复制原理 1. Redis 主从 比较简单在redi...

  • Redis主从哨兵模式配置脚本

    Redis主从哨兵模式配置脚本

  • redis集群模式:redis单点、redis主从、redis哨

    目录 redis单点、redis主从、redis哨兵 sentinel,redis集群cluster配置搭建与使用...

  • redis主从 + Sentinel 哨兵模式

    环境介绍 docker配置redis主从复制(一主两从),启动Sentinel(哨兵模式,3个sentinel) ...

  • Redis集群部署

    Redis集群部署 Redis集群有多种部署模式,包括主从模式、哨兵模式、集群模式 主从模式   主从模式可以是一...

  • Redis的高可用

    Redis主从复制 什么是主从复制 Redis有三种集群方案,主从复制,哨兵,cluster集群,主从复制是指将一...

  • SpringBoot整合Redis哨兵模式

    SpringBoot整合Redis哨兵模式 主从搭建 点击哨兵搭建 点击 配置 yaml 依赖 连接池

网友评论

      本文标题:redis 主从哨兵生产环境

      本文链接:https://www.haomeiwen.com/subject/eqlnsrtx.html