redis哨兵模式离线安装

redis哨兵模式离线安装

  • 准备三台服务器

  • 新建redis用户

  • 检查redis依赖

    1. 通过gcc -v查看是否安装gcc

    2. 如果没有安装gcc通过rpm先安装gcc依赖(Root用户)(建议本地搭建原镜像的文件yum源通过rpm包安装可能导致服务器崩溃)

    3. 具体依赖通过对应镜像iso包中的package找到以下rpm包

      在这里插入图片描述

    4. rpm命令 rpm -Uvh *.rpm --nodeps --force

    5. 再次检查

      使用内建 specs。
      COLLECT_GCC=gcc
      COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
      目标:x86_64-redhat-linux
      配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
      线程模型:posix
      gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
      
  • 安装redis服务

    1. 下载安装redis
    2. 上传至服务器并解压
      1. 进入redis目录并执行makemake install PREFIX=/data/redis
    3. /data/redis新建文件夹sentry和文件startAll.sh
    4. 在sentry下新建文件夹logs dump redis-sentinel redis-server tmp pid
  • 修改配置文件

    1. redis-server 下面新建redis.conf (三台机器配置一样,主节点不要配置slaveof

      daemonize yes
      pidfile "/data/redis/sentry/pid/redis-server-6379.pid"
      port 6379
      bind 0.0.0.0
      timeout 300
      tcp-keepalive 60
      loglevel verbose
      logfile "/data/redis/sentry/logs/redis-server_6379.log"
      databases 16
      save 900 100000
      save 300 10000000
      save 60 1000000
      stop-writes-on-bgsave-error yes
      rdbcompression yes
      rdbchecksum yes
      dbfilename "dump_6379.rdb"
      dir "/data/redis/sentry/dump"
      repl-disable-tcp-nodelay no
      appendonly no
      appendfsync everysec
      no-appendfsync-on-rewrite no
      auto-aof-rewrite-percentage 100
      auto-aof-rewrite-min-size 64mb
      lua-time-limit 5000
      slowlog-log-slower-than 500
      slowlog-max-len 1000
      notify-keyspace-events ""
      hash-max-ziplist-entries 512
      hash-max-ziplist-value 64
      list-max-ziplist-entries 512
      list-max-ziplist-value 64
      set-max-intset-entries 512
      zset-max-ziplist-entries 128
      zset-max-ziplist-value 64
      activerehashing yes
      client-output-buffer-limit normal 0 0 0
      client-output-buffer-limit replica 256mb 64mb 60
      client-output-buffer-limit pubsub 32mb 8mb 60
      hz 10
      protected-mode no
      aof-rewrite-incremental-fsync yes
      cluster-enabled no
      #从库配置(主节点ip端口)
      slaveof ip 端口
      requirepass "xxx"
      masterauth "xxxx"
      maxmemory 4gb
      
    2. redis-sentinel下新建sentinel.conf(三台机器配置一样)

      daemonize yes
      bind 0.0.0.0
      port 26380
      dir "/data/redis/sentry/tmp"
      logfile "/data/redis/sentry/logs/redis-sentinel-26380.log"
      protected-mode no
      sentinel deny-scripts-reconfig yes
      #主节点ip端口 2代表有两个哨兵认为主节点挂了才切换
      sentinel monitor smcs xxx.xxx.xxx.xxx 6379 2
      sentinel down-after-milliseconds smcs 3000
      # 如果在该时间(ms)内未能完成failover操作,则认为该failover失败
      sentinel failover-timeout smcs 3000
      sentinel auth-pass smcs smcs@123
      pidfile "/data/redis/sentry/pid/redis-server-6379.pid"
      
  • 启动服务

    ./bin/redis-server /data/redis/sentry/redis-sentinel/sentinel.conf --sentinel
    ./bin/redis-server /data/redis/sentry/redis-server/redis.conf
    
  • 连接服务查看信息

    127.0.0.1:6379> info replication
    # Replication
    role:master
    connected_slaves:2
    slave0:ip=xxx.xx.xxx.xxx,port=6379,state=online,offset=203638,lag=0
    slave1:ip=xxx.xx.xxx.xxx,port=6379,state=online,offset=203638,lag=0
    master_replid:27472df1f404448bad0d2cbbf045ee12af1aed0f
    master_replid2:ee007a63faaa1ecefce94770535d2cb51125abd5
    master_repl_offset:203777
    second_repl_offset:8170
    repl_backlog_active:1
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:1
    repl_backlog_histlen:203777
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值