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

  • 相关阅读:
    如何用互联网的思维开一家有逼格的客栈?
    create和grant配合使用,对Mysql进行创建用户和对用户授权
    Nginx 403 forbidden原因及故障模拟重现(转载)
    企业级缓存系统varnish应用
    实现基于Haproxy+Keepalived负载均衡高可用架构
    企业级监控zabbix基础
    实现基于Keepalived主从高可用集群网站架构
    实现基于LVS负载均衡集群的电商网站架构
    实现基于lnmp的电子商务网站
    CentOS6编译LAMP基于FPM模式的应用wordpress
  • 原文地址:https://www.cnblogs.com/hankyoon/p/15597237.html
Copyright © 2011-2022 走看看