久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Redis集群部署方法

144次閱讀
沒有評論

共計 7346 個字符,預計需要花費 19 分鐘才能閱讀完成。

本篇內容介紹了“Redis 集群部署方法”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓丸趣 TV 小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

1、主從節點均安裝好 redis 以及 ruby。
[root@D2-LZY245 redis-4.0.1]# yum -y install ruby ruby-devel rubygems rpm-build
[root@D2-LZY245 redis-4.0.1]# gem install redis

2、主節點創建集群目錄、配置參數并啟動
[root@D2-LZY245 ~]# cd redis-4.0.1/
[root@D2-LZY245 redis-4.0.1]# mkdir redis_cluster
[root@D2-LZY245 redis-4.0.1]# cd redis_cluster/
[root@D2-LZY245 redis_cluster]# mkdir 7000 7001 7002
[root@D2-LZY245 redis_cluster]# cp ../redis.conf 7000/
[root@D2-LZY245 redis_cluster]# vim 7000/redis.conf
[root@D2-LZY245 redis_cluster]# egrep ^port|^bind|^daemonize|^pidfile|^cluster-enabled|^cluster-config-file|^cluster-node-timeout|^appendonly 7000/redis_7000.conf
bind 10.163.89.245
port 7000
daemonize yes
pidfile /var/run/redis_7000.pid
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7000.conf
cluster-node-timeout 15000
[root@D2-LZY245 redis_cluster]# mv 7000/redis.conf  7000/redis_7000.conf
[root@D2-LZY245 redis_cluster]# cp 7000/redis_7000.conf 7001/redis_7001.conf
[root@D2-LZY245 redis_cluster]# cp 7000/redis_7000.conf 7002/redis_7002.conf
[root@D2-LZY245 redis_cluster]# vim 7001/redis_7001.conf
[root@D2-LZY245 redis_cluster]# egrep ^port|^bind|^daemonize|^pidfile|^cluster-enabled|^cluster-config-file|^cluster-node-timeout|^appendonly 7001/redis_7001.conf
bind 10.163.89.245
port 7001
daemonize yes
pidfile /var/run/redis_7001.pid
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7001.conf
cluster-node-timeout 15000
[root@D2-LZY245 redis_cluster]# vim 7002/redis_7002.conf
[root@D2-LZY245 redis_cluster]# egrep ^port|^bind|^daemonize|^pidfile|^cluster-enabled|^cluster-config-file|^cluster-node-timeout|^appendonly 7002/redis_7002.conf
bind 10.163.89.245
port 7002
daemonize yes
pidfile /var/run/redis_7002.pid
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7002.conf
cluster-node-timeout 15000

[root@D2-LZY245 redis_cluster]# cd ..
[root@D2-LZY245 redis-4.0.1]# src/redis-server redis_cluster/7000/redis_7000.conf
[root@D2-LZY245 redis-4.0.1]# src/redis-server redis_cluster/7001/redis_7001.conf
[root@D2-LZY245 redis-4.0.1]# src/redis-server redis_cluster/7002/redis_7002.conf
[root@D2-LZY245 redis-4.0.1]# netstat -tunlp | grep 700
tcp  0  0 10.163.89.245:17000  0.0.0.0:*  LISTEN  28447/src/redis-ser
tcp  0  0 10.163.89.245:17001  0.0.0.0:*  LISTEN  28423/src/redis-ser
tcp  0  0 10.163.89.245:17002  0.0.0.0:*  LISTEN  28432/src/redis-ser
tcp  0  0 10.163.89.245:7000  0.0.0.0:*  LISTEN  28447/src/redis-ser
tcp  0  0 10.163.89.245:7001  0.0.0.0:*  LISTEN  28423/src/redis-ser
tcp  0  0 10.163.89.245:7002  0.0.0.0:*  LISTEN  28432/src/redis-ser

