1 redis集群配置模板
vi /opt/cachecloud/conf/redis-cluster-template.conf
daemonize yes
tcp-backlog 511
timeout 0
tcp-keepalive 60
loglevel notice
databases 16
dir /opt/cachecloud/data
stop-writes-on-bgsave-error no
repl-timeout 60
repl-ping-slave-period 10
repl-disable-tcp-nodelay no
repl-backlog-size 10Mb
repl-backlog-ttl 7200
slave-serve-stale-data yes
slave-read-only yes
slave-priority 100
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 512mb 128mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
port {:port}
maxmemory {:maxmemory}mb
maxmemory-policy allkeys-lru
appendonly no
appendfsync everysec
appendfilename appendonly-{:port}.aof
dbfilename dump-{:port}.rdb
aof-rewrite-incremental-fsync yes
no-appendfsync-on-rewrite yes
auto-aof-rewrite-min-size 4000000kb
auto-aof-rewrite-percentage 88
rdbcompression yes
rdbchecksum yes
repl-diskless-sync no
repl-diskless-sync-delay 5
maxclients 10000
hll-sparse-max-bytes 3000
min-slaves-to-write 0
min-slaves-max-lag 10
aof-load-truncated yes
notify-keyspace-events ""
protected-mode no
cluster-enabled yes
cluster-node-timeout 15000
cluster-slave-validity-factor 10
cluster-migration-barrier 1
cluster-config-file nodes-{:port}.conf
cluster-require-full-coverage no
2 一键配置脚本
vi redisCluster.sh
CONF_DIR="/opt/cachecloud/conf/";
LOG_DIR="/opt/cachecloud/logs/";
REDIS_SRC_DIR="/opt/cachecloud/redis/src/";
REDIS_CLUSTER_TEMPLATE="/opt/cachecloud/conf/redis-cluster-template.conf"
SLOT_SIZE=16384
PORTS=(6961 6962 6963 6964 6965 6966)
MAX_MEMORY=100
function _createConfigFile()
{
local isAllExists=1
local i=0
local port=0
local configFile=''
for(( i=0;i<${#PORTS[@]};i++))
do
port=${PORTS[i]}
configFile=$CONF_DIR"redis-cluster-"$port".conf"
if [ ! -f $configFile ]; then
isAllExists=0
break
fi
done
if [ $isAllExists -eq 1 ];then
return 0
fi
for(( i=0;i<${#PORTS[@]};i++))
do
port=${PORTS[i]}
configFile=$CONF_DIR"redis-cluster-"$port".conf"
cp $REDIS_CLUSTER_TEMPLATE $configFile -f
sed -i 's/{:port}/'$port'/g' $configFile
sed -i 's/{:maxmemory}/'$MAX_MEMORY'/g' $configFile
done
}