Redis 6. X cluster construction

Codebyte 2021-04-08 12:00:48
redis cluster construction


Part1Redis 6.X Cluster Cluster building

I'm going to take you all to the end CentOS 7 Install in Redis 6.x course . I'm learning Redis Cluster The cluster before , We need to build a cluster environment first . The machines are limited , The goal is to build... On a machine 6 Nodes , Form a three master and three slave cluster model .

1 Download decompression

You can go directly to Redis Download the latest stability pack from the official website , Address :https://redis.io/download. Or use command :sudo wget http://download.redis.io/releases/redis-6.0.9.tar.gz Download installation package ..

  1. Code brother put the software package in /opt/soft Under the table of contents , And create a directory mkdir redisCluster Used to place the cluster configuration file . stay redisCluster Execute under directory mkdir 7000 7001 7002 7003 7004 7005 establish 6 Each directory corresponds to each node redis.conf The configuration template .
  2. tar -zxf redis-6.0.9.tar.gz -C redisCluster Unzip to redisCluster Directory .

2make compile

Before we compile, we need to confirm that gcc edition , since redis 6.0.0 after , compile redis Need to support C11 characteristic ,C11 Characteristic in 4.9 Introduced in .Centos 7 Default gcc Version is 4.8.5, So we need to upgrade gcc edition .

Compile error

Otherwise, the following error log will be encountered 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:168: 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]
}
^
....

Solution

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

It can be solved after upgrading make Report the wrong question .

Be careful :scl Command activation is only temporary , sign out xshell Or the restart will return to the original gcc edition . If it's going to take effect in the long run , The implementation is as follows sudo echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile.

cd /opt/soft/redisCluster/redis-6.0.9 Switch to directory execution make .

Compile complete use make install Yes redis Installation , command :sudo make install.

3 Modify the configuration file

cd /opt/soft/redisCluster/redis-6.0.9 take redis.conf Copy them to 7000 7001 7002 7003 7004 Directory .

Revision respectively 6 individual redis.conf

## 7000-7005 port
port 7000
## Background start
daemonize yes
## If you are in a stand-alone simulation cluster, you must specify bind Of IP, If not modified ip If you use the program to connect to the cluster, you will report an error
bind 192.168.221.150
## Turn on redis-cluster colony
cluster-enabled yes
## Each instance also contains the path to the file that stores the configuration of this node , By default nodes.conf, Automatically create
cluster-config-file nodes_7000.conf
## Overtime
cluster-node-timeout 500
## Turn on aof
appendonly yes
# notes cluster Replication is not allowed in a cluster .
#replicaof 127.0.0.1 9000
# Turn off protection mode , If you need to set a password to open , More complicated , According to their own needs to
protected-mode no

Each profile just needs to be modified port and cluster-config-file That's all right. .

4 Start the node and create the cluster

Start node

Get into redisCluster Catalog , Execute the command to start each node in turn .redis-6.0.9/src/redis-server 700x/redis.conf Note that each node profile is specified , If you do not specify a configuration file, it will be used by default src Configuration below .

Create clusters

Go to any node , Execute the following command to create a cluster

The instructions are as follows :

redis-6.0.9/src/redis-cli --cluster create 172.16.90.152:7000 172.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

Cluster parameter interpretation :

  1. cluster-replicas 1: Indicates that you want to create a slave node for each master node in the cluster ( A master from ).
  2. cluster-replicas 2: Indicates that you want to create two slave nodes for each master node in the cluster ( One master and two subordinates ).

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:7004 to 172.16.90.152:7000
Adding replica 172.16.90.152:7005 to 172.16.90.152:7001
Adding replica 172.16.90.152:7003 to 172.16.90.152:7002
>>> 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:7000
slots:[0-5460] (5461 slots) master
M: 0ab7c9efd97319d94a8ea52452ec58f7708d812d 172.16.90.152:7001
slots:[5461-10922] (5462 slots) master
M: 096f076d99363270c02785a2fb298e2ee65d3f07 172.16.90.152:7002
slots:[10923-16383] (5461 slots) master
S: 69d621060295eb433af3e34e702142df0fd4d73d 172.16.90.152:7003
replicates 06c56f5a6a4436108fae931be499465985141d39
S: 1d37df0aa0e2310aedb5a380f95cc818256003f8 172.16.90.152:7004
replicates 0ab7c9efd97319d94a8ea52452ec58f7708d812d
S: d9204f6da875a4b2522c5fa25d9e6c1f95cf51ea 172.16.90.152:7005
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 Distribution plan , We type in ‘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:7000)
M: 06c56f5a6a4436108fae931be499465985141d39 172.16.90.152:7000
slots:[0-5460] (5461 slots) master
1 additional replica(s)
S: 1d37df0aa0e2310aedb5a380f95cc818256003f8 172.16.90.152: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:7003
slots: (0 slots) slave
replicates 06c56f5a6a4436108fae931be499465985141d39
M: 096f076d99363270c02785a2fb298e2ee65d3f07 172.16.90.152: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.

