1:由于服务器优先,只能在同一台服务器搭建2个Redis,2个Redis Sentinel,实现Redis的集群
2:Linux上下载Redis,并安装和配置
下载执行一下命令:
$ wget http://download.redis.io/releases/redis-6.0.10.tar.gz
解压下载的Redis:
$ tar xzf redis-6.0.10.tar.gz
进入解压的文件,并进行编译:
$ cd redis-6.0.10
$ make
好像不需要安装了,那就不执行按照的命令了
3:修改Redis的配置文件
主配置修改的涉及到内容:
bind 127.0.0.1 -::1
protected-mode yes
daemonize yes
port 6380
appendonly yes
pidfile "/var/run/redis_6380.pid"
logfile "/var/log/redis_6380.log"
dir "/var/lib/redis_6380"
save 60 1
从库的设置:
bind 127.0.0.1 -::1
protected-mode yes
daemonize yes
port 6381
appendonly yes
pidfile "/var/run/redis_6381.pid"
logfile "/var/log/redis_6381.log"
dir "/var/lib/redis_6381"
save 60 1
replicaof 127.0.0.1 6380
4:然后启动Redis
主的,redis-6380 目录下 ./src/redis-server redis_6380.conf
从的,redis-6381 目录下 ./src/redis-server redis_6381.conf
5:搭建配置Redis sentinel
搭建主的配置 :
主要的配置:
port 26380
daemonize yes
pidfile "/var/run/redis-sentinel.pid"
logfile "/usr/local/soft/redis-6380/tmp/26380.log"
loglevel debug
dir "/usr/local/soft/redis-6380/tmp"
sentinel monitor mymaster_26380 127.0.0.1 6381 2
默认的配置
acllog-max-len 128
sentinel down-after-milliseconds mymaster_26380 5000
sentinel failover-timeout mymaster_26380 15000
sentinel parallel-syncs mymaster_26380 4
sentinel deny-scripts-reconfig yes
sentinel resolve-hostnames no
sentinel announce-hostnames no
搭建从的配置 :
主要的配置:
port 26381
daemonize yes
pidfile "/var/run/redis-sentinel.pid"
logfile "/usr/local/soft/redis-6381/tmp/26381.log"
loglevel debug
dir "/usr/local/soft/redis-6381/tmp"
sentinel monitor mymaster_26380 127.0.0.1 6381 2
默认的配置
acllog-max-len 128
sentinel down-after-milliseconds mymaster_26380 5000
sentinel failover-timeout mymaster_26380 15000
sentinel parallel-syncs mymaster_26380 4
sentinel deny-scripts-reconfig yes
sentinel resolve-hostnames no
sentinel announce-hostnames no
6:启动Redis sentinel
主的,redis-6380 目录下 ./src/redis-sentinel sentinel.conf
从的,redis-6381 目录下 ./src/redis-sentinel sentinel.conf
7:下载配置的Redis截图
8:剩余Redis默认的配置
tcp-backlog 511
timeout 0
tcp-keepalive 300
loglevel notice
databases 16
always-show-logo no
set-proc-title yes
proc-title-template "{title} {listen-addr} {server-mode}"
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename "dump.rdb"
rdb-del-sync-files no
replica-serve-stale-data yes
replica-read-only yes
fast (large bandwidth) networks, diskless replication
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
lazyfree-lazy-user-flush no
oom-score-adj no
oom-score-adj-values 0 200 800
disable-thp 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
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 4kb
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
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes