如何更改redis 哨兵配置文件

1、在linux系统中进入到哨兵配置文件所在目录

vi sentinel.conf

更改具体信息,保存。

2、重启redis

ps -ef |grep redis

查看进程,删除哨兵进程,

kill 15  进程数。    ----15 也可以用9  ,但是15的话,会让redis保存后再停止。

3、更改日志路径

nohup /usr/redis/redis_slave1/redis-server /usr/redis/redis_slave1/conf/sentinel.conf --sentinel > /data/redis/logs/sentinel.log 2>&1 &

4、查看redis是否已经启动,

ps -ef |grep redis

        more /data/redis/logs/sentinel.log 

5、指定访问redis的端口

注意有点:./redis-cli -p 26380

6、查看主从配置是否正确

sentinel slaves master


[root@ipu-mq-2 conf]# pwd
/usr/redis/redis_slave1/conf
[root@ipu-mq-2 conf]# vi sentinel.conf 
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# ps -ef |grep redis
root      8637     1  0  2015 ?        02:42:51 /usr/redis/redis_slave1/redis-server *:26380
root     17124     1  0 11:30 ?        00:00:21 /usr/redis/redis_slave1/redis-server *:6380
root     21446 21282  0 16:45 pts/0    00:00:00 grep --color=auto redis
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# kill 15 8637
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# nohup /usr/redis/redis_slave1/redis-server /usr/redis/redis_slave1/conf/sentinel.conf --sentinel > /data/redis/logs/sentinel.log 2>&1 &
[1] 21457
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# ps -ef |grep redis
root     17124     1  0 11:30 ?        00:00:21 /usr/redis/redis_slave1/redis-server *:6380
root     21457 21282  0 16:46 pts/0    00:00:00 /usr/redis/redis_slave1/redis-server *:26380
root     21463 21282  0 16:46 pts/0    00:00:00 grep --color=auto redis
[root@ipu-mq-2 conf]# more /data/redis/logs/sentinel.log 
nohup: ignoring input
[21457] 27 Jan 16:46:19.256 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.8.19 (00000000/0) 32 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in sentinel mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 26380
 |    `-._   `._    /     _.-'    |     PID: 21457
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               


[21457] 27 Jan 16:46:19.257 # Sentinel runid is 0326cb2fe9992b69511c2e3eb2dfa903320ca383
[21457] 27 Jan 16:46:19.257 # +monitor master mymaster 192.168.14.6 6379 quorum 2
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# vi sentinel.conf 
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# 
[root@ipu-mq-2 conf]# cd ..
[root@ipu-mq-2 redis_slave1]# ./redis-cli -p 26380
127.0.0.1:26380> sentinel slaves master
(error) ERR No such master with that name
127.0.0.1:26380> sentinel slaves mymaster
1)  1) "name"
    2) "192.168.14.7:6381"
    3) "ip"
    4) "192.168.14.7"
    5) "port"
    6) "6381"
    7) "runid"
    8) "3cf45cdba06196016e5a9207910c1058188744f4"
    9) "flags"
   10) "slave"
   11) "pending-commands"
   12) "0"
   13) "last-ping-sent"
   14) "0"
   15) "last-ok-ping-reply"
   16) "364"
   17) "last-ping-reply"
   18) "364"
   19) "down-after-milliseconds"
   20) "30000"
   21) "info-refresh"
   22) "5911"
   23) "role-reported"
   24) "slave"
   25) "role-reported-time"
   26) "66054"
   27) "master-link-down-time"
   28) "0"
   29) "master-link-status"
   30) "ok"
   31) "master-host"
   32) "192.168.14.6"
   33) "master-port"
   34) "6379"
   35) "slave-priority"
   36) "100"
   37) "slave-repl-offset"
   38) "3933898"
2)  1) "name"
    2) "192.168.14.5:6380"
    3) "ip"
    4) "192.168.14.5"
    5) "port"
    6) "6380"
    7) "runid"
    8) "20ebc311249336bd7f3fe3d521400d847ad83187"
    9) "flags"
   10) "slave"
   11) "pending-commands"
   12) "0"
   13) "last-ping-sent"
   14) "0"
   15) "last-ok-ping-reply"
   16) "364"
   17) "last-ping-reply"
   18) "364"
   19) "down-after-milliseconds"
   20) "30000"
   21) "info-refresh"
   22) "5911"
   23) "role-reported"
   24) "slave"
   25) "role-reported-time"
   26) "66054"
   27) "master-link-down-time"
   28) "0"
   29) "master-link-status"
   30) "ok"
   31) "master-host"
   32) "192.168.14.6"
   33) "master-port"
   34) "6379"
   35) "slave-priority"
   36) "100"
   37) "slave-repl-offset"
   38) "3933898"
127.0.0.1:26380> quit
[root@ipu-mq-2 redis_slave1]# 
Connection closed by foreign host.




猜你喜欢

转载自blog.csdn.net/asdasdasd123123123/article/details/50595951