redis 主从复制部署

#!/usr/bin/env bash
#make install redis
network(){
    ping -c2 www.baidu.com &>/dev/null
    if [ $? -ne 0 ];then
        echo "network is error...."
        exit
     
    fi
    
}

test(){
[ $? -ne 0 ] && echo "excution error....";exit

}

install_gcc(){
    yum -y install gcc glibc glibc-kernheaders  glibc-common glibc-devel make
    yum -y install centos-release-scl
    yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
#    scl enable devtoolset-9 bash
    echo "source /opt/rh/devtoolset-9/enable" >>/root/.bashrc
}
install_redis(){
    
    wget http://download.redis.io/releases/redis-6.0.8.tar.gz
    tar -zxvf redis-6.0.8.tar.gz -C /usr/local
    mv /usr/local/redis-6.0.8 /usr/local/redis
    cd /usr/local/redis
    make && make all

}
redis_MS(){
    mkdir -p /redis/{6380,6381,6382}/{conf,data,log}
    cd /redis
cat >6380/conf/redis.conf <<eof
bind 0.0.0.0
port 6380
daemonize yes
pidfile /redis/6380/redis.pid
loglevel notice
logfile "/redis/6380/log/redis.log"
dbfilename dump.rdb
dir /redis/6380/data/
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
slowlog-log-slower-than 10000
slowlog-max-len 128
protected-mode no
#requirepass redis
eof
    cat >6381/conf/redis.conf <<eof
bind 0.0.0.0
port 6381
daemonize yes
pidfile /redis/6381/redis.pid
loglevel notice
logfile "/redis/6381/log/redis.log"
dbfilename dump.rdb
dir /redis/6381/data/
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
slowlog-log-slower-than 10000
slowlog-max-len 128
protected-mode no
# 配置mast的认证密码
#requirepass redis
# 配置为 master的从,
replicaof 192.168.122.152 6380
eof



cat >6382/conf/redis.conf <<eof
bind 0.0.0.0
port 6382
daemonize yes
pidfile /redis/6382/redis.pid
loglevel notice
logfile "/redis/6382/log/redis.log"
dbfilename dump.rdb
dir /redis/6382/data/
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
slowlog-log-slower-than 10000
slowlog-max-len 128
protected-mode no
# 配置mast的认证密码
#requirepass redis
# 配置为 master的从,
replicaof 192.168.122.152 6380
eof
}


start_redis(){
    /usr/local/redis/src/redis-server /redis/6380/conf/redis.conf
    /usr/local/redis/src/redis-server /redis/6381/conf/redis.conf
    /usr/local/redis/src/redis-server /redis/6382/conf/redis.conf

}
script_start_redis(){
    cat >/usr/local/redis/start-redis.sh<<-EOF
#!/bin/bash
REDIS_HOME=/usr/local/redis
REDIS_CONF=/redis
\$REDIS_HOME/src/redis-server \$REDIS_CONF/6380/conf/redis.conf
\$REDIS_HOME/src/redis-server \$REDIS_CONF/6381/conf/redis.conf
\$REDIS_HOME/src/redis-server \$REDIS_CONF/6382/conf/redis.conf
EOF
    chmod +x /usr/local/redis-cluster/start-redis.sh    
}


network
install_gcc
install_redis
redis_MS
start_redis
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值