源码安装部署redis

cd /opt/
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 && make install PREFIX=/data/apps/redis
cd /data/apps/redis
mkdir conf
cp /opt/redis-4.0.0/redis.conf  ./conf

sed -i 's/daemonize no/daemonize yes/' conf/redis.conf
sed -i 's/protected-mode yes/protected-mode no/' conf/redis.conf
sed -i 's/bind 127.0.0.1/bind 0.0.0.0/' conf/redis.conf
echo 'requirepass `< /dev/urandom tr -cd _A-Z-a-z-0-9@#^ | head -c ${1:-32}; echo`' >> conf/redis.conf


useradd -M  redis
chown -R redis.redis /data/apps/redis


cat <<EOF > /usr/lib/systemd/system/redis.service

[Unit]
Description=Redis Server Manager
After=syslog.target
After=network.target 

[Service]
Type=simple
User=redis
Group=redis
PIDFile=/var/run/redis_6379.pid
ExecStart=/data/apps/redis/bin/redis-server /data/apps/redis/conf/redis.conf
ExecStop=/data/apps/redis/bin/redis-cli shutdown
Restart=always 
[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl start redis
systemctl enable redis

 

posted @ 2019-05-13 10:09  Ray_chen  阅读(457)  评论(0编辑  收藏  举报