Redis-3.2.1主从故障测试实例 及出现sdown后没有出现try-failover 或者出现 failover-abort-not-elected 解决方法
2016-08-22 23:52
1206 查看
Redis-3.2.1主从故障测试实例 配置文件如下:
Rdis 实例1配置文件 r1.conf :(默认为master)
port 6379
masterauth mypwd
requirepass mypwd
protected-mode yes
bind 192.168.98.136
Rdis 实例2配置文件 r2.conf :
port 6380
masterauth mypwd
requirepass mypwd
protected-mode yes
bind 192.168.98.136
slaveof 192.168.98.136 6379
Rdis 实例3配置文件 r3.conf :
port 6381
masterauth mypwd
requirepass mypwd
protected-mode yes
bind 192.168.98.136
slaveof 192.168.98136 6379
Rdis sentinel 哨兵1配置文件 s1.conf;
port 26379
sentinel monitor mymaster 192.168.98.136 6379 1
sentinel auth-pass mymaster mypwd
sentinel down-after-milliseconds mymaster 15000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 80000
bind 192.168.98.136
protected-mode yes
Rdis sentinel 哨兵1配置文件 s1.conf;
port 26380
sentinel monitor mymaster 192.168.98.136 6379 1
sentinel auth-pass mymaster mypwd
sentinel down-after-milliseconds mymaster 15000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 80000
bind 192.168.92.136
protected-mode yes
首次依次启动 Rdis实例r1.conf r2.conf r3.conf 和sentienl实例s1.conf s2.conf
然后停掉master r1, 测试宕机后的主从切换如下:
yzj@ubuntu:~$ redis-sentinel s1.conf
9127:X 22 Aug 23:27:50.999 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
9127:X 22 Aug 23:27:50.999 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
9127:X 22 Aug 23:27:50.999 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.1 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in sentinel mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 26379
| `-._ `._ / _.-' | PID: 9127
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
9127:X 22 Aug 23:27:51.000 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
9127:X 22 Aug 23:27:51.003 # Sentinel ID is 26f43074868559a81927040f04d8afd6be4d7d2b
9127:X 22 Aug 23:27:51.003 # +monitor master mymaster 192.168.92.136 6379 quorum 1
9127:X 22 Aug 23:27:51.004 * +slave slave 192.168.98.136:6380 192.168.92.136 6380 @ mymaster 192.168.98.136 6379
9127:X 22 Aug 23:27:51.005 * +slave slave 192.168.98.136:6381 192.168.92.136 6381 @ mymaster 192.168.98.136 6379
9127:X 22 Aug 23:27:59.017 * +sentinel sentinel 73d21ad0584a4ce628c9aa5cc0653eda169b9080 192.168.98.136 26380 @ mymaster 192.168.98.136 6379
9127:X 22 Aug 23:28:18.366 # +new-epoch 1
9127:X 22 Aug 23:28:18.367 # +vote-for-leader 73d21ad0584a4ce628c9aa5cc0653eda169b9080 1
9127:X 22 Aug 23:28:18.417 # +sdown master mymaster 192.168.98.136 6379
9127:X 22 Aug 23:28:18.417 # +odown master mymaster 192.168.98.136 6379 #quorum 1/1
9127:X 22 Aug 23:28:18.417 # Next failover delay: I will not start a failover before Mon Aug 22 23:30:58 2016
9127:X 22 Aug 23:28:19.465 # +config-update-from sentinel 73d21ad0584a4ce628c9aa5cc0653eda169b9080 192.168.98.136 26380 @ mymaster 192.168.98.136 6379
9127:X 22 Aug 23:28:19.465 # +switch-master mymaster 192.168.92.136 6379 192.168.92.136 6381
9127:X 22 Aug 23:28:19.465 * +slave slave 192.168.92.136:6380 192.168.98.136 6380 @ mymaster 192.168.98.136 6381
9127:X 22 Aug 23:28:19.465 * +slave slave 192.168.92.136:6379 192.168.98.136 6379 @ mymaster 192.168.98.136 6381
如果停掉master 后,sentinel 显示足够数量的 sdown 后,没有出现odown或try-failover,则检查密码等配置是否正确
如果停掉master后,试图切换的时候出现 failover-abort-not-elected
1)如果redis实例没有配置
protected-mode yes
bind 192.168.98.136
则在sentinel 配置文件加上
protected-mode no
即可
2)如果redis实例有配置
protected-mode yes
bind 192.168.98.136
则在sentinel 配置文件加上
protected-mode yes
bind 192.168.98.136
即可
Rdis 实例1配置文件 r1.conf :(默认为master)
port 6379
masterauth mypwd
requirepass mypwd
protected-mode yes
bind 192.168.98.136
Rdis 实例2配置文件 r2.conf :
port 6380
masterauth mypwd
requirepass mypwd
protected-mode yes
bind 192.168.98.136
slaveof 192.168.98.136 6379
Rdis 实例3配置文件 r3.conf :
port 6381
masterauth mypwd
requirepass mypwd
protected-mode yes
bind 192.168.98.136
slaveof 192.168.98136 6379
Rdis sentinel 哨兵1配置文件 s1.conf;
port 26379
sentinel monitor mymaster 192.168.98.136 6379 1
sentinel auth-pass mymaster mypwd
sentinel down-after-milliseconds mymaster 15000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 80000
bind 192.168.98.136
protected-mode yes
Rdis sentinel 哨兵1配置文件 s1.conf;
port 26380
sentinel monitor mymaster 192.168.98.136 6379 1
sentinel auth-pass mymaster mypwd
sentinel down-after-milliseconds mymaster 15000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 80000
bind 192.168.92.136
protected-mode yes
首次依次启动 Rdis实例r1.conf r2.conf r3.conf 和sentienl实例s1.conf s2.conf
然后停掉master r1, 测试宕机后的主从切换如下:
yzj@ubuntu:~$ redis-sentinel s1.conf
9127:X 22 Aug 23:27:50.999 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
9127:X 22 Aug 23:27:50.999 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
9127:X 22 Aug 23:27:50.999 # Current maximum open files is 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.2.1 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in sentinel mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 26379
| `-._ `._ / _.-' | PID: 9127
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
9127:X 22 Aug 23:27:51.000 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
9127:X 22 Aug 23:27:51.003 # Sentinel ID is 26f43074868559a81927040f04d8afd6be4d7d2b
9127:X 22 Aug 23:27:51.003 # +monitor master mymaster 192.168.92.136 6379 quorum 1
9127:X 22 Aug 23:27:51.004 * +slave slave 192.168.98.136:6380 192.168.92.136 6380 @ mymaster 192.168.98.136 6379
9127:X 22 Aug 23:27:51.005 * +slave slave 192.168.98.136:6381 192.168.92.136 6381 @ mymaster 192.168.98.136 6379
9127:X 22 Aug 23:27:59.017 * +sentinel sentinel 73d21ad0584a4ce628c9aa5cc0653eda169b9080 192.168.98.136 26380 @ mymaster 192.168.98.136 6379
9127:X 22 Aug 23:28:18.366 # +new-epoch 1
9127:X 22 Aug 23:28:18.367 # +vote-for-leader 73d21ad0584a4ce628c9aa5cc0653eda169b9080 1
9127:X 22 Aug 23:28:18.417 # +sdown master mymaster 192.168.98.136 6379
9127:X 22 Aug 23:28:18.417 # +odown master mymaster 192.168.98.136 6379 #quorum 1/1
9127:X 22 Aug 23:28:18.417 # Next failover delay: I will not start a failover before Mon Aug 22 23:30:58 2016
9127:X 22 Aug 23:28:19.465 # +config-update-from sentinel 73d21ad0584a4ce628c9aa5cc0653eda169b9080 192.168.98.136 26380 @ mymaster 192.168.98.136 6379
9127:X 22 Aug 23:28:19.465 # +switch-master mymaster 192.168.92.136 6379 192.168.92.136 6381
9127:X 22 Aug 23:28:19.465 * +slave slave 192.168.92.136:6380 192.168.98.136 6380 @ mymaster 192.168.98.136 6381
9127:X 22 Aug 23:28:19.465 * +slave slave 192.168.92.136:6379 192.168.98.136 6379 @ mymaster 192.168.98.136 6381
如果停掉master 后,sentinel 显示足够数量的 sdown 后,没有出现odown或try-failover,则检查密码等配置是否正确
如果停掉master后,试图切换的时候出现 failover-abort-not-elected
1)如果redis实例没有配置
protected-mode yes
bind 192.168.98.136
则在sentinel 配置文件加上
protected-mode no
即可
2)如果redis实例有配置
protected-mode yes
bind 192.168.98.136
则在sentinel 配置文件加上
protected-mode yes
bind 192.168.98.136
即可
相关文章推荐
- xcode7.0真机测试出现“Could not find Developer Disk Image"解决方法
- Codeblocks编译C++出现to_string is not a member of std 或者 to_string was not declared in this scope的解决方法
- 关于使用注解出现BeanCreationException或者NameNotFoundException的解决方法
- Qt出现“QSqlDatabase: QMYSQL driver not loaded”和“启动程序失败,路径或者权限错误”解决方法
- C++出现to_string is not a member of std 或者 to_string was not declared in this scope的解决方法
- ubuntu下不能浏览文件或者出现CD/DVD创建者或nautilus崩溃的解决方法
- [转]IE点击链接没有反应或打开新窗口出现一个空白框(地址栏空白)的解决方法
- 数据关系图出现“此数据库没有有效所有者”错误的解决方法
- [转]IE点击链接没有反应或打开新窗口出现一个空白框(地址栏空白)的解决方法
- MYSQL出现" Client does not support authentication "的解决方法
- PHPMyAdmin 出现 没有发现 PHP 的扩展设置mbstring 解决方法
- 关于锚点页内链接跳转出现问题(不响应,没有反应)的解决方法(ZT)
- PHPMyAdmin 出现 没有发现 PHP 的扩展设置mbstring 解决方法
- IIS出现server application error+没有对“C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files”访问权限解决方法
- Win2003下关于c#读写Excel时,出现存取被拒&Excel实例化出错的一个解决方法
- 用OLEDB操作Excel时出现Selected collating sequence not supported by the operating system错误,附解决方法
- Delphi使用BDE连接远程MS SQL SERVER 2000数据库时出现“Db-library network communciations layer not loaded.”错误的解决方法
- 出现"此版本的sql server不支持用户实例登陆标志" 问题的解决方法
- 在访问或者创建 EXCEL 应用程序时出现错误: 的解决方法!
- 在Hiberate事务中,出现抛异常或者其它原因导致没有执行commit或rollback方法时的安全问题