日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

Centos7 安裝redis主從及配置哨兵模式

 

ip

192.168.1.111 主

192.168.1.112 從

192.168.1.113 從

安裝redis

  • 安裝依賴

yum install gcc gcc-c++ -y

  • 下載redis-4.0.11.tar.gz

cd /usr/local

wget http://download.redis.io/releases/redis-4.0.11.tar.gz

3臺均按以下命令安裝redis

cd /usr/local

tar -xzvf redis.tar.gz

cd redis

make MALLOC=libc

make

make install

配置redis 主從

修改master 192.168.1.111的redis.conf

daemonize yes
pidfile "/var/run/redis.pid"
port 6379
tcp-backlog 511 
timeout 0 tcp-keepalive 0 
loglevel notice 
logfile "/usr/local/redis/redis.log" 
databases 16
save 900 1 
save 300 10 
save 60 10000
stop-writes-on-bgsave-error yes 
rdbcompression yes 
rdbchecksum yes 
dbfilename "dump.rdb"
dir "/usr/local/redis" 
slave-serve-stale-data yes 
slave-read-only yes 
repl-diskless-sync no 
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no 
slave-priority 100 
requirepass "密碼"
Appendonly yes 
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 
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-entries 512
list-max-ziplist-value 64 
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 slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
masterauth "密碼" 
protected-mode yes

修改slave 192.168.1.112和192.168.1.113的/usr/local/redis/redis.conf

daemonize yes
pidfile "/var/run/redis.pid" 
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile "/usr/local/redis/redis.log"
databases 16
save 900 1 
save 300 10 
save 60 10000 
stop-writes-on-bgsave-error yes
rdbcompression yes 
rdbchecksum yes 
dbfilename "dump.rdb"
dir "/usr/local/redis" 
slave-serve-stale-data yes 
slave-read-only yes 
repl-diskless-sync no 
repl-diskless-sync-delay 5 
repl-disable-tcp-nodelay no 
slave-priority 100 
requirepass "密碼" 
appendonly yes
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 
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-entries 512
list-max-ziplist-value 64 
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 slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10 
aof-rewrite-incremental-fsync yes 
masterauth "密碼" 
protected-mode yes 
slaveof 192.168.1.111 6379
  • 依次啟動redis

率先啟動master redis 然后依次啟動slave

/usr/local/redis/src/redis-server /usr/local/redis/redis.conf

可以在/usr/local/redis/redis.log 中 看到3臺機子連接成功的信息

Centos7 安裝redis主從及配置哨兵模式

 

也可以在redis中 添加key 測試是否會同步

在192.168.1.111上執行如下命令

Centos7 安裝redis主從及配置哨兵模式

 

在slave機子上執行如下操作,會看到slave 上有和master 一樣的key 名,value也一致

Centos7 安裝redis主從及配置哨兵模式

 

配置sentinel 哨兵

  • 配置主master的/usr/local/redis/sentinel.conf
protected-mode no
sentinel deny-scripts-reconfig yes
sentinel monitor mymaster 192.168.1.111 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 15000
sentinel auth-pass mymaster 密碼
 # Generated by CONFIG REWRITE 
port 26379 
dir "/usr/local/redis"
sentinel config-epoch mymaster 1
sentinel leader-epoch mymaster 1
sentinel known-slave mymaster 192.168.1.112 6379
sentinel known-slave mymaster 192.168.1.113 6379
sentinel current-epoch 1
sentinel announce-ip "192.168.1.111"
protected-mode no 
sentinel myid 3750d9547cf4e99c142984032492d43908ed8790
sentinel deny-scripts-reconfig yes
sentinel monitor mymaster 192.168.1.111 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 15000
sentinel auth-pass mymaster 密碼
# Generated by CONFIG REWRITE
port 26379
dir "/usr/local/redis" 
sentinel config-epoch mymaster 1 
sentinel leader-epoch mymaster 1
sentinel known-slave mymaster 192.168.1.112 6379
sentinel known-slave mymaster 192.168.1.113 6379
sentinel current-epoch 1
sentinel announce-ip "192.168.1.111"
  • 完成配置之后 依次啟動哨兵sentinel

首先啟動master 然后slave

/usr/local/redis/src/redis-sentinel /usr/local/redis/sentinel.conf &

啟動完畢后可以用如下命令查看哨兵信息

**redis-cli -p 26379 INFO Sentinel **

Centos7 安裝redis主從及配置哨兵模式

 

  • 測試殺死master redis 進程
Centos7 安裝redis主從及配置哨兵模式

 

查看日志 master 重新選舉192.168.1.112為新master

Centos7 安裝redis主從及配置哨兵模式

 

再次查看哨兵信息 master 已經變化

Centos7 安裝redis主從及配置哨兵模式

 

重新啟動192.168.1.111的redis 查看信息

至此 redis集群和哨兵均安裝完畢

分享到:
標簽:redis
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定