一键编译安装Redis脚本
2022/8/25 2:23:27
本文主要是介绍一键编译安装Redis脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
#!/bin/bash . /etc/init.d/functions VERSION=redis-5.0.7 PASSWORD=123456 INSTALL_DIR=/usr/lcoal/redis install() { yum -y install gcc jemalloc-devel || { action "安装软件包失败,请检查网络配置" false ; exit; } wget http://download.redis.io/releases/${VERSION}.tar.gz || { action "Redis 源码下载失败" false ; exit; } tar xf ${VERSION}.tar.gz cd ${VERSION} make -j 4 PREFIX=${INSTALL_DIR} install && action "Redis 编译安装完成" || { action "Redis 编译安装失败" false ;exit ; } ln -s ${INSTALL_DIR}/bin/redis-* /usr/bin/ mkdir -p ${INSTALL_DIR}/{etc,logs,data,run} cp redis.conf ${INSTALL_DIR}/etc/ sed -i.bak -e 's/bind 127.0.0.1/bind 0.0.0.0/' -e "/# requirepass/a requirepass $PASSWORD" ${INSTALL_DIR}/etc/redis.conf if id redis &> /dev/null ;then action "Redis 用户已存在" false else useradd -r -s /sbin/nologin redis action "Redis 用户创建成功" fi chown -R redis.redis ${INSTALL_DIR} cat >> /etc/sysctl.conf <<EOF net.core.somaxconn = 1024 vm.overcommit_memory = 1 EOF echo never > /sys/kernel/mm/transparent_hugepage/enabled cat > /usr/lib/systemd/system/redis.service <<EOF [Unit] Description=Redis persistent key-value database After=network.target [Service] ExecStart=${INSTALL_DIR}/bin/redis-server ${INSTALL_DIR}/etc/redis.conf --supervised systemd 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 systemctl start redis &> /dev/null && action "Redis 服务启动成功,Redis信息如下:" || { action "Redis 启动失败" false ;exit; } redis-cli -a $PASSWORD INFO Server 2> /dev/null } install
这篇关于一键编译安装Redis脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-21redisinsight-v2
- 2024-02-26Typed property App\Api\Mapper\GamePropsConfigMapper::$apiRedis must not be accessed before initia-icode9专业技术文章分享
- 2024-02-21redisson getlock
- 2024-02-20redis config
- 2024-02-20redis leaderboard
- 2024-01-23缓存选型:Redis or MemCache
- 2024-01-22面试官:Redis持久化能关吗?怎么关?
- 2024-01-21Redis压测工具redis-benchmark-icode9专业技术文章分享
- 2024-01-19这才是你应该了解的Redis数据结构!
- 2024-01-18Redis系列:使用 Redis Module 扩展功能