折雨的天空
Centos7安装Redis6.0.3,配置服务
2020-5-19 我好笨


参考网址:



https://blog.csdn.net/weixin_43260474/article/details/106003751?fps=1&locationNum=2







上一篇文章:https://www.144d.com/post-673.html



已经描述了安装过程里面遇到的问题,并已解决,表示安装成功。



以下步骤开始配置:







执行网上教程最多的命令:







./utils/install_server.sh

Welcome to the redis service installer
This script will help you easily set up a running redis server

This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!





只能进行手工配置:







1、拷贝conf配置文件,在redis的目录下有一个redis.conf文件,拷贝至/etc/redis目录下,没有则需要创建目录



cp redis.conf /etc/redis/6379.conf

2、修改配置文件



vi /etc/redis/6379.conf

主要改动以下配置:







#下面要是改的参数 可以通过vim的/查找
port 6379
daemonize yes
pidfile /var/run/redis_6379.pid
logfile "/var/log/redis_6379.log"
#这个是redis数据持久化存放的地方
dir /var/lib/redis/6379





3、创建数据存放目录



mkdir /var/lib/redis/6379



4、创建系统服务







vim /usr/lib/systemd/system/redis_6379.service

文件中放入:







[Unit]
Description=redis_6379
After=network.target
[Service]
Type=forking
#pid文件路径,这个要和redis.conf文件的一致
PIDFile=/var/run/redis_6379.pid
#这就是执行命令 前面为redis-server所在路径 后一个为刚配置的conf文件
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target



5、启动服务



systemctl start redis_6379





6、随机启动







systemctl enable redis_6379



7、查看运行状态







#看端口占用
netstat -lnp|grep 6379

#看服务启动状态
systemctl status redis_6379





发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容