Redis伪集群部署手册

文章详细描述了在Linux环境中安装和配置Redis集群的步骤,包括检查编译环境、解压安装Redis、创建目录、修改配置文件、编写启动脚本以及启动Redis服务。在过程中遇到GCC版本过低的问题,通过安装devtoolset-9来升级GCC到更高版本。
摘要由CSDN通过智能技术生成

一、查检系统编译环境

yum install gcc make
rpm -qa gcc make 
make-3.82-23.el7.x86_64
gcc-4.8.5-36.el7.x86_64

二、解压软件包与安装

mkdir /usr/local/redis-cluster
tar -xvf redis-6.2.5.tar.gz -C /usr/local/redis-cluster
cd /usr/local/redis-cluster/redis-6.2.5
make

三、文件和目录准备

cd /usr/local/redis-cluster
mkdir 6380 6381 6382 6383 6384 6385	#启6个redis,组成一个redis集群
ls
#将redis-cli  redis.conf  redis-server文件放到redis-cluster目录下,便于使用
redis-cli  redis.conf  redis-server

四、修改redis.conf参数,并放到6个创建的目录中

tree 6380 6381 6382 6383 6384 6385 
6380
└── redis.conf
6381
└── redis.conf
6382
└── redis.conf
6383
└── redis.conf
6384
└── redis.conf
6385
└── redis.conf
#redis.conf
bind 10.133.0.243 127.0.0.1
protected-mode yes
port 6380
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /opt/redis-cluster/9001/redis.pid
loglevel notice
logfile /opt/redis-cluster/9001/redis.log
databases 16
save 900 10
save 300 100
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /opt/redis-cluster/9001
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
repl-backlog-size 209715200
slave-priority 100
requirepass !@#QWEasd
masterauth !@#QWEasd
rename-command CONFIG "GJZ_CONFIG"
rename-command FLUSHALL "GJZ_FLUSHALL"
rename-command FLUSHDB "GJZ_FLUSHDB"
rename-command SHUTDOWN "GJZ_SHUTDOWN"
maxclients 10000
maxmemory 10737418240
maxmemory-policy allkeys-lru
maxmemory-samples 5
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 200
auto-aof-rewrite-min-size 1073741824
aof-load-truncated yes
lua-time-limit 5000
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 15000
cluster-slave-validity-factor 10
cluster-migration-barrier 1
cluster-require-full-coverage yes
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
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

五、编写启动脚本

useradd redis -s /sbin/nologin
cd /usr/local/redis-cluster  && cat restart.sh
#!/bin/bash
echo "stop cluster......"
/bin/pkill -9 redis
echo "start all nodes......"
/usr/local/redis-cluster/redis-server /usr/local/redis-cluster/6380/redis.conf
/usr/local/redis-cluster/redis-server /usr/local/redis-cluster/6381/redis.conf
/usr/local/redis-cluster/redis-server /usr/local/redis-cluster/6382/redis.conf
/usr/local/redis-cluster/redis-server /usr/local/redis-cluster/6383/redis.conf
/usr/local/redis-cluster/redis-server /usr/local/redis-cluster/6384/redis.conf
/usr/local/redis-cluster/redis-server /usr/local/redis-cluster/6385/redis.conf
ps -ef |grep redis
echo "OK."

六、启动Redis

cd /usr/local/redis-cluster  && chmod 755  restart.sh
./restart.sh

七、创建集群

#redis-6创建集群方法
cd /usr/local/redis-cluster 
./redis-cli --cluster-replicas 1 --cluster create 10.133.0.243:6380 10.133.0.243:6381 10.133.0.243:6382 10.133.0.243:6383 10.133.0.243:6384 10.133.0.243:6385 -a !@#QWEasd

报错-升级gcc版本(yum安装的gcc是4.8.5的。因此需要升级gcc,升级过程如下)

yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile
gcc -v
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

gswcfl

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值