您现在的位置是:网站首页> 编程资料编程资料

基于Redis6.2.6版本部署Redis Cluster集群的问题_Redis_

2023-05-27 508人已围观

简介 基于Redis6.2.6版本部署Redis Cluster集群的问题_Redis_

1.Redis6.2.6简介以及环境规划

在Redis6.x版本中主要增加了多线程的新特性,多线性对于高并发场景是非常有必要的。

Redis6.x新特性如下:

  • 多线程IO
  • 重新设计了客户端缓存功能
  • RESP3协议
  • 支持SSL
  • ACL权限控制
  • 提升了RDB日志加载速度
  • 发布官方的Redis集群代理模块 Redis Cluster proxy

Redis Cluster集群原理可以查看之前发布的文章。

环境规划:

IP主机名端口号节点
192.168.20.10redis-cluster6701master
192.168.20.10redis-cluster6702slave—>6705的master
192.168.20.10redis-cluster6703master
192.168.20.10redis-cluster6704slave—>6701的master
192.168.20.10redis-cluster6705master
192.168.20.10redis-cluster6706slave—>6703的master

架构图:

Reids集群采用三主三从交叉复制架构,由于服务器数量有限,在一台机器中模拟出集群的效果,在实际生产环境中,需要准备三台机器,每台机器中分别部署两台Redis节点,一主一从,交叉备份。

2.二进制安装Redis程序

2.1.二进制安装redis6.2.6

1.下载reids [root@k8s-master1 /data/]# wget https://download.redis.io/releases/redis-6.2.6.tar.gz 2.解压并安装redis [root@k8s-master1 /data/]# tar xf redis-6.2.6.tar.gz [root@k8s-master1 /data/]# cd redis-6.2.6 [root@k8s-master1 /data/redis-6.2.6]# make 

2.2.创建Reids Cluster集群目录

1.创建Redis Cluster各集群节点的配置文件存放路径 [root@k8s-master ~]# mkdir /data/redis-6.2.6-cluster/{bin,conf,data,var,logs} -p [root@k8s-master ~]# ll /data/redis-6.2.6-cluster/ 总用量 0 drwxr-xr-x 2 root root 6 3月 31 15:36 bin #可执行文件 drwxr-xr-x 2 root root 6 3月 31 15:36 conf #配置文件 drwxr-xr-x 2 root root 6 3月 31 15:36 data #数据文件 drwxr-xr-x 2 root root 6 3月 31 15:36 log #日志文件 drwxr-xr-x 2 root root 6 3月 31 15:36 var #pid文件 2.准备redis可执行命令 [root@k8s-master1 /data/redis-6.2.6]# cp src/redis-benchmark /data/redis-6.2.6-cluster/bin [root@k8s-master1 /data/redis-6.2.6]# cp src/redis-check-aof /data/redis-6.2.6-cluster/bin [root@k8s-master1 /data/redis-6.2.6]# cp src/redis-check-rdb /data/redis-6.2.6-cluster/bin [root@k8s-master1 /data/redis-6.2.6]# cp src/redis-cli /data/redis-6.2.6-cluster/bin [root@k8s-master1 /data/redis-6.2.6]# cp src/redis-sentinel /data/redis-6.2.6-cluster/bin [root@k8s-master1 /data/redis-6.2.6]# cp src/redis-server /data/redis-6.2.6-cluster/bin [root@k8s-master1 /data/redis-6.2.6]# cp src/redis-trib.rb /data/redis-6.2.6-cluster/bin 

3.配置Redis Cluster三主三从交叉复制集群

3.1.准备六个节点的redis配置文件

redis6.2.6版本配置文件所有内容如下,主要配置带注释的行。

bind 0.0.0.0 protected-mode no #关闭保护模式 port 6701 #端口号 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes #后台运行 pidfile /data/redis-6.2.6-cluster/var/redis_6701.pid #pid存放 loglevel notice logfile /data/redis-6.2.6-cluster/logs/redis_6701.log #日志存放路径 databases 16 always-show-logo yes #是否显示总日志 set-proc-title yes proc-title-template "{title} {listen-addr} {server-mode}" stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename redis_6701.rdb #持久化数据文件名称 rdb-del-sync-files no dir /data/redis-6.2.6-cluster/data #持久化数据文件存放路径 replica-serve-stale-data yes replica-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-diskless-load disabled repl-disable-tcp-nodelay no replica-priority 100 acllog-max-len 128 lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no replica-lazy-flush no lazyfree-lazy-user-del no lazyfree-lazy-user-flush no oom-score-adj no oom-score-adj-values 0 200 800 disable-thp yes appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes aof-use-rdb-preamble yes lua-time-limit 5000 cluster-enabled yes #开启集群模式 cluster-config-file nodes_6701.conf #集群模式配置文件名称 cluster-node-timeout 15000 #集群超时时间 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 stream-node-max-bytes 4096 stream-node-max-entries 100 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit replica 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 dynamic-hz yes aof-rewrite-incremental-fsync yes rdb-save-incremental-fsync yes jemalloc-bg-thread yes 

1.复制二进制中的配置文件

[root@k8s-master redis-6.2.6]# cp redis.conf /data/redis-6.2.6-cluster/conf/ 

