一键编译安装脚本如下:
yum ×××tall gcc jemalloc-devel wget -y &>/dev/null #初始化安装环境
cd /usr/local/src/
wget http://download.redis.io/releases/redis-4.0.14.tar.gz &>/dev/null
tar xvf redis-4.0.14.tar.gz
cd redis-4.0.14/deps/
make hiredis jemalloc linenoise lua #若无此步骤,有的主机可能安装不成功
cd ..
make PREFIX=/apps/redis ×××tall #安装目录
mkdir /apps/redis/{etc,run,data,logs} #创建文件目录
cp /usr/local/src/redis-4.0.14/redis.conf /apps/redis/etc/ #复制配置文件
ln -sv /apps/redis/bin/redis-* /usr/sbin/ #创建命令软链接
touch /usr/lib/systemd/system/redis.service #创建systemctl启动脚本
cat > /usr/lib/systemd/system/redis.service <<EOF
[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
#ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd
ExecStart=/apps/redis/bin/redis-server /apps/redis/etc/redis.conf --supervised systemd
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target
EOF
useradd -r -s /sbin/nologin redis #创建用户
chown -R redis.redis /apps/redis/ #更改目录属主属组
原文地址:https://blog.51cto.com/14230230/2409223
时间: 2024-10-06 10:13:41