在linux(Centos7)環境下實現redis的一主二從
先說明一下目前使用的鏈接工具
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
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
浙公網安備 33010602011771號