先说明一下目前使用的链接工具
MobaXterm_专业版
链接地址
在 CentOS 7 环境下实现 Redis 的一主二从三哨兵架构,步骤如下:
- 三台虚拟机的IP分别是
- 192.168.137.129
- 192.168.137.131
- 192.168.137.132
- linux的ip地址查询
- 我的ContOS 7只能使用这个命令
ip addr
- 我的ContOS 7只能使用这个命令
好了 开始整活儿
1. 安装 Redis
首先,在三台服务器上安装 Redis。
1 sudo yum install epel-release 2 sudo yum install redis
2. 配置主 Redis 服务器
编辑主 Redis 服务器的配置文件 /etc/redis.conf
:
sudo vi /etc/redis.conf
修改以下配置:
bind 0.0.0.0 protected-mode no daemonize yes requirepass yourpassword masterauth yourpassword
启动 Redis 服务:
sudo systemctl start redis sudo systemctl enable redis
注意:这个时候可以测试链接一下
Could not connect to Redis at 192.168.137.132:6379: No route to host
这个是解决方案:无法连接/访问 Linux虚拟的中的端口(Redis) - .NetCat - 博客园
3. 配置从 Redis 服务器
在两台从服务器上编辑 /etc/redis.conf
:
sudo vi /etc/redis.conf
修改以下配置:
bind 0.0.0.0 protected-mode no daemonize yes requirepass yourpassword masterauth yourpassword slaveof <master-ip> 6379
启动 Redis 服务:
sudo systemctl start redis sudo systemctl enable redis