Redis-Shake分享

1.启动两套Redis-使用自带的工具创建集群。

./redis-6.0.6/utils/create-cluster/create-cluster     文件内容为

#!/bin/bash

# Settings
BIN_PATH="../../src/"
CLUSTER_HOST=192.168.10.10
PORT=30000
TIMEOUT=2000
NODES=6
REPLICAS=1
PROTECTED_MODE=yes
ADDITIONAL_OPTIONS=""
PASSWORD="123456"

# You may want to put the above config parameters into config.sh in order to
# override the defaults without modifying this script.

if [ -a config.sh ]
then
    source "config.sh"
fi

# Computed vars
ENDPORT=$((PORT+NODES))

if [ "$1" == "start" ]
then
    while [ $((PORT < ENDPORT)) != "0" ]; do
        PORT=$((PORT+1))
        echo "Starting $PORT"
        $BIN_PATH/redis-server --requirepass ${PASSWORD} --masterauth ${PASSWORD}  --port $PORT  --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --dbfilename dump-${PORT}.rdb  --save 900 1 --save 300 10 --save 60 10000 --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS}
    done
    exit 0
fi

if [ "$1" == "create" ]
then
    HOSTS=""
    while [ $((PORT < ENDPORT)) != "0" ]; do
        PORT=$((PORT+1))
        HOSTS="$HOSTS $CLUSTER_HOST:$PORT"
    done
    $BIN_PATH/redis-cli --cluster create $HOSTS -a ${PASSWORD} --cluster-replicas $REPLICAS
    exit 0
fi

if [ "$1" == "stop" ]
then
    while [ $((PORT < ENDPORT)) != "0" ]; do
        PORT=$((PORT+1))
        echo "Stopping $PORT"
        $BIN_PATH/redis-cli -p $PORT -a ${PASSWORD}  shutdown nosave
    done
    exit 0
fi

if [ "$1" == "watch" ]
then
    PORT=$((PORT+1))
    while [ 1 ]; do
        clear
        date
        $BIN_PATH/redis-cli  -a ${PASSWORD} -p $PORT cluster nodes | head -30
        sleep 1
    done
    exit 0
fi

if [ "$1" == "tail" ]
then
    INSTANCE=$2
    PORT=$((PORT+INSTANCE))
    tail -f ${PORT}.log
    exit 0
fi

if [ "$1" == "tailall" ]
then
    tail -f *.log
    exit 0
fi

if [ "$1" == "call" ]
then
    while [ $((PORT < ENDPORT)) != "0" ]; do
        PORT=$((PORT+1))
        $BIN_PATH/redis-cli -a ${PASSWORD} -p $PORT $2 $3 $4 $5 $6 $7 $8 $9
    done
    exit 0
fi

if [ "$1" == "clean" ]
then
    rm -rf *.log
    rm -rf appendonly*.aof
    rm -rf dump*.rdb
    rm -rf nodes*.conf
    exit 0
fi

if [ "$1" == "clean-logs" ]
then
    rm -rf *.log
    exit 0
fi

echo "Usage: $0 [start|create|stop|watch|tail|clean|call]"
echo "start       -- Launch Redis Cluster instances."
echo "create      -- Create a cluster using redis-cli --cluster create."
echo "stop        -- Stop Redis Cluster instances."
echo "watch       -- Show CLUSTER NODES output (first 30 lines) of first node."
echo "tail <id>   -- Run tail -f of instance at base port + ID."
echo "tailall     -- Run tail -f for all the log files at once."
echo "clean       -- Remove all instances data, logs, configs."
echo "clean-logs  -- Remove just instances logs."
echo "call <cmd>  -- Call a command (up to 7 arguments) on all nodes."

以上可以快速搭建redis集群

2.部署Redis-Shake

2.1Github下载即可
2.2部署GO环境。

2.3参考-安装部署

https://tair-opensource.github.io/RedisShake/zh/guide/introduction.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Redis-shake是一款基于Go语言开发的Redis数据迁移工具。它能够在不停机的情况下将Redis数据从一个节点迁移到另一个节点,支持集群、单机以及主从架构的数据迁移。Redis-shake具有以下特点。 1. 快速高效:Redis-shake使用并行化的方式进行数据迁移,能够充分利用多核处理器和带宽资源,提供高性能的数据迁移速度。 2. 稳定可靠:Redis-shake经过了大规模的生产环境验证,已经得到了广泛的应用。它具备重试机制,能够自动处理网络中断等异常情况,保证数据迁移的稳定性和可靠性。 3. 灵活易用:Redis-shake支持多种数据源和数据目标的组合。它可以从Redis节点迁移到另一个Redis节点,也可以将数据迁移到其他存储系统,如MySQL、MongoDB等。同时,Redis-shake提供了丰富的配置选项,可以根据需要进行灵活配置和定制。 4. 兼容支持:Redis-shake能够兼容不同版本的Redis,包括Redis 2.x和Redis 3.x等。它支持迁移过程中的数据过滤、数据分片、数据压缩等功能,可以满足不同场景下的需求。 5. 开源免费:Redis-shake是一款开源工具,遵循Apache 2.0协议。它的源代码可以在GitHub上获取,用户可以基于其代码进行定制和扩展,且使用过程中没有任何费用。 总之,Redis-shake是一款强大且灵活的Redis数据迁移工具,通过它我们可以轻松实现Redis数据的迁移和备份等操作,同时保证数据的一致性和可靠性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值