docker+redis+sentinel配置

通過docker-compose安裝。做記錄。

原理網上太多

#sentinel.conf
port 26379
daemonize yes
pidfile /var/run/redis-sentinel.pid
logfile "/usr/local/etc/redis/logs/26379.log"
dir /tmp
sentinel monitor mymaster 10.8.8.212 6379 2
sentinel auth-pass mymaster pwd***
sentinel down-after-milliseconds mymaster 30000
sentinel failover-timeout mymaster 180000
#redins.conf
port 6379
replicaof 10.8.8.212 6379
masterauth pwd***
bind 10.8.8.212 127.0.0.1
protected-mode yes
daemonize no
logfile "/usr/local/etc/redis/logs/6379.log"
requirepass pwd***
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
no-appendfsync-on-rewrite no
appendfsync everysec
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble 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-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
stream-node-max-bytes 4096
stream-node-max-entries 100
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
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
#docker-compose.yml
version: '3'

services:
  master:
    image: redis:5.0.3
    restart: always
    ports:
      - 10.8.8.212:6379:6379
    volumes:
      - ./redis:/usr/local/etc/redis
      - redis-data:/data
    command: redis-server /usr/local/etc/redis/conf/redis-6379.conf
    network_mode: "host"
  slave1:
    image: redis:5.0.3
    restart: always
    ports:
      - 10.8.8.212:6479:6479
    volumes:
      - ./redis:/usr/local/etc/redis
      - slave1-data:/data
    command: redis-server /usr/local/etc/redis/conf/redis-6479.conf
    network_mode: "host"
    #  slave2:
    #    image: redis:5.0.3
    #    restart: always
    #    ports:
    #      - 10.8.8.212:6579:6579
    #    volumes:
    #      - ./redis:/usr/local/etc/redis
    #      - slave2-data:/data
    #    command: redis-server /usr/local/etc/redis/conf/redis-6579.conf
    #    network_mode: "host"
  sentinel:
    image: redis:5.0.3
    restart: always
    ports:
      - 10.8.8.212:26379:26379
    volumes:
      - ./redis:/usr/local/etc/redis
      - sentinel-data:/data
    command: redis-sentinel /usr/local/etc/redis/conf/sentinel-26379.conf
    network_mode: "host"

  sentinel2:
    image: redis:5.0.3
    restart: always
    ports:
      - 10.8.8.212:26479:26479
    volumes:
      - ./redis:/usr/local/etc/redis
      - sentinel-data:/data
    command: redis-sentinel /usr/local/etc/redis/conf/sentinel-26479.conf
    network_mode: "host"

volumes:
  redis-data:
  slave1-data:
  slave2-data:
  sentinel-data:

注意關閉selinux。

 

#查看狀態
sestatus
#臨時關閉
setenforce 0
#永久關閉
/etc/selinux/config,將其中SELINUX設置爲disabled
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章