這篇文章主要介紹“redis 5.02官方集群的搭建過程”,在日常操作中,相信很多人在Redis 5.02官方集群的搭建過程問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Redis 5.02官方集群的搭建過程”的疑惑有所幫助!接下來,請跟著小編一起來學(xué)習(xí)吧!
成都創(chuàng)新互聯(lián)公司堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站建設(shè)、成都網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的古城網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
1、下載安裝Redis
# wget http://download.redis.io/releases/redis-stable.tar.gz # tar xfz redis-stable.tar.gz # cd redis-stable # make # 設(shè)置命令執(zhí)行路徑 # cat ~/.bash_profile PATH=$PATH:$HOME/bin:/data/redis-stable/src
2、創(chuàng)建集群的數(shù)據(jù)目錄和配置文件
在兩臺服務(wù)器上面,要創(chuàng)建6個redis實例(三主三從),每個服務(wù)器,分布創(chuàng)建3個數(shù)據(jù)目錄和3個配置文件。
集群主節(jié)點
10.152.5.12:7000
10.152.5.12:7001
10.153.115.24:7003
集群從節(jié)點
10.152.5.12:7002
10.153.115.24:7004
10.153.115.24:7005
# 10.152.5.12 # 創(chuàng)建數(shù)據(jù)目錄 # mkdir redis_cluster # cd redis_cluster # mkdir 7000 7001 7002 # 創(chuàng)建配置文件 # cd 7000 # grep -v "^#" redis_7000.conf protected-mode no port 7000 daemonize yes supervised no pidfile /var/run/redis_7000.pid loglevel notice logfile "/data/redis_cluster/redis_7000.log" dir ./ appendonly yes cluster-enabled yes cluster-config-file nodes_7000.conf cluster-node-timeout 5000 # 啟動服務(wù) redis-server /data/redis_cluster/7000/redis_7000.conf &
# 10.152.5.12 # mkdir redis_cluster # cd redis_cluster # mkdir 7003 7004 7005
3、初始化集群
# redis-cli --cluster create 10.152.5.12:7000 10.152.5.12:7001 10.153.115.24:7003 10.152.5.12:7002 10.153.115.24:7004 10.153.115.24:7005 --cluster-replicas 1 >>> Performing hash slots allocation on 6 nodes... Master[0] -> Slots 0 - 5460 Master[1] -> Slots 5461 - 10922 Master[2] -> Slots 10923 - 16383 Adding replica 10.153.115.24:7004 to 10.152.5.12:7000 Adding replica 10.152.5.12:7002 to 10.153.115.24:7003 Adding replica 10.153.115.24:7005 to 10.152.5.12:7001 M: 65dba2ed08ecb139589710f9efdfd7eeacbb3775 10.152.5.12:7000 slots:[0-5460] (5461 slots) master M: 08e714061bdb817c23c72f1e5c9a72ab878a0c8f 10.152.5.12:7001 slots:[10923-16383] (5461 slots) master M: 7a0a2c7b7778467fa6d5d2d5cab52ad35aa77bf4 10.153.115.24:7003 slots:[5461-10922] (5462 slots) master S: 030fc4d0e02bb7f8245b0bbecf428066daf23a7a 10.152.5.12:7002 replicates 7a0a2c7b7778467fa6d5d2d5cab52ad35aa77bf4 S: c33f01a81258077f3d6cd5f97c91a85225279bff 10.153.115.24:7004 replicates 65dba2ed08ecb139589710f9efdfd7eeacbb3775 S: 18092c18796972c26785a9cfa408cb3a52107818 10.153.115.24:7005 replicates 08e714061bdb817c23c72f1e5c9a72ab878a0c8f Can I set the above configuration? (type 'yes' to accept): yes >>> Nodes configuration updated >>> Assign a different config epoch to each node >>> Sending CLUSTER MEET messages to join the cluster Waiting for the cluster to join .. >>> Performing Cluster Check (using node 10.152.5.12:7000) M: 65dba2ed08ecb139589710f9efdfd7eeacbb3775 10.152.5.12:7000 slots:[0-5460] (5461 slots) master 1 additional replica(s) S: c33f01a81258077f3d6cd5f97c91a85225279bff 10.153.115.24:7004 slots: (0 slots) slave replicates 65dba2ed08ecb139589710f9efdfd7eeacbb3775 S: 18092c18796972c26785a9cfa408cb3a52107818 10.153.115.24:7005 slots: (0 slots) slave replicates 08e714061bdb817c23c72f1e5c9a72ab878a0c8f M: 08e714061bdb817c23c72f1e5c9a72ab878a0c8f 10.152.5.12:7001 slots:[10923-16383] (5461 slots) master 1 additional replica(s) S: 030fc4d0e02bb7f8245b0bbecf428066daf23a7a 10.152.5.12:7002 slots: (0 slots) slave replicates 7a0a2c7b7778467fa6d5d2d5cab52ad35aa77bf4 M: 7a0a2c7b7778467fa6d5d2d5cab52ad35aa77bf4 10.153.115.24:7003 slots:[5461-10922] (5462 slots) master 1 additional replica(s) [OK] All nodes agree about slots configuration. >>> Check for open slots... >>> Check slots coverage... [OK] All 16384 slots covered.
查看進程和日志
# ps -ef|grep redis root 32071 23964 18 11:01 pts/0 00:09:31 redis-server *:7003 [cluster] root 32120 23964 1 11:02 pts/0 00:00:42 redis-server *:7004 [cluster] root 32165 23964 1 11:03 pts/0 00:00:41 redis-server *:7005 [cluster] root 34550 32071 0 11:39 pts/0 00:00:00 redis-aof-rewrite *:7003 [cluster] # tail redis_7003.log 30922:M 07 Dec 2018 10:41:38.391 * Ready to accept connections 32071:C 07 Dec 2018 11:01:32.731 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 32071:C 07 Dec 2018 11:01:32.731 # Redis version=5.0.2, bits=64, commit=00000000, modified=0, pid=32071, just started 32071:C 07 Dec 2018 11:01:32.731 # Configuration loaded 32071:M 07 Dec 2018 11:01:32.733 * Node configuration loaded, I'm 7a0a2c7b7778467fa6d5d2d5cab52ad35aa77bf4 _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 5.0.2 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in cluster mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 7003 | `-._ `._ / _.-' | PID: 32071 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 32071:M 07 Dec 2018 11:01:32.734 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 32071:M 07 Dec 2018 11:01:32.734 # Server initialized 32071:M 07 Dec 2018 11:01:32.734 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. 32071:M 07 Dec 2018 11:01:32.734 * Ready to accept connections 32071:M 07 Dec 2018 11:06:15.060 # configEpoch set to 3 via CLUSTER SET-CONFIG-EPOCH 32071:M 07 Dec 2018 11:06:15.116 # IP address for this node updated to 10.153.115.24 32071:M 07 Dec 2018 11:06:18.146 * Replica 10.152.5.12:7002 asks for synchronization 32071:M 07 Dec 2018 11:06:18.146 * Partial resynchronization not accepted: Replication ID mismatch (Replica asked for 'b8db3eb5c491ab9e2ff92de627925a93105ddd96', my replication IDs are '054964ff1a25320ff6d97c24594f2683e30d43c0' and '0000000000000000000000000000000000000000') 32071:M 07 Dec 2018 11:06:18.146 * Starting BGSAVE for SYNC with target: disk 32071:M 07 Dec 2018 11:06:18.146 * Background saving started by pid 32349 32349:C 07 Dec 2018 11:06:18.147 * DB saved on disk 32349:C 07 Dec 2018 11:06:18.148 * RDB: 0 MB of memory used by copy-on-write 32071:M 07 Dec 2018 11:06:18.196 * Background saving terminated with success 32071:M 07 Dec 2018 11:06:18.196 * Synchronization with replica 10.152.5.12:7002 succeeded 32071:M 07 Dec 2018 11:06:20.001 # Cluster state changed: ok 32071:M 07 Dec 2018 11:31:25.118 * 1 changes in 900 seconds. Saving... 32071:M 07 Dec 2018 11:31:25.118 * Background saving started by pid 33740 33740:C 07 Dec 2018 11:31:25.119 * DB saved on disk 33740:C 07 Dec 2018 11:31:25.120 * RDB: 0 MB of memory used by copy-on-write 32071:M 07 Dec 2018 11:31:25.218 * Background saving terminated with success 32071:M 07 Dec 2018 11:31:37.418 * Starting automatic rewriting of AOF on 6722641000% growth 32071:M 07 Dec 2018 11:31:37.418 * Background append only file rewriting started by pid 33751 32071:M 07 Dec 2018 11:31:38.420 * AOF rewrite child asks to stop sending diffs. 33751:C 07 Dec 2018 11:31:38.420 * Parent agreed to stop sending diffs. Finalizing AOF... 33751:C 07 Dec 2018 11:31:38.420 * Concatenating 5.25 MB of AOF diff received from parent.
到此,關(guān)于“Redis 5.02官方集群的搭建過程”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識,請繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
名稱欄目:Redis5.02官方集群的搭建過程
轉(zhuǎn)載來于:http://aaarwkj.com/article34/ijpcse.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、網(wǎng)站設(shè)計公司、網(wǎng)站建設(shè)、電子商務(wù)、用戶體驗、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)