首页 技术 正文
技术 2022年11月18日
0 收藏 446 点赞 2,817 浏览 4133 个字

redis cluster的conf配置文件配置

master配置文件如下:

 bind 127.0.0.1
port
tcp-backlog
timeout
tcp-keepalive
loglevel notice
logfile ""
databases
save
save
save
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay
repl-disable-tcp-nodelay no
slave-priority
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit
slowlog-log-slower-than
slowlog-max-len
latency-monitor-threshold
notify-keyspace-events ""
hash-max-ziplist-entries
hash-max-ziplist-value
list-max-ziplist-size -
list-compress-depth
set-max-intset-entries
zset-max-ziplist-entries
zset-max-ziplist-value
hll-sparse-max-bytes
activerehashing yes
client-output-buffer-limit normal
client-output-buffer-limit slave 256mb 64mb
client-output-buffer-limit pubsub 32mb 8mb
hz
aof-rewrite-incremental-fsync yes

Master配置文件

slave配置文件如下:

 ################################## INCLUDES ###################################
# include .\path\to\local.conf
# include c:\path\to\other.conf
################################## NETWORK #####################################
bind 127.0.0.1
protected-mode yes
port
tcp-backlog
timeout
tcp-keepalive
################################# GENERAL #####################################
loglevel notice
logfile ""
databases
################################ SNAPSHOTTING ################################
save
save
save
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
################################# REPLICATION #################################
slaveof 127.0.0.1
# masterauth <master-password>
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay
repl-ping-slave-period
repl-timeout
repl-disable-tcp-nodelay no
repl-backlog-size 1mb
repl-backlog-ttl
slave-priority
min-slaves-to-write
min-slaves-max-lag
################################## SECURITY ###################################
# rename-command CONFIG ""
################################### LIMITS ####################################
# maxclients
# persistence-available [(yes)|no]
# maxmemory <bytes>
# maxmemory-policy noeviction
# maxmemory-samples
############################## APPEND ONLY MODE ###############################
appendonly no
appendfilename "appendonly.aof"
# appendfsync always
appendfsync everysec
# appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
################################ LUA SCRIPTING ###############################
lua-time-limit
################################ REDIS CLUSTER ###############################
cluster-enabled no
# cluster-config-file nodes-.conf
# cluster-node-timeout
# cluster-slave-validity-factor
# cluster-migration-barrier
# cluster-require-full-coverage yes
################################## SLOW LOG ###################################
slowlog-log-slower-than
################################ LATENCY MONITOR ##############################
latency-monitor-threshold
############################# EVENT NOTIFICATION ##############################
# notify-keyspace-events Elg
# notify-keyspace-events Ex
notify-keyspace-events ""
############################### ADVANCED CONFIG ###############################
hash-max-ziplist-entries
hash-max-ziplist-value
list-max-ziplist-size -
list-compress-depth
set-max-intset-entries
zset-max-ziplist-entries
zset-max-ziplist-value
hll-sparse-max-bytes
activerehashing yes
client-output-buffer-limit normal
client-output-buffer-limit slave 256mb 64mb
client-output-buffer-limit pubsub 32mb 8mb
hz
aof-rewrite-incremental-fsync yes

slave配置文件

结果可以分别进入6379和6380的redis客户端进行查看:命令为 info Replication

redis cluster的conf配置文件配置

redis cluster的conf配置文件配置

如果看到此处的role分别为master 和salve则说明现在已经基本配置成功了

使用哨兵模式,自动监视Master节点,当前挂掉后,自动将Slaver节点变为Master节点       a) sentinel.conf配置文件,修改sentinel monitor host6379 127.0.0.1 6379 1,其它使用默认即可
           host6379 主机名称,随便起    主机IP 端口 1表示选举,某个slaver得到超过1票则成成为Master节点       b) 启动sentinel: ./redis-sentinel ../sentinel.conf 6379 原来的Master节点重启后变成Slaver节点

另附几点声明:

  1. Master可读可写,Slaver只能读,不能写
  2. Master可以对应多个Slaver,但是数量越多压力越大,延迟就可能越严重
  3. Master写入后立即返回,几乎同时将写入异步同步到各个Slaver,所以基本上延迟可以忽略
  4. 可以通过slaveof no one命令将Slaver升级为Master(当Master挂掉时,手动将某个Slaver变为Master)
  5. 可以通过sentinel哨兵模式监控Master,当Master挂掉时自动选举Slaver变为Master,其它Slaver自动重连新的Master
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,105
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,582
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,429
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,836
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,919