Redis 主从模式
2017-11-20 17:38
155 查看
系统:Centos6.6x64
安装目录:/usr/local/
主:192.168.100.103
从:192.168.100.104
5,redis 主从配置
6,启动测试:
7,测试:
安装目录:/usr/local/
主:192.168.100.103
从:192.168.100.104
1,下载安装: 安装依赖: # yum install gcc tcl ruby -y # wget http://download.redis.io/releases/redis-3.2.4.tar.gz # tar xf redis-3.2.4.tar.gz # mv redis-3.2.4 /opt/redis # cd /opt/redis # make # make test 2,内核修改配置 echo "vm.overcommit_memory=1" >> /etc/sysctl.conf /sbin/sysctl -p 3,iptables端口开发 selinux关闭设置: # cat /etc/sysconfig/iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 6379 -j ACCEPT 4,创建 数据 日志目录 mkdir -p redis/{log,data}
5,redis 主从配置
主服务:192.168.100.103 # cat redis.conf bind 192.168.100.103 protected-mode yes port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no pidfile /var/run/redis_6379.pid loglevel notice logfile /opt/redis/log/redis.log databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir /opt/redis/data requirepass passwd slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 appendonly no 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 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 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes
从服务:192.168.100.104 # cat redis.conf bind 192.168.100.104 protected-mode yes port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no pidfile /var/run/redis_6379.pid loglevel notice logfile /opt/redis/log/redis.log databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir /opt/redis/data slaveof 192.168.100.103 6379 masterauth passwd slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 appendonly no 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 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 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes
6,启动测试:
# /opt/redis# nohup src/redis-server redis.conf & # ps-ef|grep redis # /usr/local/redis/bin/redis-cli ping
7,测试:
主服务103上执行创建: # /usr/local/redis/bin/redis-cli -h 192.168.100.103 -a passwd set test 123456 从服务104上执行查看: # /usr/local/redis/bin/redis-cli -h 192.168.100.104 get test
性能测试 # /usr/local/redis/bin/redis-benchmark 关闭服务 # /usr/local/redis/bin/redis-cli -p 6379 shutdown 强制刷新数据到磁盘【Redis默认是异步写入磁盘的】 # /usr/local/redis/bin/redis-cli -p 6379 save
相关文章推荐
- redis演练(6) redis主从模式搭建
- redis主从切换---Sentinel(哨兵模式)
- centos6.5 redis主从模式配置
- spring-data-redis连接sentinel主从切换模式
- Redis的主从模式-Redis学习笔记五
- redis的主从模式
- Redis的哨兵模式第一次主从切换成功,再次进行主从切换就不行了,怎么破?
- thinkphp的redis主从分布式的单例模式
- Redis主从复制和哨兵模式
- redis的主从架构的配置和哨兵模式原理和配置
- redis学习三,Redis主从复制和哨兵模式
- Redis集群 - redis主从配置初步:简单主从切换(哨兵模式)
- Redis主从模式
- redis配置主从模式
- redis之key、string、list、set、sort set、hash、精细持久化、snapshotting快照保存、主从模式
- 第五节.Redis的主从模式
- Redis主从复制哨兵模式
- Redis 哨兵模式实现主从故障互切换
- Redis主从复制和哨兵模式
- redis复习(二):高级命令,主从复制,哨兵模式