redis的哨兵模式

redis主机:10.21.20.131
主端口:6379
从端口:6380
部署过程:
1. root用户安装gcc、gcc-c++
yum install -y gcc gcc-c++
2. tar -xvf redis-3.2.12.tar
mv redis-3.2.12 redis
cd redis
make PREFIX=${HOME}/redis MALLOC=libc install

         3.  cd ~/redis
              mkdir -p conf data/node-6379 data/node-6380
             cp redis.conf conf/node-6379.conf
            配置文件如下部分需要修改:
            bind 0.0.0.0
            dir /home/redis/redis/data/node-6379/ 
            port 6379  
            #masterauth "123456"
            #requirepass "123456"
            pidfile /home/redis/redis/conf/node_6379.pid
        4. 启动redis
            ./redis-server ../conf/node-6379.conf
            ./redis-server ../conf/node-6380.conf
        5. 登录从库
            ./redis-cli -p 6380
             slaveof 10.21.20.131 6379

哨兵主机:10.21.20.132
端口1:16379
端口2:16380
部署过程:
1. 安装reids,同上
2. 哨兵配置文件
#sentinel端口
port 16379
#工作路径
dir "/home/redis/redis/sentinel1"
#守护进程模式
daemonize yes
protected-mode no

指明日志文件名

                logfile "/home/redis/redis/sentinel1/log/sentinel.log"
            3. 启动哨兵
                ./redis-sentinel ../conf/sentinel_1.conf
                ./redis-sentinel ../conf/sentinel_2.conf
            4. 分别登录两个哨兵执行如下命令
                ./redis-cli -p 16379
               sentinel monitor mymaster 10.21.20.131 6379 2
               sentinel set mymaster down-after-milliseconds 5000
               sentinel set mymaster failover-timeout 15000
            5. sentinel monitor mymaster 10.21.20.131 6379 2 //参数2代表两个哨兵同时认为master不可用时将会主从切换 ??

你可能感兴趣的:(redis的哨兵模式)