That's it !

5 View the cluster status

redis-6.0.9/src/redis-cli --cluster check 172.16.90.152:7000

6 matters needing attention

When using redis-6.0.9/src/redis-cli --cluster create 172.16.90.152:7000 172.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 After creating the cluster , Create... At once , Permanent use . After that, start each node directly to build the cluster .

Closing order :redis-6.0.9/src/redis-cli -c -h 192.168.124.23 -p 7004 shutdown

Enter the cluster command redis-cli -c -h host -p prot No -c The parameter does not enter the cluster

After building the cluster , Looking forward to the next 「Redis High availability :Cluster How much data can be supported ?」

This article is from WeChat official account. - Code byte (MageByte)

The source and reprint of the original text are detailed in the text , If there is any infringement , Please contact the yunjia_community@tencent.com Delete .

Original publication time : 2021-04-05

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

版权声明
本文为[Codebyte]所创,转载请带上原文链接,感谢
https://javamana.com/2021/04/20210408111751515t.html

  1. A love diary about http
  2. navicat连接win10 mysql8.0 报错2059
  3. [rocketmq source code analysis] in depth message storage (3)
  4. Implementation of service configuration center with spring cloud + Nacos (Hoxton version)
  5. SCIP: constructing data abstraction -- Explanation of queue and tree in data structure
  6. SCIP: abstraction of construction process -- object oriented explanation
  7. Using docker to build elasticsearch + kibana cluster
  8. What are the spring IOC features? I can't understand the source code!
  9. Spring cloud upgrade road - 2020.0. X - 3. Accesslog configuration of undertow
  10. 导致Oracle性能抖动的参数提醒
  11. 风险提醒之Oracle RAC高可用失效
  12. 小机上运行Oracle需要注意的进程调度bug
  13. Oracle内存过度消耗风险提醒
  14. Oracle SQL monitor
  15. 使用Bifrost实现Mysql的数据同步
  16. 揭秘Oracle数据库truncate原理
  17. 看了此文,Oracle SQL优化文章不必再看!
  18. Mybatis (3) map and fuzzy query expansion
  19. Kafka性能篇:为何这么“快”?
  20. 两个高频设计类面试题:如何设计HashMap和线程池
  21. [TTS] AIX - & gt; Linux -- Based on RMAN (real environment)
  22. 为什么学编程大部分人选Java编程语言?
  23. Redis 高可用篇:你管这叫 Sentinel 哨兵集群原理
  24. redis 为什么把简单的字符串设计成 SDS?
  25. [TTS] transfer table space AIX - & gt; Linux based on RMAN
  26. Linux 网卡数据收发过程分析
  27. Redis 高可用篇:你管这叫 Sentinel 哨兵集群原
  28. Redis 6.X Cluster 集群搭建
  29. [TTS] transfer table space AIX ASM - & gt; Linux ASM
  30. [TTS] transfer table space Linux ASM - & gt; AIX ASM
  31. 高性能通讯框架——Netty
  32. Brief introduction and test of orchestrator, a high availability management tool for MySQL
  33. [TTS] transfer table space Linux - & gt; AIX based on RMAN
  34. A love diary about http
  35. [rocketmq source code analysis] in depth message storage (3)
  36. Implementation of service configuration center with spring cloud + Nacos (Hoxton version)
  37. SiCp: abstraction of construction process -- object oriented explanation
  38. springboot网上点餐系统
  39. 【SPM】oracle如何固定执行计划
  40. 用好HugePage,告别Linux性能故障
  41. 3 W word long text, java basic interview questions! It's amazing!!!
  42. Spring cloud upgrade road - 2020.0. X - 3. Accesslog configuration of undertow
  43. Win10 uninstall mysql5.7
  44. CentOS下dotnet Core使用HttpWebRequest进行HTTP通讯,系统存在大量CLOSE_WAIT连接问题的分析,已解决。
  45. MySQL batch insert, how not to insert duplicate data?
  46. K8s cronjob application example
  47. Unconventional method, easy to deal with Oracle database critical exception
  48. How to use sqlplus - prelim in Oracle hang
  49. How to search Oracle official documents in full text
  50. Install mysql8.0 on win10
  51. Oracle OCR的备份与恢复
  52. Oracle kill session相关问题
  53. 《Oracle DBA工作笔记》第二章 常用工具和问题分析
  54. Oracle回收站及flashback drop
  55. Hand in hand to teach you to write a spring IOC container
  56. Exception in Java (1) - basic concept
  57. 3w 字长文爆肝 Java 基础面试题!太顶了!!!
  58. Error 2059 when Navicat connects to win10 mysql8.0
  59. Parameter reminder causing Oracle Performance jitter
  60. 「技术分享」Java线程状态间的互相转换看这个就行了