阿里云服务器搭建redis主从遇到的坑
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了阿里云服务器搭建redis主从遇到的坑,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2146字,纯文字阅读大概需要4分钟。
内容图文
![阿里云服务器搭建redis主从遇到的坑](/upload/InfoBanner/zyjiaocheng/870/83b8757359c047cf8e50564b97a5da1e.jpg)
如题,在两台服务器之间搭建主从redis:
- 登录阿里云控制台把redis的端口开放。
- 如果是宝塔面板在安全栏目里放行redis的端口。
- 主服务器的redis.conf
bind 127.0.0.1 //注释掉不用 protected-mode no //关闭保护模式
- 从服务器的redis.conf配置同上,redis的主从可以在配置文件中修改,具体位置如下
################################# REPLICATION ################################# # Master-Replica replication. Use replicaof to make a Redis instance a copy of # another Redis server. A few things to understand ASAP about Redis replication. # # +------------------+ +---------------+ # | Master | ---> | Replica | # | (receive writes) | | (exact copy) | # +------------------+ +---------------+ # # 1) Redis replication is asynchronous, but you can configure a master to # stop accepting writes if it appears to be not connected with at least # a given number of replicas. # 2) Redis replicas are able to perform a partial resynchronization with the # master if the replication link is lost for a relatively small amount of # time. You may want to configure the replication backlog size (see the next # sections of this file) with a sensible value depending on your needs. # 3) Replication is automatic and does not need user intervention. After a # network partition replicas automatically try to reconnect to masters # and resynchronize with them. # # replicaof <masterip> <masterport> #在这里写入主服务器的ip 端口 例如 replicaof 192.168.1.103 6379 //如果redis有密码 密码是123456 masterauth 123456 //登录账户 user masteruser user
网上的视频教程里都是同一服务器开三个不同端口的redis,在同一服务器搭建主从没有什么问题,但是当真正在两台服务器之间搭建的时候就会出现问题,输入info replication 会出现master_link_status:down。主服务器查看从服务器的连接数也是0。connected_slaves:0;
另外,我的服务器系统:CentOS 7.6.1810,装的宝塔面板,然后首次安装redis的时候会报错,原因是gcc的版本过低,网上查找原因提示 升级gcc,命令如下
yum -y install centos-release-scl yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils scl enable devtoolset-9 bash echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile gcc -v
内容总结
以上是互联网集市为您收集整理的阿里云服务器搭建redis主从遇到的坑全部内容,希望文章能够帮你解决阿里云服务器搭建redis主从遇到的坑所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。