天天看點

redis 一主二從三哨兵模式搭建

開工大吉!!!

所需環境:3台虛拟機搭建redis,虛拟機資訊分布如下:

hik.redis-01 hik.redis-02 hik.redis-03
192.168.150.128 192.168.150.129 192.168.150.130

分别在三台機器上安裝redis

# 設定redis的安裝源頭
[[email protected] hik]# yum install epel-release

# 線上安裝redis,保證你的虛拟機能連接配接上網際網路
# 
# 此時可能會報錯,報錯内容:
[[email protected]] yum.repos.d]# yum install redis -y

# Loaded plugins: fastestmirror, langpacks


# One of the configured repositories failed (Unknown),
# ...
# ...
#  Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again

# 解決:
[[email protected]] vim /etc/yum.repo.d/epel.repo

# 把baseurl的注釋放開,把metalink注釋掉
# baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
# #metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch

# 啟動redis、啟動redis哨兵
[[email protected]] systemctl start redis
[[email protected]] systemctl start redis-sentinel
# 允許開機啟動
[[email protected]] systemctl enable redis
[[email protected]] systemctl enable redis-sentinel
# 之後進行配置修改:為哨兵叢集,重新開機啟動服務