Redis 5.02官方叢集搭建
1、下載安裝Redis
# wget # tar xfz redis-stable.tar.gz # cd redis-stable # make # 設定命令執行路徑 # cat ~/.bash_profile PATH=$PATH:$HOME/bin:/data/redis-stable/src
2、建立叢集的資料目錄和配置檔案
在兩臺伺服器上面,要建立6個redis例項(三主三從),每個伺服器,分佈建立3個資料目錄和3個配置檔案。
叢集主節點
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
# 10.152.5.12 # 建立資料目錄 # mkdir redis_cluster # cd redis_cluster # mkdir 7000 7001 7002 # 建立配置檔案 # 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 # 啟動服務 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 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 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.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2284491/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Redis系列:搭建Redis叢集(叢集模式)Redis模式
- 搭建 Redis 叢集Redis
- redis叢集搭建Redis
- Redis(5.0) 叢集搭建Redis
- 搭建Redis原生叢集Redis
- Redis--叢集搭建Redis
- 搭建redis cluster叢集Redis
- redis叢集的搭建Redis
- redis 4.0.11 叢集搭建Redis
- Docker搭建Redis叢集DockerRedis
- Redis5.0.10叢集搭建Redis
- Redis4.0.12叢集搭建Redis
- 基於Dokcer搭建Redis叢集(主從叢集)Redis
- Docker Redis 5.0 叢集(cluster)搭建DockerRedis
- centos7搭建redis叢集CentOSRedis
- CentOS7 搭建 Redis 叢集CentOSRedis
- Redis主從同步叢集搭建Redis主從同步
- Redis叢集搭建 三主三從Redis
- Redis叢集環境搭建實踐Redis
- 12. Redis叢集環境搭建Redis
- Docker 容器搭建及 Redis 叢集原理DockerRedis
- Redis叢集搭建與簡單使用Redis
- Redis叢集搭建(三主三從)Redis
- Redis叢集搭建採坑總結Redis
- Redis-cluster叢集搭建部署Redis
- 搭建分散式 Redis Cluster 叢集與 Redis 入門分散式Redis
- 使用redis-trib.rb工具快速搭建redis叢集Redis
- redis 叢集搭建以及redislive監測部署Redis
- Redis搭建主從複製、哨兵叢集Redis
- Linux(Centos7)Redis叢集的搭建LinuxCentOSRedis
- Mac 環境下 Redis 叢集的搭建MacRedis
- redis叢集Redis
- redis 叢集Redis
- 在K8S上搭建Redis叢集K8SRedis
- 在滴滴雲上搭建 Redis-Cluster 叢集Redis
- 基於 Redis3.2.4 叢集搭建說明RedisS3
- Redis操作及叢集搭建以及高可用配置Redis
- Redis 結合 Docker 搭建叢集,並整合SpringBootRedisDockerSpring Boot