Redis Cluster 原生搭建(一)啟動節(jié)點(diǎn)

創(chuàng)建 6 個(gè)節(jié)點(diǎn)的配置文件

[root@redis3_0_7 config]# cd /opt/soft/redis/config
[root@redis3_0_7 config]# vi redis-7000.conf
port 7000
daemonize yes
dir "/opt/soft/redis/data"
logfile "7000.log"
dbfilename "dump-7000.rdb"
cluster-enabled yes
cluster-config-file nodes-7000.conf
cluster-require-full-coverage no

[root@redis3_0_7 config]# sed "s/7000/7001/g" redis-7000.conf > redis-7001.conf
[root@redis3_0_7 config]# sed "s/7000/7002/g" redis-7000.conf > redis-7002.conf
[root@redis3_0_7 config]# sed "s/7000/7003/g" redis-7000.conf > redis-7003.conf
[root@redis3_0_7 config]# sed "s/7000/7004/g" redis-7000.conf > redis-7004.conf
[root@redis3_0_7 config]# sed "s/7000/7005/g" redis-7000.conf > redis-7005.conf

啟動 6 個(gè)節(jié)點(diǎn)

[root@redis3_0_7 config]# redis-server redis-7000.conf 
[root@redis3_0_7 config]# redis-server redis-7001.conf 
[root@redis3_0_7 config]# redis-server redis-7002.conf 
[root@redis3_0_7 config]# redis-server redis-7003.conf 
[root@redis3_0_7 config]# redis-server redis-7004.conf 
[root@redis3_0_7 config]# redis-server redis-7005.conf 
[root@redis3_0_7 config]# ps -ef|grep redis
root         71      1  0 11:09 ?        00:00:00 redis-server *:7000 [cluster]
root         75      1  0 11:09 ?        00:00:00 redis-server *:7001 [cluster]
root         79      1  0 11:09 ?        00:00:00 redis-server *:7002 [cluster]
root         83      1  0 11:09 ?        00:00:00 redis-server *:7003 [cluster]
root         87      1  0 11:09 ?        00:00:00 redis-server *:7004 [cluster]
root         91      1  0 11:09 ?        00:00:00 redis-server *:7005 [cluster]
root         95      8  0 11:09 pts/1    00:00:00 grep --color=auto redis

嘗試向一個(gè)節(jié)點(diǎn)寫數(shù)據(jù)

  • 失敗,在集群模式下,16384 個(gè)槽都進(jìn)行了分配,集群才是可用的;
[root@redis3_0_7 config]# redis-cli -p 7000 
127.0.0.1:7000> set hello world
(error) CLUSTERDOWN The cluster is down

查看 data 目錄下生成的文件

[root@redis3_0_7 data]# ll /opt/soft/redis/data/
total 52
-rw-r--r-- 1 root root 2036 May 14 17:00 6382.log
-rw-r--r-- 1 root root 1951 May 18 11:09 7000.log
-rw-r--r-- 1 root root 1951 May 18 11:09 7001.log
-rw-r--r-- 1 root root 1951 May 18 11:09 7002.log
-rw-r--r-- 1 root root 1951 May 18 11:09 7003.log
-rw-r--r-- 1 root root 1951 May 18 11:09 7004.log
-rw-r--r-- 1 root root 1951 May 18 11:09 7005.log
-rw-r--r-- 1 root root  112 May 18 11:09 nodes-7000.conf
-rw-r--r-- 1 root root  112 May 18 11:09 nodes-7001.conf
-rw-r--r-- 1 root root  112 May 18 11:09 nodes-7002.conf
-rw-r--r-- 1 root root  112 May 18 11:09 nodes-7003.conf
-rw-r--r-- 1 root root  112 May 18 11:09 nodes-7004.conf
-rw-r--r-- 1 root root  112 May 18 11:09 nodes-7005.conf

查看一個(gè)節(jié)點(diǎn)的配置文件

  • 只知道自己的信息;
[root@redis3_0_7 data]# cat nodes-7000.conf 
53be0c4f0ec1275a7fad49ca74c85623c70201da :0 myself,master - 0 0 0 connected
vars currentEpoch 0 lastVoteEpoch 0

連接上 7000 節(jié)點(diǎn)查看集群的節(jié)點(diǎn)

  • 只知道自己的信息;
[root@redis3_0_7 data]# redis-cli -p 7000 cluster nodes
53be0c4f0ec1275a7fad49ca74c85623c70201da :7000 myself,master - 0 0 0 connected

連接上 7000 節(jié)點(diǎn)查看集群的信息

[root@redis3_0_7 data]# redis-cli -p 7000 cluster info 
cluster_state:fail
cluster_slots_assigned:0
cluster_slots_ok:0
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:1
cluster_size:0
cluster_current_epoch:0
cluster_my_epoch:0
cluster_stats_messages_sent:0
cluster_stats_messages_received:0
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • feisky云計(jì)算、虛擬化與Linux技術(shù)筆記posts - 1014, comments - 298, trac...
    不排版閱讀 4,354評論 0 5
  • redis集群分為服務(wù)端集群和客戶端分片,redis3.0以上版本實(shí)現(xiàn)了集群機(jī)制,即服務(wù)端集群,3.0以下使用客戶...
    hadoop_null閱讀 1,678評論 0 6
  • 1.1 Redis集群的設(shè)計(jì)原則和初衷 在官方文檔Cluster Spec中,作者詳細(xì)介紹了Redis集群為什么要...
    Flame_1109閱讀 2,271評論 1 5
  • 前段時(shí)間我將廣告頻次高的朋友圈關(guān)閉了,想刷出更多的生活狀態(tài)。為此我還寫了篇文章《屏蔽那些無效朋友圈》(點(diǎn)擊標(biāo)題即可...
    郭睿之閱讀 290評論 0 1
  • 一、 數(shù)據(jù)類型及運(yùn)算 求補(bǔ)碼 原碼的基礎(chǔ)上, 符號位不變, 其余各位取反, 最后+1 原碼轉(zhuǎn)補(bǔ)碼不考慮符號位 補(bǔ)碼...
    rh_Jameson閱讀 7,625評論 6 42

友情鏈接更多精彩內(nèi)容