#解决编译高版本redis报错gcc版本低问题,编译需要在互联网环境服务器上进行
yum install centos-release-scl
#换源地址
vim /etc/yum.repos.d/CentOS-SCLo-scl.repo
#注掉原有镜像,更改为
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/7/sclo/$basearch/sclo/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
#换源地址
vim /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
#注掉原有mirrorlist,解开baseurl并更改为如下,建议复制,手动更改需严格注意细节
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/$basearch/rh/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
yum clean all && yum makecache
yum install -y devtoolset-9-gcc*
#查看已安装完成的版本
scl --list
#启动生效
scl enable devtoolset-9 bash
#查看是否变更为gcc-9版本
gcc -v
#写入开机生效
vim /etc/profile
scl enable devtoolset-9 bash
#至此高版本redis编译环境部署完成,编译后的redis文件可以随意复制上传运行
#redis源码包下载:https://download.redis.io/releases/
#本次安装选择下载redis-6.0.0.tar.gz,下载后上传到编译环境服务器的/opt下
cd /opt && tar -xvf redis-6.0.0.tar.gz
cd /opt/redis-6.0.0
#编译
make
#打包编译完成后redis
cd /opt && tar -cvzf redis-6.0.0_finish.tar.gz redis-6.0.0
#至此编译后的redis-6.0.0_finish.tar.gz可以随意复制上传其他环境解压运行
#上传redis-6.0.0_finish.tar.gz到每台服务器的/opt下,离线环境也可以,每台机器操作如下
cd /opt/
tar –xvf redis-6.0.0_finish.tar.gz
mv redis-6.0.0 redis
cd /opt/redis
cp redis.conf redis.conf_bak
cp redis.conf redis.conf2
#三节点ip192.168.1.21,192.168.1.22,192.168.1.23,下述配置以192.168.1.21机器为例,其他节点配置更改ip即可,其他操作步骤相同
#每台机器双节点,3台机器共3主3从共6节点集群部署,每台机器redis.conf起6379为一节点,reids.conf2起6380为一节点
echo 1 > redis.conf
echo 1 > redis.conf2
vim redis.conf
#覆盖更改为下
bind 192.168.1.21
port 6379
protected-mode no
tcp-backlog 4096
timeout 300
tcp-keepalive 60
maxclients 10000
maxmemory-policy volatile-lru
slowlog-max-len 512
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 0 0 0
repl-backlog-size 100mb
stop-writes-on-bgsave-error no
cluster-enabled yes
cluster-config-file node6379.conf
cluster-node-timeout 5000
cluster-require-full-coverage no
dbfilename "dump6379.rdb"
appendonly yes
appendfilename "appendonly6379.aof"
logfile "/mnt/data/redis/redis6379.log"
daemonize yes
dir "/mnt/data/redis6379"
vim redis.conf2
#覆盖更改为下
bind 192.168.1.21
port 6380
protected-mode no
tcp-backlog 4096
timeout 300
tcp-keepalive 60
maxclients 10000
maxmemory-policy volatile-lru
slowlog-max-len 512
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 0 0 0
repl-backlog-size 100mb
stop-writes-on-bgsave-error no
cluster-enabled yes
cluster-config-file node6380.conf
cluster-node-timeout 5000
cluster-require-full-coverage no
dbfilename "dump6380.rdb"
appendonly yes
appendfilename "appendonly6380.aof"
logfile "/mnt/data/redis/redis6380.log"
daemonize yes
dir "/mnt/data/redis6380"
#创建配置文件中的相关目录
mkdir -p /mnt/data/redis
mkdir -p /mnt/data/redis6379
mkdir -p /mnt/data/redis6380
#启动redis,每台服务器启动两个配置,三台机器共六个redis节点
/opt/redis/src/redis-server /opt/redis/redis.conf
/opt/redis/src/redis-server /opt/redis/redis.conf2
#配置集群,三主三从自动分配,--cluster-replicas 1表示一主分配一个从
/opt/redis/src/redis-cli --cluster create --cluster-replicas 1 192.168.1.20:6379 192.168.1.21:6379 192.168.1.22:6379 192.168.1.20:6380 192.168.1.21:6380 192.168.1.22:6380
#完成后进行集群检查
/opt/redis/src/redis-cli --cluster check 192.168.1.20:6379
#登陆集群
/opt/redis/src/redis-cli -h 192.168.1.20 -p 6379 -c
#集群创建完成后才能设置密码
vim /opt/redis/redis.conf
vim /opt/redis/redis.conf2
#在配置最后新加requirepass 节点和masterauth主节点密码
requirepass Diablo@2025
masterauth Diablo@2025
#重启所有节点,kill掉6台所有redis节点
Kill -9 进程号
#再启动所有节点,三台都执行如下,每台启动两个redis业务
/opt/redis/src/redis-server /opt/redis/redis.conf
/opt/redis/src/redis-server /opt/redis/redis.conf2
#使用密码进行集群检查
/opt/redis/src/redis-cli --cluster check 192.168.1.21:6379 -a Diablo@2025
#验证密码登录
/opt/redis/src/redis-cli -h 192.168.1.20 -p 6379 -c -a Diablo@2025
1282

被折叠的 条评论
为什么被折叠?