2.Reids 6701节点配置文件内容

[root@k8s-master conf]# vim redis_6701.conf bind 0.0.0.0 #监听地址 protected-mode no #关闭保护模式 port 6701 #端口号 daemonize yes #后台运行 pidfile /data/redis-6.2.6-cluster/var/redis_6701.pid #pid存放路径 logfile /data/redis-6.2.6-cluster/logs/redis_6701.log #日志存放路径 always-show-logo yes #是否显示总日志 dbfilename redis_6701.rdb #持久化数据文件名称 dir /data/redis-6.2.6-cluster/data #持久化数据文件存放路径 cluster-enabled yes #开启集群模式 cluster-config-file nodes_6701.conf #集群模式配置文件名称 cluster-node-timeout 15000 #集群超时时间 

3.Reids 6702节点配置文件内容

[root@k8s-master conf]# vim redis_6702.conf bind 0.0.0.0 #监听地址 protected-mode no #关闭保护模式 port 6702 #端口号 daemonize yes #后台运行 pidfile /data/redis-6.2.6-cluster/var/redis_6702.pid #pid存放路径 logfile /data/redis-6.2.6-cluster/logs/redis_6702.log #日志存放路径 always-show-logo yes #是否显示总日志 dbfilename redis_6702.rdb #持久化数据文件名称 dir /data/redis-6.2.6-cluster/data #持久化数据文件存放路径 cluster-enabled yes #开启集群模式 cluster-config-file nodes_6702.conf #集群模式配置文件名称 cluster-node-timeout 15000 #集群超时时间 

4.Reids 6703节点配置文件内容

[root@k8s-master conf]# vim redis_6702.conf bind 0.0.0.0 #监听地址 protected-mode no #关闭保护模式 port 6703 #端口号 daemonize yes #后台运行 pidfile /data/redis-6.2.6-cluster/var/redis_6703.pid #pid存放路径 logfile /data/redis-6.2.6-cluster/logs/redis_6703.log #日志存放路径 always-show-logo yes #是否显示总日志 dbfilename redis_6703.rdb #持久化数据文件名称 dir /data/redis-6.2.6-cluster/data #持久化数据文件存放路径 cluster-enabled yes #开启集群模式 cluster-config-file nodes_6703.conf #集群模式配置文件名称 cluster-node-timeout 15000 

5.Reids 6704节点配置文件内容

[root@k8s-master conf]# vim redis_6702.conf bind 0.0.0.0 #监听地址 protected-mode no #关闭保护模式 port 6704 #端口号 daemonize yes #后台运行 pidfile /data/redis-6.2.6-cluster/var/redis_6704.pid #pid存放路径 logfile /data/redis-6.2.6-cluster/logs/redis_6704.log #日志存放路径 always-show-logo yes #是否显示总日志 dbfilename redis_6704.rdb #持久化数据文件名称 dir /data/redis-6.2.6-cluster/data #持久化数据文件存放路径 cluster-enabled yes #开启集群模式 cluster-config-file nodes_6704.conf #集群模式配置文件名称 cluster-node-timeout 15000 

6.Reids 6705节点配置文件内容

[root@k8s-master conf]# vim redis_6702.conf bind 0.0.0.0 #监听地址 protected-mode no #关闭保护模式 port 6705 #端口号 daemonize yes #后台运行 pidfile /data/redis-6.2.6-cluster/var/redis_6705.pid #pid存放路径 logfile /data/redis-6.2.6-cluster/logs/redis_6705.log #日志存放路径 always-show-logo yes #是否显示总日志 dbfilename redis_6705.rdb #持久化数据文件名称 dir /data/redis-6.2.6-cluster/data #持久化数据文件存放路径 cluster-enabled yes #开启集群模式 cluster-config-file nodes_6705.conf #集群模式配置文件名称 cluster-node-timeout 15000 

7.Reids 6706节点配置文件内容

[root@k8s-master conf]# vim redis_6702.conf bind 0.0.0.0 #监听地址 protected-mode no #关闭保护模式 port 6706 #端口号 daemonize yes #后台运行 pidfile /data/redis-6.2.6-cluster/var/redis_6706.pid #pid存放路径 logfile /data/redis-6.2.6-cluster/logs/redis_6706.log #日志存放路径 always-show-logo yes #是否显示总日志 dbfilename redis_6706.rdb #持久化数据文件名称 dir /data/redis-6.2.6-cluster/data #持久化数据文件存放路径 cluster-enabled yes #开启集群模式 cluster-config-file nodes_6706.conf #集群模式配置文件名称 cluster-node-timeout 15000 

3.2.将六个节点全部启动

1)启动redis各个节点

[root@k8s-master ~]# /data/redis-6.2.6-cluster/bin/redis-server /data/redis-6.2.6-cluster/conf/redis_6701.conf [root@k8s-master ~]# /data/redis-6.2.6-cluster/bin/redis-server /data/redis-6.2.6-cluster/conf/redis_6702.conf [root@k8s-master ~]# /data/redis-6.2.6-cluster/bin/redis-server /data/redis-6.2.6-cluster/conf/redis_6703.conf [root@k8s-master ~]# /data/redis-6.2.6-cluster/bin/redis-server /data/r
                
                

-六神源码网