In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to build a Redis 6.x Cluster cluster for you. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Part1Redis 6.x Cluster cluster build 1 download decompress
You can download the latest stability package directly from Redis's official website at https://redis.io/download. Or use the command: sudo wget http://download.redis.io/releases/redis-6.0.9.tar.gz to download the installation package..
Brother Ma put the software package in the / opt/soft directory and created a directory mkdir redisCluster to place the cluster configuration file. Execute mkdir 7000 7001 7002 7003 7004 7005 under the redisCluster directory to create 6 directories for each node redis.conf configuration template.
Tar-zxf redis-6.0.9.tar.gz-C redisCluster unzipped to the redisCluster directory.
2make compilation
We need to confirm the gcc version before compiling. Since redis 6.0.0, compiling redis needs to support the C11 feature, which was introduced in 4.9. The default gcc version of Centos 7 is 4.8.5, so you need to upgrade the gcc version.
Compilation error
Otherwise, you will encounter the following error log during compilation:
In file included from server.c:31:0: server.c:4999:59: error: 'struct redisServer' has no member named' cluster' (server.cluster_enabled & & nodeIsMaster (server.cluster- > myself) ^ cluster.h:58:27: note: in definition of macro 'nodeIsMaster' # define nodeIsMaster (n) ((n)-> flags & CLUSTER_NODE_MASTER) ^ server.c: In function' main': server.c:5047:11: error: 'struct redisServer' has no member named' sentinel_mode' server.sentinel_mode = checkForSentinelMode (argc) Argv) ^ server.c:5064:15: error: 'struct redisServer' has no member named' sentinel_mode' if (server.sentinel_mode) {^ server.c:5131:19: error: 'struct redisServer' has no member named' sentinel_mode' if (server.sentinel_mode & & configfile & & * configfile = ='-') {^ server.c:5153 Error: 'struct redisServer' has no member named' sentinel_mode' serverLog (LL_WARNING "Warning: no config file specified, using the default config. In order to specify a config file use% s / path/to/%s.conf ", argv [0], server.sentinel_mode? "sentinel": "redis") ^ server.c:5158:11: error: 'struct redisServer' has no member named' supervised' server.supervised = redisIsSupervised (server.supervised_mode) ^ server.c:5158:49: error: 'struct redisServer' has no member named' supervised_mode' server.supervised = redisIsSupervised (server.supervised_mode); ^ server.c:5159:28: error: 'struct redisServer' has no member named' daemonize' int background = server.daemonize & &! server.supervised ^ server.c:5159:49: error: 'struct redisServer' has no member named' supervised' int background = server.daemonize & &! server.supervised; ^ server.c:5163:29: error: 'struct redisServer' has no member named' pidfile' if (background | | server.pidfile) createPidFile () ^ server.c:5168:16: error: 'struct redisServer' has no member named' sentinel_mode' if (! server.sentinel_mode) {^ server.c:5178:19: error: 'struct redisServer' has no member named' cluster_enabled' if (server.cluster_enabled) {^ server.c:5186:19 : error: 'struct redisServer' has no member named' ipfd_count' if (server.ipfd_count > 0 | | server.tlsfd_count > 0) ^ server.c:5186:44: error: 'struct redisServer' has no member named' tlsfd_count' if (server.ipfd_count > 0 | | server.tlsfd_count > 0) ^ server.c:5188:19: error: 'struct redisServer' has no member named' sofd' if (server.sofd > 0) ^ server.c:5189:94: error: 'struct redisServer' has no member named' unixsocket' serverLog (LL_NOTICE "The server is now ready to accept connections at's", server.unixsocket) ^ server.c:5190:19: error: 'struct redisServer' has no member named' supervised_mode' if (server.supervised_mode = = SUPERVISED_SYSTEMD) {^ server.c:5191:24: error: 'struct redisServer' has no member Named 'masterhost' if (! server.masterhost) {^ server.c:5201:19: error:' struct redisServer' has no member named 'supervised_mode' if (server.supervised_mode = = SUPERVISED_SYSTEMD) {^ server.c:5208:15: error:' struct redisServer' has no member named 'maxmemory' if (server.maxmemory > 0 & & server.maxmemory
< 1024*1024) { ^ server.c:5208:39: error: ‘struct redisServer’ has no member named ‘maxmemory’ if (server.maxmemory >0 & & server.maxmemory
< 1024*1024) { ^ server.c:5209:176: error: ‘struct redisServer’ has no member named ‘maxmemory’ serverLog(LL_WARNING,"WARNING: You specified a maxmemory value that is less than 1MB (current value is %llu bytes). Are you sure this is what you really want?", server.maxmemory); ^ server.c:5212:31: error: ‘struct redisServer’ has no member named ‘server_cpulist’ redisSetCpuAffinity(server.server_cpulist); ^ server.c: In function ‘hasActiveChildProcess’: server.c:1480:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ server.c: In function ‘allPersistenceDisabled’: server.c:1486:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ server.c: In function ‘writeCommandsDeniedByDiskError’: server.c:3826:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ server.c: In function ‘iAmMaster’: server.c:5000:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ ....解决方式yum -y install gcc gcc-c++ make tcl yum -y install centos-release-scl yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils scl enable devtoolset-9 bash 升级之后便可解决 make 报错问题。 注意:scl命令启用只是临时的,退出xshell或者重启就会恢复到原来的gcc版本。如果要长期生效的话,执行如下 sudo echo "source /opt/rh/devtoolset-9/enable" >> / etc/profile.
Cd / opt/soft/redisCluster/redis-6.0.9 changes to the directory to execute make.
After compilation, use make install to install redis, command: sudo make install.
3 modify the configuration file
Cd / opt/soft/redisCluster/redis-6.0.9 copies the redis.conf to the 7000 7001 7002 7003 7004 directory, respectively.
Modify 6 redis.conf respectively
# # 7000-7005 port port 7000 # # launch daemonize yes # # if you are simulating a cluster on a stand-alone machine, you must specify the IP of bind. If you do not modify ip, connecting to the cluster using the program will report an error bind 192.168.221.150 # # enable redis-cluster cluster cluster-enabled yes # # each instance also contains the path to store the files configured by this node. By default, it is nodes.conf. Automatically create cluster-config-file nodes_7000.conf # # timeout cluster-node-timeout # # enable aof appendonly yes # Note replication is not allowed under cluster cluster. # replicaof 127.0.0.1 9000 # disable the protection mode. If you enable it, you need to set a password, which is cumbersome. You can protected-mode no according to your own needs.
Only port and cluster-config-file need to be modified for each configuration file.
4 start the node and create the cluster startup node
Go to the redisCluster directory and execute the instructions to start each node in turn. Redis-6.0.9/src/redis-server 700x/redis.conf notes that each node profile is specified. If it is not specified, the configuration under src will be used by default.
Create a cluster
Enter any node and execute the following instructions to create a cluster
The instructions are as follows:
Redis-6.0.9/src/redis-cli-- cluster create 172.16.90.152 7000172.16.90.152 7001 172.16.90.152 7002 172.16.90.152 7003 172.16.90.152 7004 172.16.90.152 cluster-replicas 1
Explanation of cluster parameters:
Cluster-replicas 1: indicates that you want to create a slave node (one master and one slave) for each master node in the cluster.
Cluster-replicas 2: indicates that you want to create two slave nodes (one master and two slaves) for each master node in the cluster.
Console response:
> Performing hash slots allocation on 6 nodes... Master [0]-> Slots 0-5460 Master [1]-> Slots 5461-10922 Master [2]-> Slots 10923-16383 Adding replica 172.16.90.152 to 172.16.90.152 7000Adding replica 172.16.90.152 005 to 172.16.90.152 7003 to 172.16.90.152 7003 to 172.16.90.152 > Trying to optimize slaves allocation for anti-affinity [WARNING Some slaves are in the same host as their master M] : 06c56f5a6a4436108fae931be499465985141d39 172.16.90.152 master 7000slots: [0-5460] (5461 slots) master M: 0ab7c9efd97319d94a8ea52452ec58f7708d812d 172.16.90.152 slots 7001 slots: [5461-10922] (5462 slots) master M: 096f076d99363270c02785a2fb298e2ee65d3f07 172.16.90.152 master 7002 slots: [10923-16383] (5461 slots) master S: 69d621060295eb433af3e34e702142df0fd4d73d 172.16.90.152 2lav 7003 replicates 06c56f5a6a4436108fae931be499465985141d39 S: 1d37df0aa0e2310aedb5a380f95cc818256003f8 172.16.90.152 2Rover 7004 replicates 0ab7c9efd97319d94a8ea52452ec58f7708d812d S: d9204f6da875a4b2522c5fa25d9e6c1f95cf51ea 172.16.90.152 replicates 096f076d99363270c02785a2fb298e2ee65d3f07 Can I set the above configuration? (type 'yes' to accept):
Can I set the above configuration? (type 'yes' to accept): ask if you want to confirm the node slots allocation scheme, and we enter' 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 172.16.90.152 0ab7c9efd97319d94a8ea52452ec58f7708d812d 7000) M: 06c56f5a6a4436108fae931be499465985141d39 172.16.90.152 slots 7000 slots: [0-5460] (5461 slots) master 1 additional replica (s) S: 1d37df0aa0e2310aedb5a380f95cc818256003f8 172.16.90.152 0ab7c9efd97319d94a8ea52452ec58f7708d812d 7004 slots: (0 slots) slave replicates 0ab7c9efd97319d94a8ea52452ec58f7708d812d M: 0ab7c9efd97319d94a8ea52452ec58f7708d812d 172.16.90.152 7001 slots: [5461-10922] (5462 slots) master 1 additional replica (s) S: d9204f6da875a4b2522c5fa25d9e6c1f95cf51ea 172.16.90.152 7005 Slots: (0 slots) slave replicates 096f076d99363270c02785a2fb298e2ee65d3f07 S: 69d621060295eb433af3e34e702142df0fd4d73d 172.16.90.152 slots 7003 slots: (0 slots) slave replicates 06c56f5a6a4436108fae931be499465985141d39 M: 096f076d99363270c02785a2fb298e2ee65d3f07 172.16.90.152 slave replicates 096f076d99363270c02785a2fb298e2ee65d3f07 7002 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.
[OK] All 16384 slots covered.
It's done here!
5 View cluster status
Redis-6.0.9/src/redis-cli-- cluster check 172.16.90.152Vl7000
6 points for attention
When you create a cluster using redis-6.0.9/src/redis-cli-- cluster create 172.16.90.152 7000172.16.90.152 7001 172.16.90.152 7002 172.16.90.152 7003 172.16.90.152 7004 172.16.90.152 7005-cluster-replicas 1, create it once and use it permanently. Then start each node directly to build the cluster.
End command: redis-6.0.9/src/redis-cli-c-h 192.168.124.23-p 7004 shutdown
The entry command redis-cli-c-h host-p prot does not enter the cluster without the-c parameter.
This is the end of the article on "how to build Redis 6.x Cluster clusters". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.