redis5安装说明

2022-10-27 13:35:19 浏览数 (2)

# 离线安装redis5.0.8

安装包含脚本链接 (提取码:1314)

# 用法说明

  1. 解压命令:unzip redis.zip -d /home/summer &>/dev/null
  2. cd /home/summer/redis-5.0.8/utils/create-cluster
  3. 执行启动命令:./create-cluster start
  4. 停止命令:./create-cluster stop
  5. 清理命令(重启时用):./create-cluster clean
  6. 默认密码:summerking
  7. 默认启动27000和27001两个端口

# 启动脚本

代码语言:javascript复制
#!/bin/bash

# Settings
PORT=26999
TIMEOUT=2000
NODES=2
REPLICAS=1
reids_pwd=summerking
ip=$(ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:")

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

if [ "$1" == "start" ]
then
    while [ $((PORT < ENDPORT)) != "0" ]; do
        PORT=$((PORT 1))
        echo "Starting $PORT"
        /home/summer/redis-5.0.8/src/redis-server --port $PORT --bind $ip --masterauth $reids_pwd --requirepass $reids_pwd --protected-mode no --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes
    done

    exit 0
fi

if [ "$1" == "stop" ]
then
    while [ $((PORT < ENDPORT)) != "0" ]; do
        PORT=$((PORT 1))
        echo "Stopping $PORT"
        /home/summer/redis-5.0.8/src/redis-cli -a $reids_pwd -h $ip -p $PORT shutdown nosave
    done
    kill -9 $(ps -ef | grep redis | grep -v grep | awk '{print $2}')
    exit 0
fi

if [ "$1" == "clean" ]
then
    cd /home/summer/redis-5.0.8/utils/create-cluster
    rm -rf *.log
    rm -rf appendonly*.aof 
    rm -rf dump*.rdb
    rm -rf nodes*.conf
    exit 0
fi

0 人点赞