在线编译安装redis脚本
2021/9/14 2:05:18
本文主要是介绍在线编译安装redis脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#!/bin/bash INSTALL_DIR=/apps/redis CONF_FILE=/apps/redis/etc/redis.conf before_install (){ yum makecache && yum install -y gcc jemalloc > /dev/null cd /usr/local/src && wget https://download.redis.io/releases/redis-5.0.9.tar.gz tar xzvf redis-5.0.9.tar.gz > /dev/null } redis_install (){ cd redis-5.0.9 && make PREFIX=${INSTALL_DIR} install } after_install (){ useradd -r -s /sbin/nologin redis mkdir -p /apps/redis/{etc,log,run,data} && chown redis.redis -R /apps/redis/ cp /usr/local/src/redis-5.0.9/redis.conf /apps/redis/etc/ sed -ri.bak '/^daemonize/s/yes/no/' $CONF_FILE sed -ri '/^bind/s/127.0.0.1/0.0.0.0/' $CONF_FILE sed -ri '/^protected-mode/s/yes/no/' $CONF_FILE sed -ri '/^pidfile/s/\/var/\/apps\/redis/' $CONF_FILE sed -ri '/^logfile/s/\"\"/\"\/apps\/redis\/log\/redis.log\"/' $CONF_FILE sed -ri '/^dir/s/\.\//\/apps\/redis\/data/' $CONF_FILE cat > /lib/systemd/system/redis.service << EOF [Unit] Description=Redis persistent key-value database After=network.target [Service] ExecStart=/apps/redis/bin/redis-server /apps/redis/etc/redis.conf --supervised systemd #ExecStop=/usr/libexec/redis-shutdown ExecStop=/bin/kill -s QUIT $MAINPID Type=notify User=redis Group=redis RuntimeDirectory=redis RuntimeDirectoryMode=0755 [Install] WantedBy=multi-user.target EOF systemctl daemon-reload cat >> /etc/sysctl.conf << EOF vm.overcommit_memory = 1 net.core.somaxconn = 1024 EOF sysctl -p echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.d/rc.local chmod +x /etc/rc.d/rc.local && /etc/rc.d/rc.local systemctl start redis && echo "redis 启动成功" } main (){ before_install redis_install after_install } main
这篇关于在线编译安装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缓存基础知识