菜单形式部署redis 集群的脚本

为减轻Linux运维工作中重复执行的工作量,降低出错概率;同时保证脚本能应用在不同的场合以及其灵活性,特地编写此脚本,仅供参考!

?
#!/bin/bash
#
#Author: fanfubin
#QQ: 502422514
#Date: 2019-03-19
#FileName: redis.sh
#Description: The deploy redis script
#Copyright (C): 2019 All rights reserved
#

source /etc/init.d/functions

BLACK_COLOR=‘\E[1;30m‘
RED_COLOR=‘\E[1;31m‘
GREEN_COLOR=‘\E[1;32m‘
YELLOW_COLOR=‘\E[1;33m‘
BLUE_COLOR=‘\E[1;34m‘
PINK_COLOR=‘\E[1;35m‘ #紫色
SKYBLUE_COLOR=‘\E[1;36m‘ #天蓝色
WHITE_COLOR=‘\E[1;37m‘ #白色       

SHAN=‘\E[31;5m‘ #字体闪烁
RES=‘\E[0m‘

cpu_count=`lscpu|awk -F ‘ +‘ ‘/^CPU\(s\):/{print $2}‘`
if [ $cpu_count -le 2 ];then
    export cpu_num="1"
else
    let cpu_num=`lscpu|awk -F ‘ +‘ ‘/^CPU\(s\):/{print $2}‘`-1
    export cpu_num
fi

export httpd_user="nginx"
export httpd_group="nginx"
export httpd_id="2000"
export redis_×××tall_ver="redis-4.0.14.tar.gz"
export master_default_passwd="123456"
export ruby_×××tall_ver="ruby-2.5.5.tar.gz"
export redis_gem_×××tall_ver="redis-4.1.2.gem"

f_main_title() {
        f_color green "`echo -e "\t服务器监控系统"`"
}

f_color() {
    case "$1" in
        black)
            echo -e "${PINK_COLOR}$2 ${RES}"
            ;;
        red)
            echo -e "${RED_COLOR}$2 ${RES}"
            ;;
        green)
            echo -e "${GREEN_COLOR}$2 ${RES}"
            ;;
        yellow)
            echo -e "${YELLOW_COLOR}$2 ${RES}"
            ;;
        blue)
            echo -e "${BLUE_COLOR}$2 ${RES}"
            ;;
        skyblue)
            echo -e "${PINK_COLOR}$2 ${RES}"
            ;;
        pink)
            echo -e "${PINK_COLOR}$2 ${RES}"
            ;;
        white)
            echo -e "${PINK_COLOR}$2 ${RES}"
            ;;
        shan)
            echo -e "${SHAN}$2 ${RES}"
            ;;
        *)
            exit
            ;;
    esac
}

##创建通用的用户名和id(user:nginx  id:2000)
id $httpd_user
        if [ `echo $?` -ne 0 ];then
                useradd -s /sbin/nologin -M -u $httpd_id $httpd_user
        else
             test_httpd_id=`id $httpd_user | awk -F ‘[=(]‘ ‘{print $2}‘`
             test_httpd_gid=`id $httpd_user | awk -F ‘[=(]‘ ‘{print $4}‘`
             if [ $test_httpd_id -ne $httpd_id -o $test_httpd_gid -ne $httpd_id ];then
                     userdel -r $httpd_id
                     useradd -s /sbin/nologin -M -u $httpd_id $httpd_user
             fi
        fi

