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>
    
    
  • 相关阅读:
    android:由URL载入中ImageView
    POI操作Excel详细解释,HSSF和XSSF两种方式
    深入了解jsonp解决跨域访问
    __declspec(novtable)keyword
    八十第五个冠军(复制和匹配的字符串)
    Canvas入门(3):图像处理和渲染文本
    创建位图画刷(CreatePatternBrush)
    MATLAB新手教程
    java io流之int数组数据的插入与取出
    随想录(从apple的swift语言说起)
  • 原文地址:https://www.cnblogs.com/CSunShine/p/11476973.html
Copyright © 2011-2022 走看看