$ wget http://download.redis.io/releases/redis-5.0.4.tar.gz
$ tar xzf redis-5.0.4.tar.gz
$ cd redis-5.0.4
$ make
安装完成后,可执行文件在当前目录的src下。
cp redis-5.0.4当前目录下的redis.conf到/etc/redis/redis.conf
然后创建服务:
vi /lib/systemd/system/redis.service
[Unit]
Description=Redis
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/soft/redis-5.0.4/src/redis-server /etc/redis/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
配置服务:
2、刷新配置
刚刚配置的服务需要让systemctl能识别,就必须刷新配置
systemctl daemon-reload
3、启动、重启、停止
启动redis
systemctl start redis
systemctl restart redis
systemctl stop redis
4、开机自启动
redis服务加入开机启动
systemctl enable redis
禁止开机启动
systemctl disable redis
5、查看状态
systemctl status redis