Step‑by‑Step Guide to Deploy a Redis Cluster on Linux
This tutorial walks you through compiling Redis from source, configuring six cluster nodes on ports 7000‑7005, adjusting system memory settings, creating startup scripts, launching the services, forming the cluster, verifying its status, and testing basic read/write operations, all with detailed command examples.
Redis Cluster Deployment
1. Compile and install Redis 5.0.0 from source.
# cd /usr/local/src/
# wget http://download.redis.io/releases/redis-5.0.0.tar.gz
# tar zxvf redis-5.0.0.tar.gz
# apt-get update && apt-get install -y gcc automake make
# cd redis-5.0.0 && make && make install
# cp ./src/redis-server /usr/bin/
# cp ./src/redis-cli /usr/bin/2. Create an init script (optional) and start the service.
# cp ./utils/redis_init_script /etc/init.d/redisd
# service redisd start3. Create directories and copy a base configuration file for each node (ports 7000‑7005).
# mkdir -p /tmp/redis-cluster/{7000,7001,7002,7003,7004,7005}/log
# cp /usr/local/src/redis-5.0.0/redis.conf /data/redis-cluster/7000/redis.conf
# cd /data/redis-cluster/ && cat 7000/redis.conf
bind 0.0.0.0
protected-mode yes
port 7000
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_7000.pid
loglevel notice
logfile "/data/redis-cluster/7000/log/redis-7000.log"
Databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
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
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
appendonly yes
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
use-rdb-preamble yes
lua-time-limit 5000
cluster-enabled yes
cluster-config-file nodes.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-max-ziplist-value 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
masterauth AuDdQdpuEZpXgNthP6CjYjPb
requirepass AuDdQdpuEZpXgNthP6CjYjPb4. Adjust kernel memory overcommit settings and apply them.
# echo "vm.overcommit_memory=1" >> /etc/sysctl.conf
# sysctl -p5. Create a startup script to launch all six nodes.
# cat start-redis-cluster.sh
#!/bin/bash
cd /data/redis-cluster
cd 7000 && /usr/bin/redis-server /data/redis-cluster/7000/redis.conf
cd ../7001 && /usr/bin/redis-server /data/redis-cluster/7001/redis.conf
cd ../7002 && /usr/bin/redis-server /data/redis-cluster/7002/redis.conf
cd ../7003 && /usr/bin/redis-server /data/redis-cluster/7003/redis.conf
cd ../7004 && /usr/bin/redis-server /data/redis-cluster/7004/redis.conf
cd ../7005 && /usr/bin/redis-server /data/redis-cluster/7005/redis.conf6. Start the cluster services.
# bash start-redis-cluster.sh
# ps -ef|grep redis7. Create the cluster with six nodes and one replica per master.
# redis-cli --cluster create 10.20.71.215:7000 10.20.73.204:7001 10.20.71.67:7002 10.20.71.215:7003 10.20.73.204:7004 10.20.71.67:7005 --cluster-replicas 1 -a AuDdQdpuEZpXgNthP6CjYjPb8. Verify cluster information.
# redis-cli -c -p 7000
127.0.0.1:7000> auth AuDdQdpuEZpXgNthP6CjYjPb
OK
127.0.0.1:7000> cluster nodes
... (output showing three masters and three slaves) ...9. Test data operations.
# redis-cli -h 10.20.73.204 -p 7001 -a AuDdQdpuEZpXgNthP6CjYjPb
127.0.0.1:7001> set name shuke
OK
127.0.0.1:7001> get name
"shuke"10. Persist the cluster configuration to disk.
# redis-cli -p 7009 cluster saveconfig
OKTips: If you need to recreate the cluster, log into each node, run flushdb , then cluster reset , and restart the node.
Cluster management commands and common operations are covered throughout the guide.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
