mkdir /usr/local/redis-cluster/{7000,7001}/data -pv
cp redis.conf /usr/local/redis-cluster/7000/
[root@redis-cs-node01 redis-cluster]# grep "^[a-Z]" 7000/redis.conf
bind 0.0.0.0
protected-mode yes
port 7000
tcp-backlog 511
timeout 0
tcp-keepalive 30
daemonize yes
supervised no
pidfile /var/run/redis_7000.pid
loglevel notice
logfile "/usr/local/redis-cluster/7000/redis.log"
databases 16
always-show-logo yes
save ""
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /usr/local/redis-cluster/7000/data
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
maxclients 10000
maxmemory 3g
maxmemory-policy allkeys-lru
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
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-7000.conf
cluster-node-timeout 5000
cluster-require-full-coverage no
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
#修改配置信息
cp 7000/redis.conf 7001/
sed -i 's/7000/7001/g' 7001/redis.conf
#同理另外两台节点同理
mkdir /usr/local/redis-cluster/{7002,7003}/data -pv
sed -i 's/7000/7001/g' 7002/redis.conf
sed -i 's/7000/7001/g' 7003/redis.conf
mkdir /usr/local/redis-cluster/{7004,7005}/data -pv
sed -i 's/7000/7004/g' 7004/redis.conf
sed -i 's/7000/7005/g' 7005/redis.conf
创建启动脚本及开启启动
#第一个节点
[root@redis-cs-node01 redis-cluster]# cat start_redis_cluster.sh
#!/bin/bash
cd /usr/local/redis-cluster
cd 7000 && /usr/bin/redis-server /usr/local/redis-cluster/7000/redis.conf
cd ../7001 &&/usr/bin/redis-server /usr/local/redis-cluster/7001/redis.conf
#第二个节点
[root@redis-cs-node02 redis-cluster]# cat start_redis_cluster.sh
#!/bin/bash
cd /usr/local/redis-cluster
cd 7002 && /usr/bin/redis-server /usr/local/redis-cluster/7002/redis.conf
cd ../7003 &&/usr/bin/redis-server /usr/local/redis-cluster/7003/redis.conf
#第三个节点
[root@redis-cs-node03 redis-cluster]# cat start_redis_cluster.sh
#!/bin/bash
cd /usr/local/redis-cluster
cd 7004 && /usr/bin/redis-server /usr/local/redis-cluster/7004/redis.conf
cd ../7005 &&/usr/bin/redis-server /usr/local/redis-cluster/7005/redis.conf
#启动节点
[root@redis-cs-node01 redis-cluster]# sh start_redis_cluster.sh
[root@redis-cs-node02 redis-cluster]# sh start_redis_cluster.sh
[root@redis-cs-node03 redis-cluster]# sh start_redis_cluster.sh
#配置开机启动
[root@redis-cs-node01 redis-cluster]# cat /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
echo never > /sys/kernel/mm/transparent_hugepage/enabled
/usr/bin/sh /usr/local/redis-cluster/start_redis_cluster.sh
/usr/bin/sh /usr/local/redis-cluster/start_exporter.sh