Shell脚本------一键部署Redis

该脚本详细指导了如何在Linux环境中通过yum源安装GCC、make等依赖,下载并解压Redis源码,编译安装,并配置启动Redis服务。包括设置安全策略、创建启动脚本、修改配置文件以允许远程访问及启用持久化功能。
摘要由CSDN通过智能技术生成

使用此脚本需要先配置好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
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值