3、從節點創建集群目錄、配置參數并啟動
[root@D2-TRAIN15 ~]# cd redis-4.0.1
[root@D2-TRAIN15 redis-4.0.1]# mkdir redis_cluster
[root@D2-TRAIN15 redis-4.0.1]# cd redis_cluster/
[root@D2-TRAIN15 redis_cluster]# mkdir 7003 7004 7005
[root@D2-TRAIN15 redis_cluster]# cp ../redis.conf 7003/
[root@D2-TRAIN15 redis_cluster]# vim 7003/redis.conf
[root@D2-TRAIN15 redis_cluster]#  egrep ^port|^bind|^daemonize|^pidfile|^cluster-enabled|^cluster-config-file|^cluster-node-timeout|^appendonly 7003/redis.conf
bind 10.163.89.15
port 7003
daemonize yes
pidfile /var/run/redis_7003.pid
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7003.conf
cluster-node-timeout 15000
[root@D2-TRAIN15 redis_cluster]# mv 7003/redis.conf 7003/redis_7003.conf
[root@D2-TRAIN15 redis_cluster]# cp 7003/redis_7003.conf 7004/redis_7004.conf
[root@D2-TRAIN15 redis_cluster]# cp 7003/redis_7003.conf 7005/redis_7005.conf
[root@D2-TRAIN15 redis_cluster]# vim 7004/redis_7004.conf
[root@D2-TRAIN15 redis_cluster]# egrep ^port|^bind|^daemonize|^pidfile|^cluster-enabled|^cluster-config-file|^cluster-node-timeout|^appendonly 7004/redis_7004.conf
bind 10.163.89.15
port 7004
daemonize yes
pidfile /var/run/redis_7004.pid
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7004.conf
cluster-node-timeout 15000
[root@D2-TRAIN15 redis_cluster]# vim 7005/redis_7005.conf
[root@D2-TRAIN15 redis_cluster]# egrep ^port|^bind|^daemonize|^pidfile|^cluster-enabled|^cluster-config-file|^cluster-node-timeout|^appendonly 7005/redis_7005.conf
bind 10.163.89.15
port 7005
daemonize yes
pidfile /var/run/redis_7005.pid
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7005.conf
cluster-node-timeout 15000

[root@D2-TRAIN15 redis_cluster]# cd ..
[root@D2-TRAIN15 redis-4.0.1]# src/redis-server redis_cluster/7003/redis_7003.conf
[root@D2-TRAIN15 redis-4.0.1]# src/redis-server redis_cluster/7004/redis_7004.conf
[root@D2-TRAIN15 redis-4.0.1]# src/redis-server redis_cluster/7005/redis_7005.conf
[root@D2-TRAIN15 redis-4.0.1]# netstat -tunlp | grep 700
tcp  0  0 10.163.89.15:17003  0.0.0.0:*  LISTEN  14258/src/redis-ser
tcp  0  0 10.163.89.15:17004  0.0.0.0:*  LISTEN  14263/src/redis-ser
tcp  0  0 10.163.89.15:17005  0.0.0.0:*  LISTEN  14268/src/redis-ser
tcp  0  0 10.163.89.15:7003  0.0.0.0:*  LISTEN  14258/src/redis-ser
tcp  0  0 10.163.89.15:7004  0.0.0.0:*  LISTEN  14263/src/redis-ser
tcp  0  0 10.163.89.15:7005  0.0.0.0:*  LISTEN  14268/src/redis-ser
[root@D2-TRAIN15 redis-4.0.1]#

