Shell脚本------一键部署Redis
Posted 下雨天的放羊娃
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Shell脚本------一键部署Redis相关的知识,希望对你有一定的参考价值。
使用此脚本需要先配置好yum源,然后将安装包传输到/opt目录中,编写脚本,复制下面的脚本代码,source执行。
安装包:redis-5.0.7.tar.gz
提取码:1122
#!/bin/bash
#关闭防火墙
systemctl stop firewalld
setenforce 0
yum install -y gcc gcc-c++ make
yum -y install expect
cd /opt
tar zxvf redis-5.0.7.tar.gz -C /opt/
cd /opt/redis-5.0.7/
make
make PREFIX=/usr/local/redis install
cd /opt/redis-5.0.7/utils
/usr/bin/expect <<EOF
spawn ./install_server.sh
expect "instance" send "\\r"
expect "config" send "\\r"
expect "log" send "\\r"
expect "data" send "\\r"
expect "executable" send "/usr/local/redis/bin/redis-server\\r"
expect "abort" send "\\r"
expect eof
EOF
ln -s /usr/local/redis/bin/* /usr/local/bin/
/etc/init.d/redis_6379 restart
sed -i '/bind 127.0.0.1/c bind 0.0.0.0' /etc/redis/6379.conf
sed -i 's/appendonly no/appendonly yes/' /etc/redis/6379.conf
/etc/init.d/redis_6379 restart
netstat -natp | grep redis
if [ $? -eq 0 ];then
echo -e "服务启动成功"
else
exit
echo -e "服务启动失败,请检查"
fi
以上是关于Shell脚本------一键部署Redis的主要内容,如果未能解决你的问题,请参考以下文章