zoukankan      html  css  js  c++  java
  • 部署redis sentinel

    部署redis sentinel,节点信息:

    172.17.9.131
    172.17.9.133
    172.17.9.136

    redis配置文件redis_6379.conf

    [root@host redis6379]# cat redis_6379.conf   (redis cluster配置文件,禁用cluster)
    bind 0.0.0.0
    protected-mode no
    port 6379
    tcp-backlog 511
    timeout 0
    tcp-keepalive 300
    daemonize yes
    supervised no
    pidfile "/data/redis6379/redis6379.pid"
    loglevel warning
    logfile "/data/redis6379/redis6379.log"
    masterauth "hankyoon"
    requirepass "hankyoon"
    databases 16
    
    stop-writes-on-bgsave-error yes
    rdbcompression yes
    rdbchecksum yes
    dbfilename "redis6379.rdb"
    dir "/data/redis6379"
    replica-serve-stale-data yes
    replica-read-only yes
    repl-diskless-sync no
    repl-diskless-sync-delay 5
    repl-disable-tcp-nodelay no
    replica-priority 100
    min-replicas-to-write 0
    min-replicas-max-lag 10
    maxmemory 6gb
    maxmemory-policy volatile-lru
    appendonly no
    appendfilename "appendonly.aof"
    appendfsync everysec
    no-appendfsync-on-rewrite no
    auto-aof-rewrite-percentage 100
    auto-aof-rewrite-min-size 64mb
    aof-load-truncated yes
    lua-time-limit 5000
    #cluster-enabled yes
    #cluster-config-file "nodes6379.conf"
    #cluster-node-timeout 15000
    slowlog-log-slower-than 10000
    slowlog-max-len 128
    latency-monitor-threshold 0
    notify-keyspace-events ""
    hash-max-ziplist-entries 512
    hash-max-ziplist-value 64
    list-max-ziplist-size -2
    list-compress-depth 0
    set-max-intset-entries 512
    zset-max-ziplist-entries 128
    zset-max-ziplist-value 64
    hll-sparse-max-bytes 3000
    activerehashing yes
    client-output-buffer-limit normal 0 0 0
    client-output-buffer-limit replica 0 0 0
    client-output-buffer-limit pubsub 32mb 8mb 60
    hz 10
    aof-rewrite-incremental-fsync yes
    # Generated by CONFIG REWRITE
    #cluster-require-full-coverage no
    repl-timeout 600
    #cluster-migration-barrier 0

    启动三个单节点redis:

    [root@host 172.17.9.131]# /usr/local/bin/redis-server /data/redis6379/redis_6379.conf
    
    [root@host 172.17.9.133]# /usr/local/bin/redis-server /data/redis6379/redis_6379.conf
    
    [root@host 172.17.9.136]# /usr/local/bin/redis-server /data/redis6379/redis_6379.conf

    哨兵配置文件sentinel.conf

    port 26379
    daemonize yes
    pidfile /data/redis6379/sentinel_26379.pid
    logfile "/data/redis6379/sentinel_6379.log"
    dir /data/redis6379
    sentinel monitor mymaster 172.17.9.131 6379 2
    sentinel down-after-milliseconds mymaster 30000
    sentinel parallel-syncs mymaster 1
    sentinel failover-timeout mymaster 180000
    sentinel deny-scripts-reconfig yes
    sentinel auth-pass mymaster hankyoon
    #sentinel monitor mymaster 192.168.1.xxx 6379 1   #监控 人员组名/ip/端口/失效判定数(多少从端判断不同则认为master断开)  
    #sentinel down-after-milliseconds mymaster 10000  #ping 超过 10000 毫秒则认为宕机  
    #sentinel failover-timeout mymaster 900000        #主从切换超过 30000 毫秒则认为失败  
    #sentinel can-failover mymaster yes               #master断开后是否允许判断进行故障转移  
    #sentinel parallel-syncs mymaster 1               #从端继续同步新master的数量 

    启动哨兵监听:

    [root@host 172.17.9.131]# /usr/local/bin/redis-sentinel /data/redis/sentinel_6379.conf
    
    [root@host 172.17.9.133]# /usr/local/bin/redis-sentinel /data/redis/sentinel_6379.conf
    
    [root@host 172.17.9.136]# /usr/local/bin/redis-sentinel /data/redis/sentinel_6379.conf

    redis sentinel 相关命令:

    [root@host 172.17.9.131]# redis-cli -h 127.0.0.1 -p 26379 -a "hankyoon"
    127.0.0.1:26379> SENTINEL masters             #列出所有master状态信息
    
    127.0.0.1:26379> SENTINEL master mymaster      #列出某个master状态信息
    
    127.0.0.1:26379> SENTINEL slaves mymaster      #列出某个master的所有slave和状态信息
    
    127.0.0.1:26379> SENTINEL sentinels mymaster   #列出某个master的sentinels 
    
    127.0.0.1:26379> SENTINEL get-master-addr-by-name mymaster #通过某个master获取其IP及port 
    
    127.0.0.1:26379> SENTINEL ckquorum mymaster    #检查某个master是达到投票及故障转移条件
    
    127.0.0.1:26379> SENTINEL flushconfig            #强制重写 SENTINEL 配置到磁盘文件中
      
    127.0.0.1:26379> SENTINEL failover mymaster    #这个操作就注意了!强制进行故障转移!慎操作!

    程序配置redis sentinel 端口为:26379

  • 相关阅读:
    安装torchtext
    RuntimeError: CUDA error: invalid device ordinal
    mongodb aggregate $unwind
    pytorch安装与入门(二)--tensor的基本操作
    pytorch安装与入门(一)
    iOS开发小技巧--iOS程序进入后台运行的实现
    iOS开发小技巧--计算label的Size的方法总结
    iOS开发小技巧--纯代码自定义cell
    iOS开发小技巧--iOS中设置applicationIconBadgeNumber遇到的问题
    iOS开发中的错误整理,Changing the delegate of a tab bar managed by a tab bar controller is not allowed
  • 原文地址:https://www.cnblogs.com/hankyoon/p/15597237.html
Copyright © 2011-2022 走看看