Redis 4.0.0 一键安装脚本,CentOS 7 systemd 完美启动

Redis

首先安装 GCC

curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/gcc/gcc.sh | bash

#!/bin/bash

##################################################

# Redis 4.0.0 setup script

# Author: netkiller<netkiller@msn.com>

# Website: http://www.netkiller.cn

##################################################

cd /usr/local/src

adduser redis

wget http://download.redis.io/releases/redis-4.0.0.tar.gz

tar xzf redis-4.0.0.tar.gz

cd redis-4.0.0

make MALLOC=libc -j$(getconf _NPROCESSORS_ONLN) && make install

cp redis.conf /usr/local/etc/

cp /usr/local/etc/redis.conf{,.original}

sed -i 's/daemonize no/daemonize yes/' /usr/local/etc/redis.conf

sed -i 's/timeout 0/timeout 30/' /usr/local/etc/redis.conf

sed -i 's/tcp-keepalive 0/tcp-keepalive 120/' /usr/local/etc/redis.conf

sed -i 's/# maxclients 10000/maxclients 10000/' /usr/local/etc/redis.conf

sed -i 's/# maxmemory-policy noeviction/maxmemory-policy volatile-lru/g' /usr/local/etc/redis.conf

cat >> /etc/sysctl.conf <<EOF

# Set up for Redis

vm.overcommit_memory = 1

EOF

sysctl vm.overcommit_memory=1

wget -q https://raw.githubusercontent.com/oscm/shell/master/database/redis/source/systemd/redis.service -O /usr/lib/systemd/system/redis.service

wget -q https://raw.githubusercontent.com/oscm/shell/master/database/redis/source/systemd/redis-shutdown -O /usr/local/bin/redis-shutdown

chmod 700 /usr/local/bin/redis-shutdown

chown redis:redis /usr/local/bin/redis-shutdown

systemctl enable redis

systemctl start redis

原文发布于微信公众号 - Netkiller(netkiller-ebook)

原文发表时间:2017-07-18

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区