創(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ù)。