首页 技术 正文
技术 2022年11月21日
0 收藏 824 点赞 2,768 浏览 5749 个字

网络环境:

主:10.187.120.5从:10.187.69.58从:10.187.69.59


一.安装mv redis-2.8.19.tar.gz /export/servers/cd /export/servers/tar zxf redis-2.8.19.tar.gzcd redis-2.8.19make && make install


二,主从环境搭建  主:10.187.120.5conf/redis_6379.conf(src/redis-server conf/redis_6379.conf)重要参数备注:loglevel notice# 指定日志记录级别# Redis总共支持四个级别:debug、verbose、notice、warning,默认为verbose# debug 记录很多信息,用于开发和测试# varbose 有用的信息,不像debug会记录那么多# notice 普通的verbose,常用于生产环境# warning 只有非常重要或者严重的信息会记录到日志timeout 300# 设置客户端连接时的超时时间,单位为秒。当客户端在这段时间内没有发出任何指令,那么关闭该连接;0是关闭此设置databases 16#可用数据库数rdbcompression yes# 存储至本地数据库时(持久化到rdb文件)是否压缩数据,默认为yesslave-serve-stale-data yes# 当 slaves 和 master 失去联系或者 复制数据工作仍然在进行,yes的时候 slave 会反馈 客户端的请求,no的时候不会slave-read-only yes#yes意味着客户端没法给slave 节点写入数据repl-disable-tcp-nodelay no#在slave和master同步后(发送psync/sync),后续的同步是否设置成TCP_NODELAY。no代表不设置为TCP_NODELAY, redis master会立即发送同步数据,没有延迟;yes会有延迟repl-backlog-size 128mb#设置复制的backlog值,缓冲区的值;当从服务器断开连接之后,主服务器将更新的数据放置在这个缓冲区中,因为当从服务重新连接上来时候不是所有的数据都需要同步,因此从这个缓冲区中取数据就可以同步到和主服务器一样的状态

daemonize yes
pidfile /export/Data/redis_pid/redis_6379.pid
port 6379
# tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile /export/Logs/redis/redis_6379.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
dbfilename 6379.rdb
dir /export/Data/redis_data/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
repl-backlog-size 128mb
maxmemory 2g
appendonly no
appendfilename 6379.aof
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 10000
slowlog-max-len 1024
# 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 512mb 256mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
rename-command keys jkeys

从:10.187.69.58conf/redis_6379.conf(src/redis-server conf/redis_6379.conf)

daemonize yes
slaveof 10.187.120.5 6379
pidfile /export/Data/redis_pid/redis_6379.pid
port 6379
# tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile /export/Logs/redis/redis_6379.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
dbfilename 6379.rdb
dir /export/Data/redis_data/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
repl-backlog-size 128mb
maxmemory 2g
appendonly no
appendfilename 6379.aof
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 10000
slowlog-max-len 1024
# 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 512mb 256mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
rename-command keys jkeys

  从:10.187.69.59conf/redis_6379.conf(src/redis-server conf/redis_6379.conf)

daemonize yes
slaveof 10.187.120.5 6379
pidfile /export/Data/redis_pid/redis_6379.pid
port 6379
# tcp-backlog 511
timeout 300
tcp-keepalive 0
loglevel notice
logfile /export/Logs/redis/redis_6379.log
databases 16
stop-writes-on-bgsave-error yes
rdbcompression yes
dbfilename 6379.rdb
dir /export/Data/redis_data/6379
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
repl-backlog-size 128mb
maxmemory 2g
appendonly no
appendfilename 6379.aof
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 10000
slowlog-max-len 1024
# 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 512mb 256mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
rename-command keys jkeys

三.主备切换

主:10.187.120.5conf/sentinel_26379.conf(src/redis-sentinel conf/sentinel_26379.conf)

port 26379
daemonize yes
sentinel monitor mymaster 10.187.120.5 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 900000
#sentinel can-failover mymaster yes
sentinel config-epoch mymaster 0
# Generated by CONFIG REWRITE
dir "/export/servers/redis-2.8.19"
sentinel leader-epoch mymaster 0
sentinel known-slave mymaster 10.187.69.59 6379
sentinel known-slave mymaster 10.187.69.58 6379
#sentinel known-sentinel mymaster 10.187.69.59 26379 84ac24684dc485bc0c4bcf84a03d7cdb12d32ac9
#sentinel known-sentinel mymaster 10.187.69.58 26379 68da3e5c7d7da1ac1dfb542741bd89181fdda580
sentinel current-epoch 0

从:10.187.69.58sentinel_26379.conf(src/redis-sentinel conf/sentinel_26379.conf)

daemonize yes
port 26379
sentinel monitor mymaster 10.187.120.5 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 900000
#sentinel can-failover mymaster yes
sentinel config-epoch mymaster 0
#Generated by CONFIG REWRITE
dir "/export/servers/redis-2.8.19"
sentinel leader-epoch mymaster 0
sentinel known-slave mymaster 10.187.69.58 6379
# Generated by CONFIG REWRITE
sentinel known-slave mymaster 10.187.69.59 6379
sentinel current-epoch 0

从:10.187.69.59sentinel_26379.conf(src/redis-sentinel conf/sentinel_26379.conf)

daemonize yes
port 26379
sentinel monitor mymaster 10.187.120.5 6379 2
sentinel down-after-milliseconds mymaster 10000
sentinel failover-timeout mymaster 900000
#sentinel can-failover mymaster yes
sentinel config-epoch mymaster 0
#Generated by CONFIG REWRITE
dir "/export/servers/redis-2.8.19"
sentinel leader-epoch mymaster 0
sentinel known-slave mymaster 10.187.69.58 6379
# Generated by CONFIG REWRITE
sentinel known-slave mymaster 10.187.69.58 6379
sentinel known-slave mymaster 10.187.69.59 6379
sentinel current-epoch 0

 

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,076
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,400
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,812
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,894