首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

redis 主从同步配备方案

2013-01-06 
redis 主从同步配置方案今天研究了redis主从同步部分的配置,在这里留个备忘!闲话少续,上配置!这是redis-ma

redis 主从同步配置方案
今天研究了redis主从同步部分的配置,在这里留个备忘!

闲话少续,上配置!
这是redis-master.conf

daemonize yespidfile /var/run/redis-master.pidport 6379timeout 0loglevel verboselogfile stdoutdatabases 16save 60 100rdbcompression yesdbfilename dump-master.rdbdir /usr/local/redis/dataslave-serve-stale-data yesrequirepass ooxxooappendonly no appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbslowlog-log-slower-than 10000slowlog-max-len 128maxclients 128maxmemory 1gbvm-enabled novm-swap-file /tmp/redis.swapvm-max-memory 0vm-page-size 32vm-pages 134217728vm-max-threads 4hash-max-zipmap-entries 512hash-max-zipmap-value 64list-max-ziplist-entries 512list-max-ziplist-value 64set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64activerehashing yes


这是redis-slave.conf
daemonize nopidfile /var/run/redis-slave.pidport 7379timeout 0loglevel verboselogfile stdoutdatabases 16save 60 100rdbcompression yesdbfilename dump-slave.rdbdir /usr/local/redis/dataslave-serve-stale-data yesslaveof 127.0.0.1 6379masterauth ooxxooappendonly noappendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbslowlog-log-slower-than 10000slowlog-max-len 128maxclients 128maxmemory 1gbvm-enabled novm-swap-file /tmp/redis.swapvm-max-memory 0vm-page-size 32vm-pages 134217728vm-max-threads 4hash-max-zipmap-entries 512hash-max-zipmap-value 64list-max-ziplist-entries 512list-max-ziplist-value 64set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64activerehashing yes


主要有几点需要注意:
1、 memory设置问题
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.


需要执行脚本
# echo vm.overcommit_memory=1 >> /etc/sysctl.conf# sysctl vm.overcommit_memory=1


2、要保证主配置中  slave-serve-stale-data yes
3、slaveof 127.0.0.1 6379
masterauth ooxxoo


密码一定要设置正确哦!

另外:由于redis rdb模式下会有部分数据处于未落地状态,停redis前最好执行
/usr/local/redis/redis-cli -h 127.0.0.1 -p 6379 -a pwd bgsave 保存下数据,然后再停止redis线程

热点排行