zoukankan      html  css  js  c++  java
  • Redis环境搭建--哨兵模式

    Redis环境搭建--主从模式

    搭建redis-sentinel系统

    • 复制配置文件
    cp sentinel.conf configs
    cd configs
    
    # 哨兵不分主从,配置文件除了端口,其余一致
    cp sentinel.conf sentinel27000.conf
    cp sentinel.conf sentinel27001.conf
    cp sentinel.conf sentinel27002.conf
    
    • 节点配置
    protected-mode no
    port 27000
    daemonize yes
    pidfile /var/run/redis-sentinel-27000.pid
    logfile /var/log/redis/sentinel-27000.log
    sentinel monitor mymaster 127.0.0.1 7000 2
    sentinel auth-pass mymaster 123456
    sentinel down-after-milliseconds mymaster 5000
    sentinel failover-timeout mymaster 15000
    
    • 启动
    ../src/redis-sentinel sentinel27000.conf
    ../src/redis-sentinel sentinel27001.conf
    ../src/redis-sentinel sentinel27002.conf
    

    测试

    • 故障转移测试
    # 停掉主节点
    ../src/redis-cli -p 7000 -a 123456
    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    127.0.0.1:7000> SHUTDOWN
    not connected>
    
    # 登录从节点查看集群状态
    ../src/redis-cli -p 7001 -a 123456
    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    127.0.0.1:7001> info replication
    # Replication
    role:master
    connected_slaves:1
    slave0:ip=127.0.0.1,port=7002,state=online,offset=28228,lag=1
    master_replid:420a4b36f142ddb7d4b162cd7662c265a9c63f63
    master_replid2:48e78dadeaff69321566ce0c7c9860557c60b66c
    master_repl_offset:28375
    second_repl_offset:26477
    repl_backlog_active:1
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:1
    repl_backlog_histlen:28375
    127.0.0.1:7001>
    
    ../src/redis-cli -p 7002 -a 123456
    Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
    127.0.0.1:7002> info replication
    # Replication
    role:slave
    master_host:127.0.0.1
    master_port:7001
    master_link_status:up
    master_last_io_seconds_ago:2
    master_sync_in_progress:0
    slave_repl_offset:32393
    slave_priority:100
    slave_read_only:1
    connected_slaves:0
    master_replid:420a4b36f142ddb7d4b162cd7662c265a9c63f63
    master_replid2:48e78dadeaff69321566ce0c7c9860557c60b66c
    master_repl_offset:32393
    second_repl_offset:26477
    repl_backlog_active:1
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:1
    repl_backlog_histlen:32393
    127.0.0.1:7002>
    
    
  • 相关阅读:
    JSP Web第五章整理复习 JSP访问数据库
    JSP Web第四章整理复习 JSP技术基础
    JSP Web第三章整理复习 开发环境搭建
    在n个球中,任意取出m个(不放回),求共有多少种取法
    递归比较字符串是否相等
    数组求和的3种常见递归方法
    打印begin~end
    jQuery简单实现图片预加载
    HTML5语义化标签重构页面
    jQuery插件slick实现响应式移动端幻灯片图片切换特效—大全
  • 原文地址:https://www.cnblogs.com/CSunShine/p/11476973.html
Copyright © 2011-2022 走看看