文章插图
ip192.168.1.111 主
192.168.1.112 从
192.168.1.113 从
安装redis
- 安装依赖
- 下载redis-4.0.11.tar.gz
wget http://download.redis.io/releases/redis-4.0.11.tar.gz
3台均按以下命令安装redis
cd /usr/local
tar -xzvf redis.tar.gz
cd redis
make MALLOC=libc
make
make install
配置redis 主从修改master 192.168.1.111的redis.conf
daemonize yespidfile "/var/run/redis.pid"port 6379tcp-backlog 511 timeout 0 tcp-keepalive 0 loglevel notice logfile "/usr/local/redis/redis.log" databases 16save 900 1 save 300 10 save 60 10000stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename "dump.rdb"dir "/usr/local/redis" slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5repl-disable-tcp-nodelay no slave-priority 100 requirepass "密码"Appendonly yes appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mbaof-load-truncated yeslua-time-limit 5000 slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512hash-max-ziplist-value 64 list-max-ziplist-entries 512list-max-ziplist-value 64 set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yes client-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yesmasterauth "密码" protected-mode yes修改slave 192.168.1.112和192.168.1.113的/usr/local/redis/redis.conf
daemonize yespidfile "/var/run/redis.pid" port 6379tcp-backlog 511timeout 0tcp-keepalive 0loglevel noticelogfile "/usr/local/redis/redis.log"databases 16save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yesrdbcompression yes rdbchecksum yes dbfilename "dump.rdb"dir "/usr/local/redis" 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 requirepass "密码" appendonly yesappendfilename "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 10000slowlog-max-len 128latency-monitor-threshold 0 notify-keyspace-events ""hash-max-ziplist-entries 512 hash-max-ziplist-value 64list-max-ziplist-entries 512list-max-ziplist-value 64 set-max-intset-entries 512 zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10 aof-rewrite-incremental-fsync yes masterauth "密码" protected-mode yes slaveof 192.168.1.111 6379
- 依次启动redis
/usr/local/redis/src/redis-server /usr/local/redis/redis.conf
可以在/usr/local/redis/redis.log 中 看到3台机子连接成功的信息
文章插图
也可以在redis中 添加key 测试是否会同步
在192.168.1.111上执行如下命令
文章插图
在slave机子上执行如下操作,会看到slave 上有和master 一样的key 名,value也一致
文章插图
配置sentinel 哨兵
- 配置主master的/usr/local/redis/sentinel.conf
推荐阅读
- Windows 10 1909全新安装终极指南
- Linux安装JDK 以及 tomcat 和mysql
- Redis从入门到精通
- java服务 tomcat安装,不要太简单
- nginx LNMP环境安装SSL安全证书,全站开启HTTPS访问
- Redis实现注册、删除、编辑、分页功能
- 空调移机安装怎么排空,空调移机安装不排空好不好
- 装门应该在乳胶漆之前还是以后,门是最后安装的吗
- 茶园安装摄像头助力保证有机茶质量
- Redis如何处理客户端连接