4、創建集群
[root@D2-LZY245 redis-4.0.1]# src/redis-trib.rb create –replicas 1 10.163.89.245:7000 10.163.89.245:7001 10.163.89.245:7002 10.163.89.15:7003 10.163.89.15:7004 10.163.89.15:7005
Creating cluster
Performing hash slots allocation on 6 nodes…
Using 3 masters:
10.163.89.245:7000
10.163.89.15:7003
10.163.89.245:7001
Adding replica 10.163.89.15:7004 to 10.163.89.245:7000
Adding replica 10.163.89.245:7002 to 10.163.89.15:7003
Adding replica 10.163.89.15:7005 to 10.163.89.245:7001
M: b545390b3e8c3602e13978cf28f6ef7dd76b6197 10.163.89.245:7000
  slots:0-5460 (5461 slots) master
M: 0e26e28f3c531357db73e522bb6279350ff5275e 10.163.89.245:7001
  slots:10923-16383 (5461 slots) master
S: 8164d21461a9a5612e9657863c1c214f8c116a8e 10.163.89.245:7002
  replicates e81c2072be94bdf7729b10088a312ff519cb0f2b
M: e81c2072be94bdf7729b10088a312ff519cb0f2b 10.163.89.15:7003
  slots:5461-10922 (5462 slots) master
S: 4284f88f612157caa6611173d347ec4ec9f9554b 10.163.89.15:7004
  replicates b545390b3e8c3602e13978cf28f6ef7dd76b6197
S: d141fe7c975728b1243d6d314914179a7febb306 10.163.89.15:7005
  replicates 0e26e28f3c531357db73e522bb6279350ff5275e
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.163.89.245:7000)
M: b545390b3e8c3602e13978cf28f6ef7dd76b6197 10.163.89.245:7000
  slots:0-5460 (5461 slots) master
  1 additional replica(s)
S: 8164d21461a9a5612e9657863c1c214f8c116a8e 10.163.89.245:7002
  slots: (0 slots) slave
  replicates e81c2072be94bdf7729b10088a312ff519cb0f2b
S: d141fe7c975728b1243d6d314914179a7febb306 10.163.89.15:7005
  slots: (0 slots) slave
  replicates 0e26e28f3c531357db73e522bb6279350ff5275e
S: 4284f88f612157caa6611173d347ec4ec9f9554b 10.163.89.15:7004
  slots: (0 slots) slave
  replicates b545390b3e8c3602e13978cf28f6ef7dd76b6197
M: e81c2072be94bdf7729b10088a312ff519cb0f2b 10.163.89.15:7003
  slots:5461-10922 (5462 slots) master
  1 additional replica(s)
M: 0e26e28f3c531357db73e522bb6279350ff5275e 10.163.89.245:7001
  slots:10923-16383 (5461 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.

5、測試
在主節點 7000 端口設置 key:
[root@D2-LZY245 ~]# cd redis-4.0.1/
[root@D2-LZY245 redis-4.0.1]# src/redis-cli -h 10.163.89.245 -c -p 7000
10.163.89.245:7000 set key1 hello world
– Redirected to slot [9189] located at 10.163.89.15:7003
OK
10.163.89.15:7003 keys *
1) key1

在從節點 7005 端口查看:
[root@D2-TRAIN15 redis-4.0.1]# src/redis-cli -h 10.163.89.15 -c -p 7005
10.163.89.15:7005 get key1
– Redirected to slot [9189] located at 10.163.89.15:7003
hello world

“Redis 集群部署方法”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注丸趣 TV 網站,丸趣 TV 小編將為大家輸出更多高質量的實用文章!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-08-01發表,共計7346字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 大石桥市| 临海市| 深圳市| 宜黄县| 岗巴县| 延川县| 临颍县| 泗洪县| 岚皋县| 犍为县| 闸北区| 伊宁市| 莱西市| 衡水市| 巨野县| 普兰店市| 聂荣县| 定襄县| 莲花县| 德江县| 兴安盟| 石台县| 金阳县| 右玉县| 张家港市| 驻马店市| 华蓥市| 隆子县| 贺兰县| 沙田区| 镇康县| 拉孜县| 增城市| 永安市| 彩票| 日土县| 泌阳县| 景东| 景洪市| 湖州市| 房产|