美文网首页
本地构建一个Redis Cluster调试集群

本地构建一个Redis Cluster调试集群

作者: 若罗 | 来源:发表于2020-12-24 11:35 被阅读0次

    有时候,我们需要调试redis cluster的一些功能,我们需要在本地搭建
    首先,先本地安装一个Redis,并且搞一个配置文件如下
    命名为redis.conf,把它放在某个目录(比如说~/rc)的下面

    bind 0.0.0.0
    protected-mode yes
    port 6380
    tcp-backlog 511
    timeout 0
    tcp-keepalive 300
    daemonize yes
    supervised no
    pidfile /var/run/redis_6380.pid
    loglevel notice
    logfile "logs/redis_6380.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 data/6380
    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
    requirepass Su1m2Ab&kPB0J#
    masterauth Su1m2Ab&kPB0J#
    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
    aof-use-rdb-preamble yes
    lua-time-limit 5000
    cluster-enabled yes
    cluster-config-file nodes-6380.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-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
    

    来到这个目录下面,搞点事情

    if [ ! -d "data" ]; then mkdir data;fi;if [ ! -d "conf" ]; then mkdir conf;fi;if [ ! -d "logs" ]; then  mkdir logs; fi;for i in `seq 6380 6385`;do mkdir data/$i;cp -rvf redis.conf conf/redis_$i.conf;sed -i "s@6380@$i@g" conf/redis_$i.conf;redis5-server conf/redis_$i.conf;done
    

    这个命令如果也可以写一个shell脚本

    if [ ! -d "data" ]; then
            mkdir data;
    fi;
    if [ ! -d "conf" ]; then
            mkdir conf;
    fi;
    if [ ! -d "logs" ]; then
            mkdir logs;
    fi;
    for i in `seq 6380 6385`;
    do 
    mkdir data/$i;
    cp -rvf redis.conf conf/redis_$i.conf;
    sed -i "s@6380@$i@g" conf/redis_$i.conf;
    redis5-server conf/redis_$i.conf;
    done
    

    这样我们瞬间启动了六个redis,现在来把她们加入集群把

    redis5-cli -a 'Su1m2Ab&kPB0J#' --cluster create 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382 127.0.0.1:6383 127.0.0.1:6384 127.0.0.1:6385 --cluster-replicas 1
    

    相关文章

      网友评论

          本文标题:本地构建一个Redis Cluster调试集群

          本文链接:https://www.haomeiwen.com/subject/uqapnktx.html