Redis-部署主从
时间:2020-05-10 16:17:46
收藏:0
阅读:43
环境
系统 | IP | 软件 | 备注 |
---|---|---|---|
centos7 | 192.168.153.130 | redis5.0.8 | 主 |
centos7 | 192.168.153.131 | redis5.0.8 | 从 |
源码编译安装
]# wget http://download.redis.io/releases/redis-5.0.8.tar.gz
]# tar xf redis-5.0.8.tar.gz;cd redis-5.0.8
]# make && make install # make install 是为了能够在/usr/local/bin目录下产生redis-server/cli等文件
主服务器配置文件修改
]# vim /opt/program/redis-5.0.8/redis.conf
...
bind 192.168.153.130 127.0.0.1 #绑定本地网卡
daemonize yes #可以后台运行
port 6379
pidfile /var/run/redis_6379.pid
logfile "/opt/program/redis-5.0.8/redis_6379.log"
]# redis-server /opt/program/redis-5.0.8/redis.conf #启动redis-server
从服务器配置文件修改
]# vim /opt/program/redis-5.0.8/redis.conf
bind 192.168.153.131 127.0.0.1 #
daemonize yes #可以后台运行
port 6379
pidfile /var/run/redis_6379.pid
logfile "/opt/program/redis-5.0.8/redis_6379.log"
replicaof 192.168.153.130 6379
]# redis-server /opt/program/redis-5.0.8/redis.conf #启动redis-server
注意点
- bind
- 只是为了设置接口地址,能够让其他机器通过接口地址访问
- 想要限制其他ip访问需要设置防火墙或者protected-mode
- protected-mode 保护模式是否开启
- ‘yes‘生效条件,缺一不可
]# vim redis.conf
bind 192.168.153.130 127.0.0.1
protected-mode yes
requirepass pass123
- 若设置保护模式,从服务器也需要更改配置文件
]# vim redis.conf
replicaof 192.168.153.130 6379
masterauth pass123 #增加此项
原文:https://www.cnblogs.com/wanwz/p/12794772.html
评论(0)