新聞中心
首先對(duì)三臺(tái)機(jī)器進(jìn)行redis的單機(jī)安裝,然后進(jìn)行以下步驟
鶴壁網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,鶴壁網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為鶴壁上千余家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的鶴壁做網(wǎng)站的公司定做!
master 192.168.1.102
slaver 192.168.1.104
slaver 192.168.1.105
修改兩個(gè)slaver的redis.conf配置文件 添加master配置信息
slaveof 192.168.1.102 6379
啟動(dòng)三臺(tái)機(jī)器
sudo ./redis-server redis.conf
然后查看主節(jié)點(diǎn)的信息
./redis-cli -h 192.168.1.102 info Replication
然后再查看從節(jié)點(diǎn)的信息
./redis-cli -h 192.168.1.105 info Replication
此時(shí)驗(yàn)證主從是否同步
在master上連接客戶端插入數(shù)據(jù),看是否在slaver是否存在數(shù)據(jù)
可以看到主從已經(jīng)可以成功同步數(shù)據(jù)
192.168.1.106
配置sentinel
需要將sentinel拷貝過去
cp src/redis-sentinel /usr/redis/
cp sentinel.conf /usr/redis/
修改配置文件sentinel.conf
修改 設(shè)置master地址和端口號(hào)
sentinel monitor mymaster 192.168.1.102 6379 2
保存
然后復(fù)制三份配置文件
sentinel1.conf sentinel2.conf sentinel3.conf
端口號(hào)分別為26379、36379、46379
分別啟動(dòng)三個(gè)進(jìn)程
./redis-sentinel sentinel1.conf
./redis-sentinel sentinel2.conf
./redis-sentinel sentinel3.conf
測(cè)試集群
關(guān)閉192.168.1.102的redis服務(wù)
在192.168.1.106上查看原本為slaver的192.168.1.104的信息
./redis-cli -h 192.168.1.104 info Replication
可以看到192.168.1.104已經(jīng)變成master,slaver是192.168.1.105
再重新連接192.168.1.102
發(fā)現(xiàn)192.168.1.102已經(jīng)變成從節(jié)點(diǎn)
至此整個(gè)集群搭建完成
當(dāng)前題目:Redis主從集群的Sentinel配置
網(wǎng)頁鏈接:http://fisionsoft.com.cn/article/jghoch.html