redis一键部署脚本
2021/11/13 2:42:33
本文主要是介绍redis一键部署脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
redis一键部署脚本
需要创建一个脚本后执行就可!若长时间启动不了要看有无睡眠进程以及要先切换到opt目录下后上传软件包
#!/bin/bash echo -e "\033[31m =====正在验证当前为仅主机还是NAT模式===== \033[0m" ping -c1 -W1 www.baidu.com &> /dev/null if [ $? -eq 0 ];then echo -e "\033[31m 检测当前为NAT模式,为您配置在线yum源 \033[0m" mkdir -p /etc/yum.repos.d/repo.bak mv -f /etc/yum.repos.d/* /etc/yum.repos.d/repo.bak &> /dev/null wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo &> /dev/null yum clean all &> /dev/null yum list &> /dev/null echo -e "\033[31m 在线源已配置完成 \033[0m" else echo -e "\033[31m 检测当前为仅主机模式,为您配置本地yum源 \033[0m" mount /dev/sr0 /mnt &> /dev/null cd /etc/yum.repos.d/ mkdir -p /etc/yum.repos.d/repo.bak mv -f /etc/yum.repos.d/* /etc/yum.repos.d/repo.bak &> /dev/null echo '[local] name=local baseurl=file:///mnt enabled=1 gpgcheck=0' > /etc/yum.repos.d/local.repo yum clean all &> /dev/null yum makecache &> /dev/null df -h | grep "/mnt" if [ $? -ne 0 ];then echo -e "\033[31m 检测当前为仅主机模式,但光盘未连接! \033[0m" else echo -e "\033[31m 本地yum源已配置完成 \033[0m" fi fi #关闭防火墙 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 /etc/init.d/redis_6379 status netstat -natp | grep redis
这篇关于redis一键部署脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-08阿里云Redis项目实战入门教程
- 2024-11-08阿里云Redis资料:新手入门与初级使用指南
- 2024-11-08阿里云Redis教程:新手入门及实用指南
- 2024-11-07阿里云Redis学习入门:新手必读指南
- 2024-11-07阿里云Redis学习入门:从零开始的操作指南
- 2024-11-07阿里云Redis学习:初学者指南
- 2024-11-06阿里云Redis入门教程:轻松搭建与使用指南
- 2024-11-02Redis项目实战:新手入门教程
- 2024-10-22Redis入门教程:轻松掌握数据存储与操作
- 2024-10-22Redis缓存入门教程:快速掌握Redis缓存基础知识