阿里云主从配置后 ubuntu16.04 启动redis报错
现象:Job for redis-server.service failed because a configured resource limit was exceeded.
直接绑定公网ip不能启动redis服务
root@iZbp1ic9ggky8kbqefuyiqZ:~# service redis-server start
Job for redis-server.service failed because a configured resource limit was exceeded. See “systemctl status redis-server.service” and “journalctl -xe” for details.
原因:
腾讯和阿里的公网ip在内网是不可见的
所以redis绑定公网ip是不能启动的
并且绑定公网ip,在slaveof 主服务器公网ip 时 从服务器是不能访问到主服务器的
解决办法:
在阿里或腾讯云里配置安全组规则 将公网ip:6379 与私网ip:6379组成映射关系
主服务器(阿里云)配置:
sudo vi /etc/redis/redis.conf
bind 0.0.0.0
修改配置
可以选择绑定私网ip 或0.0.0.0(本机上的所有IPV4地址)
重启
sudo service redis restart
redis-cli
登陆
从服务器(腾讯云)配置:
修改配置
band 本机内网地址
slaveof 填写主服务器(阿里云)公网ip地址
登陆成功