f_menu_×××tall_server_redis_list() {
    local path
    local redis_×××tall_dir
    local num
    local choose_num
    local passwd_choose_num
    local locate_server_num
    local find_server_num
    local new_master_passwd
    local master_passwd
    local redis_gem_×××tall_dir
    local gem_passwd

    echo
    f_main_title
    echo "=================================="
    cat <<-EOF
    【1. 】 Show ×××tall redis version
    【2. 】 Source ×××tall redis && cluster
    【3. 】 Show ×××tall ruby && gem version
    【4. 】 Source ×××tall ruby && gem
    【0. 】 Exit

    EOF
    echo "=================================="

    read -p "Pls input a num:" num
    f_is_num $num
    [ $? -eq 1 ] || { action "Pls input valid num!" false ; f_menu_×××tall_server_redis_list;}

    case "$num" in
        1)
            echo
            echo -e "\t$redis_×××tall_ver"
            f_menu_×××tall_server_redis_list
            ;;
        ###################################################### ×××tall redis && cluster
        2)
            echo
            #redis  .tar. is exist?
            yum -y ×××tall mlocate &> /dev/null
            updatedb &> /dev/null
            locate_server_num=`locate ${redis_×××tall_ver}| wc -l`
            if [ ! -e $redis_×××tall_ver ];then
                if [ $locate_server_num -eq 1 ];then
                    \cp `locate ${redis_×××tall_ver}` . -a
                elif [ $locate_server_num -ge 2 ];then
                    \cp `locate ${redis_×××tall_ver} | head -n1` . -a
                else
                    find_server_num=`find / -name ${redis_×××tall_ver}| wc -l`
                    if [ $find_server_num -eq 1 ];then
                        \cp `find / -name ${redis_×××tall_ver}` . -a
                    elif [ $find_server_num -ge 2 ];then
                        \cp `find / -name ${redis_×××tall_ver} | head -n1` . -a
                    else
                        f_color red "`echo "${redis_×××tall_ver} is not exist!"`"
                        f_menu_×××tall_server_redis_list
                    fi
                fi
            fi

            redis_×××tall_dir=`echo $redis_×××tall_ver | awk -F ‘.tar.‘ ‘{print $1}‘`

            read -p "Pls input 1-×××tall or 2-quit : " choose_num
            f_is_num $choose_num
            [ $? -eq 1 ] || { action "Pls input valid num!" false ; f_menu_×××tall_server_redis_list;}

            case "$choose_num" in
                1)
                    echo
                    yum -y ×××tall gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel &> /dev/null

                    read -p "Whether use default masterauth=requirepass  1-yes or 2-no : " passwd_choose_num
                    f_is_num $passwd_choose_num
                    [ $? -eq 1 ] || { action "Pls input valid num!" false ; f_menu_×××tall_server_redis_list;}
                    case $passwd_choose_num in
                        1)
                            new_master_passwd=$master_default_passwd
                            f_color shan "`echo "Default masterauth=password is: $new_master_passwd "`"
                            ;;
                        2)
                            while true
                            do
                                read -p "Pls input masterauth=requirepass password: " master_passwd
                                if [ -z "$master_passwd" ];then
                                    f_color red "`echo "password can not be empty !"`"
                                else
                                    new_master_passwd=$master_passwd
                                    f_color shan "`echo "Masterauth=requirepass password is: $new_master_passwd "`"
                                    break
                                fi
                            done
                            ;;
                        *)
                            f_menu_×××tall_server_redis_list
                    esac

                    read -p "Pls input ×××tall Path or null: " path

                    if [ -z "$path" ];then
                        \rm -rf $redis_×××tall_dir
                        tar xf $redis_×××tall_ver
                        cd $redis_×××tall_dir
                        make PREFIX=/apps/$redis_×××tall_dir ×××tall
                        mkdir -p /apps/$redis_×××tall_dir/{etc,logs,data,run}
                        \cp redis.conf /apps/$redis_×××tall_dir/etc
                        \cp src/redis-trib.rb /usr/bin/
                        sed -ri ‘s/bind 127.0.0.1/bind 0.0.0.0/‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s/daemonize no/daemonize yes/‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s/supervised no/supervised systemd/‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s#/var/run/redis_6379.pid#/apps/‘$redis_×××tall_dir‘/run/redis_6379.pid#‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sleep 0.5
                        sed -ri ‘s#logfile ""#logfile "/apps/‘$redis_×××tall_dir‘/logs/redis_6379.log"#‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s/stop-writes-on-bgsave-error yes/stop-writes-on-bgsave-error no/‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s#dbfilename dump.rdb#dbfilename dump_6379.rdb#‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s#dir \./#dir /apps/‘$redis_×××tall_dir‘/data#‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s/# masterauth <master-password>/masterauth "‘$new_master_passwd‘"/‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sleep 0.5
                        sed -ri ‘s/# requirepass foobared/requirepass ‘$new_master_passwd‘/‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s/# maxclients 10000/maxclients 65536/‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s/appendonly no/appendonly yes/‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s/appendfilename "appendonly.aof"/appendfilename "appendonly_6379.aof"/‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sleep 0.5
                        ##cluster
                        sed -ri ‘s/# cluster-enabled yes/ cluster-enabled yes/‘ /apps/$redis_×××tall_dir/etc/redis.conf
                        sed -ri ‘s/# cluster-config-file nodes-6379.conf/ cluster-config-file nodes-6379.conf/‘ /apps/$redis_×××tall_dir/etc/redis.conf

                        total_mem=`free -m | grep ‘Mem‘ |awk ‘{print $2}‘`
                        let mem_result=$total_mem/2*1024*1024
                        sed -ri ‘s/# maxmemory <bytes>/maxmemory ‘$mem_result‘/‘ /apps/$redis_×××tall_dir/etc/redis.conf

                        ln -s /apps/$redis_×××tall_dir/bin/* /usr/bin/
                        sleep 1
                        cat >/usr/lib/systemd/system/redis.service<<-EOF
                            [Unit]
                            Description=Redis persistent key-value database
                            After=network.target
                            After=network-online.target
                            Wants=network-online.target

                            [Service]
                            ExecStart=/apps/$redis_×××tall_dir/bin/redis-server /apps/$redis_×××tall_dir/etc/redis.conf --supervised systemd
                            ExecReload=/bin/kill -s HUP \$MAINPID
                            ExecStop=/bin/kill -s QUIT \$MAINPID
                            Type=notify
                            #User=$httpd_user
                            #Group=$httpd_user
                            User=root
                            Group=root
                            RuntimeDirectory=redis
                            RuntimeDirectoryMode=0755

                            [Install]
                            WantedBy=multi-user.target
                        EOF

                        #chown -R ${httpd_user}.${httpd_user} /apps/$redis_×××tall_dir
                        cat >>/etc/sysctl.conf<<-EOF
                            net.core.somaxconn = 512
                            vm.overcommit_memory = 1
                        EOF
                        sysctl -p
                        sleep 1
                        cat >>/etc/rc.d/rc.local<<-EOF
                            echo never > /sys/kernel/mm/transparent_hugepage/enabled
                        EOF
                        chmod a+x /etc/rc.d/rc.local
                        systemctl daemon-reload
                        sleep 1
                        systemctl start redis
                        cd -

                        f_color shan "`echo "redis ×××tall path is: /apps/${redis_×××tall_dir}"`"

                    else
                        \rm -rf $redis_×××tall_dir
                        tar xf $redis_×××tall_ver
                        cd $redis_×××tall_dir
                        make PREFIX=$path ×××tall
                        mkdir -p ${path}/{etc,logs,data,run}
                        \cp redis.conf ${path}/etc
                        \cp src/redis-trib.rb /usr/bin/
                        sed -ri ‘s/bind 127.0.0.1/bind 0.0.0.0/‘ $path/etc/redis.conf
                        sed -ri ‘s/daemonize no/daemonize yes/‘ $path/etc/redis.conf
                        sed -ri ‘s/supervised no/supervised systemd/‘ $path/etc/redis.conf
                        sed -ri ‘s#/var/run/redis_6379.pid#/apps/‘$redis_×××tall_dir‘/run/redis_6379.pid#‘ $path/etc/redis.conf
                        sleep 0.5
                        sed -ri ‘s#logfile ""#logfile "/apps/‘$redis_×××tall_dir‘/logs/redis_6379.log"#‘ $path/etc/redis.conf
                        sed -ri ‘s/stop-writes-on-bgsave-error yes/stop-writes-on-bgsave-error no/‘ $path/etc/redis.conf
                        sed -ri ‘s#dbfilename dump.rdb#dbfilename dump_6379.rdb#‘ $path/etc/redis.conf
                        sed -ri ‘s#dir \./#dir /apps/‘$redis_×××tall_dir‘/data#‘ $path/etc/redis.conf
                        sed -ri ‘s/# masterauth <master-password>/masterauth "‘$new_master_passwd‘"/‘ $path/etc/redis.conf
                        sleep 0.5
                        sed -ri ‘s/# requirepass foobared/# requirepass ‘$new_master_passwd‘/‘ $path/etc/redis.conf
                        sed -ri ‘s/# maxclients 10000/maxclients 65536/‘ $path/etc/redis.conf
                        sed -ri ‘s/appendonly no/appendonly yes/‘ $path/etc/redis.conf
                        sed -ri ‘s/appendfilename "appendonly.aof"/appendfilename "appendonly_6379.aof"/‘ $path/etc/redis.conf
                        sleep 0.5
                        ##cluster
                        sed -ri ‘s/# cluster-enabled yes/ cluster-enabled yes/‘ $path/etc/redis.conf
                        sed -ri ‘s/# cluster-config-file nodes-6379.conf/ cluster-config-file nodes-6379.conf/‘ $path/etc/redis.conf

                        total_mem=`free -m | grep ‘Mem‘ |awk ‘{print $2}‘`
                        let mem_result=$total_mem/2*1024*1024
                        sed -ri ‘s/# maxmemory <bytes>/maxmemory ‘$mem_result‘/‘ $path/etc/redis.conf

                        ln -s ${path}/bin/* /usr/bin/
                        sleep 1
                        cat >/usr/lib/systemd/system/redis.service<<-EOF
                            [Unit]
                            Description=Redis persistent key-value database
                            After=network.target
                            After=network-online.target
                            Wants=network-online.target

                            [Service]
                            ExecStart=${path}/bin/redis-server ${path}/etc/redis.conf --supervised systemd
                            ExecReload=/bin/kill -s HUP \$MAINPID
                            ExecStop=/bin/kill -s QUIT \$MAINPID
                            Type=notify
                            #User=$httpd_user
                            #Group=$httpd_user
                            User=root
                            Group=root
                            RuntimeDirectory=redis
                            RuntimeDirectoryMode=0755

                            [Install]
                            WantedBy=multi-user.target
                        EOF

                        #chown -R ${httpd_user}.${httpd_user} $path
                        cat >>/etc/sysctl.conf<<-EOF
                            net.core.somaxconn = 512
                            vm.overcommit_memory = 1
                        EOF
                        sysctl -p
                        sleep 1
                        cat >>/etc/rc.d/rc.local<<-EOF
                            echo never > /sys/kernel/mm/transparent_hugepage/enabled
                        EOF
                        chmod a+x /etc/rc.d/rc.local
                        systemctl daemon-reload
                        sleep 1
                        systemctl start redis
                        cd -

                        f_color shan "`echo "redis ×××tall path is: ${path}"`"
                        sleep 1
                    fi

                    f_menu_×××tall_server_redis_list
                    ;;
                2)
                    f_menu_×××tall_server_redis_list
                    ;;
                *)
                    f_menu_×××tall_server_redis_list
                    ;;
            esac
            ;;
        ####################################################  show ruby && redis_gem version
        3)
            echo
            echo -e "\t$ruby_×××tall_ver"
            echo -e "\t$redis_gem_×××tall_ver"
            f_menu_×××tall_server_redis_list
            ;;
        #####################################################  ×××tal ruby && redis_gem
        4)
            echo
            read -p "Pls input 1-×××tall or 2-quit : " choose_num
            f_is_num $choose_num
            [ $? -eq 1 ] || { action "Pls input valid num!" false ; f_menu_×××tall_server_redis_list;}

            yum -y ×××tall gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel &> /dev/null

            read -p "Whether use default masterauth=requirepass  1-yes or 2-no : " passwd_choose_num
            f_is_num $passwd_choose_num
            [ $? -eq 1 ] || { action "Pls input valid num!" false ; f_menu_×××tall_server_redis_list;}
            case $passwd_choose_num in
                1)
                    new_master_passwd=$master_default_passwd
                    f_color shan "`echo "Default masterauth=requirepass is: $new_master_passwd "`"
                    ;;
                2)
                    f_color shan "`echo "You input passwd must be -eq redis cluster requirepass, or else create cluster error!!! "`"
                    read -p "You affirm chooge passwd ? 1-yes or 2-no :" $gem_choose_num
                    case $gem_choose_num in
                        1)
                            while true
                            do
                                read -p "Pls input gem password: " gem_passwd
                                if [ -z "$gem_passwd" ];then
                                    f_color red "`echo "password can not be empty !"`"
                                else
                                    new_master_passwd=$gem_passwd
                                    f_color shan "`echo "Gem password is: $new_master_passwd "`"
                                    break
                                fi
                            done
                            ;;
                        2)
                            f_menu_×××tall_server_redis_list
                            ;;
                        *)
                            f_menu_×××tall_server_redis_list
                    esac
                    ;;
                *)
                    f_menu_×××tall_server_redis_list
            esac

            # ruby  .tar. is exist?
            yum -y ×××tall mlocate &> /dev/null
            updatedb &> /dev/null
            locate_server_num=`locate ${ruby_×××tall_ver}| wc -l`
            if [ ! -e $ruby_×××tall_ver ];then
                if [ $locate_server_num -eq 1 ];then
                    \cp `find / -name ${ruby_×××tall_ver}` . -a
                elif [ $locate_server_num -ge 2 ];then
                    \cp `find / -name ${ruby_×××tall_ver} | head -n1` . -a
                else
                    find_server_num=`find / -name ${ruby_×××tall_ver}| wc -l`
                    if [ $find_server_num -eq 1 ];then
                        \cp `find / -name ${ruby_×××tall_ver}` . -a
                    elif [ $find_server_num -ge 2 ];then
                        \cp `find / -name ${ruby_×××tall_ver} | head -n1` . -a
                    else
                        f_color red "`echo "${ruby_×××tall_ver} is not exist!"`"
                        f_menu_×××tall_server_redis_list
                    fi
                fi
            fi

            # redis_gem exist?
            locate_server_num=`locate ${redis_gem_×××tall_ver}| wc -l`
            if [ ! -e $redis_gem_×××tall_ver ];then
                if [ $locate_server_num -eq 1 ];then
                    \cp `find / -name ${redis_gem_×××tall_ver}` . -a
                elif [ $locate_server_num -ge 2 ];then
                    \cp `find / -name ${redis_gem_×××tall_ver} | head -n1` . -a
                else
                    find_server_num=`find / -name ${redis_gem_×××tall_ver}| wc -l`
                    if [ $find_server_num -eq 1 ];then
                        \cp `find / -name ${redis_gem_×××tall_ver}` . -a
                    elif [ $find_server_num -ge 2 ];then
                        \cp `find / -name ${redis_gem_×××tall_ver} | head -n1` . -a
                    else
                        f_color red "`echo "${redis_gem_×××tall_ver} is not exist!"`"
                        f_menu_×××tall_server_redis_list
                    fi
                fi
            fi

            ruby_×××tall_dir=`echo $ruby_×××tall_ver | awk -F ‘.tar.‘ ‘{print $1}‘`
            redis_gem_×××tall_dir=`echo $redis_gem_×××tall_ver | awk -F ‘.gem‘ ‘{print $1}‘`
            \rm -rf $ruby_×××tall_dir
            tar xvf $ruby_×××tall_ver
            cd $ruby_×××tall_dir
            ./configure
            make -j $cpu_num
            make ×××tall
            sleep 1
            cd -
            /usr/local/bin/gem ×××tall -l $redis_gem_×××tall_ver
            sed -ri s‘/password => nil/password => ‘$new_master_passwd‘/g‘ /usr/local/lib/ruby/gems/2.5.0/gems/$redis_gem_×××tall_dir/lib/redis/client.rb
            f_menu_×××tall_server_redis_list
            ;;
        0)
            exit 1
            ;;
        *)
            echo
            f_menu_×××tall_server_redis_list
    esac
    unset path
    unset redis_×××tall_dir
    unset num
    unset choose_num
    unset locate_server_num
    unset passwd_choose_num
    unset find_server_num
    unset new_master_passwd
    unset master_passwd
    unset redis_gem_×××tall_dir
    unset gem_passwd

}

Flag=true
while $Flag
do
    f_menu_×××tall_server_redis_list
        if [ $? -eq 0 ];then
                Flag=false
        fi
done

最后需要手动登陆集群中任意主机,进行创建集群,命令示例如下:

redis-trib.rb create  --replicas 1 172.18.200.101:6379  172.18.200.102:6379 172.18.200.103:6379 172.18.200.104:6379 172.18.200.105:6379 172.18.200.106:6379

原文地址:https://blog.51cto.com/13560168/2409657

时间: 2024-11-05 20:45:22

菜单形式部署redis 集群的脚本的相关文章

laravel项目利用twemproxy部署redis集群的完整步骤

Twemproxy是一个代理服务器,可以通过它减少Memcached或Redis服务器所打开的连接数.下面这篇文章主要给大家介绍了关于laravel项目利用twemproxy部署redis集群的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考下 前言 twemproxy是twitter开发的一个redis代理proxy,Twemproxy可以把多台redis server当作一台使用,开发人员通过twemproxy访问这些redis servers 的时候不用关心到底去哪一台redi

Centos7 上部署 redis集群

一.安装前看下redis5.0版本的新特性 先看一下 Redis 5 带来的更新内容: 新的流数据类型(Stream data type) https://redis.io/topics/streams-intro2.新的 Redis 模块 API:定时器.集群和字典 API(Timers, Cluster and Dictionary APIs) RDB 现在可存储 LFU 和 LRU 信息4.redis-cli 中的集群管理器从 Ruby (redis-trib.rb) 移植到了 C 语言代

部署redis集群

0.创建redis用户 并设置密码(可选操作) sudo useradd -g dream361 -s /bin/bash -d /home/redis -m redis echo 'redis' | sudo passwd redis --stdin 1.使用yum 安装 必须的软件包 sudo yum install wget ruby -y  # 下载包含gcc 编译工具的开发包 sudo yum groupinstall 'Development Tools' -y  2. 登录 rub

如何在Windows上部署Redis集群和SpringBoot进行整合

一.安装Redis的Windows版本并进行配置 (1)下载链接 https://github.com/microsoftarchive/redis/releases (2)将下载后的Redis复制成6份(3主3从集群.官方推荐最低的配置了) 文件名自定义,这里我改成和端口名一样 点进去每个文件夹,修改每个Redis的 redis.windows.conf 配置文件, 1 port 6380 # 6380,6381,6382,6383,6384,6385 2 cluster-enabled ye

Redis集群启动脚本

redis版本:redis-5.0.0 Centos: centos 7 64位 #!/bin/bash redis_path="/usr/local/cluster/" cluster_num=`ps aux | grep redis | wc -l` if [ "${cluster_num}" -le 0 ] then echo -e "===== Success: Has killed all cluster progress." else

Redis集群部署过程记录(3台服务器共6个节点)

这是我的第一篇博文,整理了我在部署Redis集群踩过的坑,以及详细的部署过程,同时归结了部署过程中遇到的问题的处理方法.1.部署的环境:SUSE Linux Enterprise 11 sp42.涉及到的安装包如下:(1) 安装包:redis-4.0.2.tar.gz下载地址:http://download.redis.io/releases/ redis官网http://www.redis.io(2) 接口包:redis-4.0.0.gem(3) 脚本语言包:ruby-2.4.2.tar.gz

Redis集群错误

部署Redis集群时出现如下错误: >>> Creating cluster>>> Performing hash slots allocation on 9 nodes...Using 4 masters:192.168.247.40:7000192.168.247.40:7001192.168.247.40:7002192.168.247.40:7003Adding replica 192.168.247.40:7004 to 192.168.247.40:7000

zabbix监控redis集群

1.agent端新建自动发现redis集群端口 脚本如下 #!/bin/bash #redis_sport_scan.sh redis() { port=($(sudo netstat -tpln | awk -F "[ :]+" '/redis/ && /0.0.0.0/ {print $5}')) printf '{\n' printf '\t"data":[\n' for key in ${!port[@]} do if [[ "${

windows下安装redis集群

前几天在自己在本机win10 电脑下部署了redis集群. 主要通过的是网上两个博客: 如何在windows下部署redis集群:https://blog.csdn.net/zsg88/article/details/73715947 redis的一些操作:https://blog.csdn.net/mlc1218559742/article/details/52640180 原文地址:https://www.cnblogs.com/tuanz/p/9359037.html