Environmental Science
Operating system: CentOS 7.3
Redis version: Redis 3.2.8
Two hosts, three nodes on each host
Basic steps
Download and unzip the installation package
# Download and unzip the installation package
wget http://download.redis.io/releases/redis-3.2.8.tar.gz
tar -zxvf redis-3.2.8.tar.gz
Build install
# Normal compilation and installation
make && make install
# If gcc is not installed, install gcc
yum install gcc
# If the jemalloc memory allocator is not installed, compile the installation using the following command
make MALLOC=libc && make install
Create corresponding directory and write configuration file
The following directory is used for this construction:
- Log directory / opt/redis/logs
- Data directory / opt/redis/db
- Cluster file directory: / opt / redis / cluster conf / port, such as: / opt / redis / cluster conf / 7001
Profile: Simple profile , pay attention to modify the IP and port of each node.
Start each node
# Start each node
cd /opt/redis/src
./redis-server ../cluster-conf/7001/redis.conf
./redis-server ../cluster-conf/7002/redis.conf
./redis-server ../cluster-conf/7003/redis.conf
./redis-server ../cluster-conf/7004/redis.conf
./redis-server ../cluster-conf/7005/redis.conf
./redis-server ../cluster-conf/7006/redis.conf
Create cluster
# Install ruby
yum -y install ruby ruby-devel rubygems rpm-build
# Install the redis package (specify the corresponding version number, https://rubygems.org/gems/redis)
gem install redis -v 3.3.0
# Create cluster
./redis-trib.rb create --replicas 1 192.168.192.128:7001 192.168.192.128:7002 192.168.192.128:7003 192.168.192.129:7004 192.168.192.129:7005 192.168.192.129:7006
- When using RubyGems to install Redis package, you need to indicate the version number, otherwise the latest version will be installed. Because the default version of Ruby for this version of CentOS is 2.0, the latest Redis package needs to be upgraded to the Ruby version before installation.
Simple profile
################################## INCLUDES ###################################
################################## NETWORK #####################################
bind 192.168.192.128
protected-mode yes
port 7001
tcp-backlog 511
timeout 0
tcp-keepalive 300
################################# GENERAL #####################################
daemonize yes
supervised no
pidfile /var/run/redis_7001.pid
loglevel notice
logfile "/opt/redis/logs/redis_7001.log"
databases 16
################################ SNAPSHOTTING ################################
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /opt/redis/db
################################# REPLICATION #################################
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
################################## SECURITY ###################################
################################### LIMITS ####################################
############################## APPEND ONLY MODE ###############################
appendonly yes
appendfilename "appendonly_7001.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
################################ LUA SCRIPTING ###############################
lua-time-limit 5000
################################ REDIS CLUSTER ###############################
cluster-enabled yes
cluster-config-file nodes-7001.conf
cluster-node-timeout 15000
################################## SLOW LOG ###################################
slowlog-log-slower-than 10000
slowlog-max-len 128
################################ LATENCY MONITOR ##############################
latency-monitor-threshold 0
############################# EVENT NOTIFICATION ##############################
notify-keyspace-events ""
############################### ADVANCED CONFIG ###############################
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