新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这篇文章主要介绍“Redis 5.02官方集群的搭建过程”,在日常操作中,相信很多人在Redis 5.02官方集群的搭建过程问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Redis 5.02官方集群的搭建过程”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
作为一家“创意+整合+营销”的成都网站建设机构,我们在业内良好的客户口碑。成都创新互联公司提供从前期的网站品牌分析策划、网站设计、网站建设、网站制作、创意表现、网页制作、系统开发以及后续网站营销运营等一系列服务,帮助企业打造创新的互联网品牌经营模式与有效的网络营销方法,创造更大的价值。1、下载安装Redis
# wget http://download.redis.io/releases/redis-stable.tar.gz # 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 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | 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.
到此,关于“Redis 5.02官方集群的搭建过程”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联-成都网站建设公司网站,小编会继续努力为大家带来更多实用的文章!