redis的cluster集群模式shell一键启动/停止/重启/清缓存脚本

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
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值