6 redis 编译失败_Centos7.8环境搭建Redis主从复制和哨兵模式
生活随笔
收集整理的這篇文章主要介紹了
6 redis 编译失败_Centos7.8环境搭建Redis主从复制和哨兵模式
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
本節我們搭建Redis主從復制和哨兵模式集群,集群的好處是把數據分散不不同的服務器上,解決網站中的很多高并發,高負載等問題,很好的提高網站的性能,也能解決mysql的數據讀寫問題,所以我們搭建集群非常有必要,而且在大網站中都是必須上的技能-簡稱“緩存必殺技”。
下面我們開始做好準備工作:
一、環境和版本
準備三臺Linux服務器centos7系統(本地虛擬機-土豪可以買云上服務器)
192.168.1.101192.168.1.102192.168.1.103Redis:redis-6.0.3(最新版本)二、Redis安裝與啟動(大家按步執行 )
1、下載redis(官方安裝方法)
[root@localhost local]# cd /usr/local/src[root@localhost src]# wget http://download.redis.io/releases/redis-6.0.3.tar.gz2、安裝解壓編譯安裝
[root@localhost src]# tar xzf redis-6.0.3.tar.gz
[root@localhost src]# cd redis-6.0.3
[root@localhost redis-6.0.3]# make
3、錯誤解決(出現以下錯誤)
a、執行:yum -y install gcc-c++yum -y install gcc-c++
b、清除編譯文件:make clean
make cleanc、然后執行:make
maked、如果還報這個錯誤,刪除redis文件夾,重新解壓。
e、命令:
rm -rf redis-6.0.3cd redis-6.0.3make CFLAGS="-march=x86-64" #執行這個命令才行,不然也是安裝失敗,如果你們直接make可以編譯完成就無需執行這個命令。4、啟動服務
[root@localhost redis-6.0.3]# cd src[root@localhost src]# redis-server redis.conf5、配置進程啟動,修改/usr/local/src/redis.conf
daemonize yes6、進程查看關閉
[root@localhost redis-6.0.3]# ./src/redis-server redis.conf[root@localhost redis-6.0.3]# ps -aux | grep redis[root@localhost redis-6.0.3]# kill -9 840
三、配置開機啟動
1、相關配置
[root@localhost init.d]# cd /etc[root@localhost etc]# mkdir redis[root@localhost etc]# cp /usr/local/src/redis-6.0.3/redis.conf /etc/redis/6379.conf[root@localhost etc]# cd redis/[root@localhost redis]# cp /usr/local/src/redis-6.0.3 /utils/redis_init_script /etc/init.d/redisd[root@localhost redis]# chkconfig redisd on #開機啟動命令2、服務啟動關閉
[root@localhost redis]# service redisd start #開啟[root@localhost redis]# service redisd stop #關閉3、重啟虛擬機查看Redis狀態
[root@localhost ~]# ps -aux | grep redisroot 21907 0.0 0.4 145256 4504 pts/0 Sl+ 15:51 0:00 redis-server *:6379root 21980 0.0 0.0 110228 888 pts/1 R+ 15:55 0:00 grep --color redis四、解決客戶端連接問題
關閉防火墻,或者開放6379端口
firewalld的基本使用啟動:systemctl start firewalld關閉:systemctl stop firewalld查看狀態:systemctl status firewalld開機禁用 :systemctl disable firewalld開機啟用 :systemctl enable firewalld修改redis.conf 配置
注釋掉:# bind 127.0.0.1修改保護模式:protected-mode no備注:以上配置只演示了一臺服務器安裝redis,其他2臺按同樣方法進行安裝,先把redis服務安裝完成,再進入以下哨兵模式配置。
五、sentinel哨兵模式
1、基礎配置
192.168.1.101 主服務192.168.1.102 從服務192.168.1.103 從服務2、配置主服務 redis.conf
requirepass 123456masterauth 1234563、配置從服務 redis.conf
requirepass 123456slaveof 192.168.1.101 6379masterauth 1234564、配置sentinel.conf
protected-mode no# sentinel monitor代表監控# mymaster代表服務器的名稱,可以自定義(不可重復即可),# 192.168.1.101 代表監控的主服務器,6379代表端口,# 2 標識 >=2 哨兵認為主服務器不可用,執行failover操作。sentinel monitor mymaster 192.168.1.101 6379 2sentinel auth-pass mymaster 1234565、啟動服務(先主服務,后從服務)
[root@localhost src]#./redis-server ../redis.conf[root@localhost src]#./redis-server ../sentinel.conf --sentinel好了,主從復制集群搭建完畢!更多內容請關注公眾號(Laravel技術社區)
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的6 redis 编译失败_Centos7.8环境搭建Redis主从复制和哨兵模式的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第二季度 QQ 平台生态治理公告:处置违
- 下一篇: 长城汽车王远力:生态环境部已对比亚迪秦