美文网首页
3.Redis配置成系统服务(CentOS7)

3.Redis配置成系统服务(CentOS7)

作者: 一枼落知天下 | 来源:发表于2019-06-24 20:55 被阅读0次

Redis配置成系统服务

[root@ShuaiJhou ~]# wget http://download.redis.io/releases/redis-5.0.5.tar.gz
[root@ShuaiJhou ~]# tar xzf redis-5.0.5.tar.gz 
[root@ShuaiJhou ~]# cd redis-5.0.5
[root@ShuaiJhou redis-5.0.5]# make PREFIX=/usr/local/redis install
[root@ShuaiJhou redis-5.0.5]# ls /usr/local/redis/
[root@ShuaiJhou redis-5.0.5]# mkdir /usr/local/redis/ect
[root@ShuaiJhou redis-5.0.5]# cp redis.conf  /usr/local/redis/ect/

[root@ShuaiJhou ~]# mkdir /usr/local/redis/data
[root@ShuaiJhou ~]# ls /usr/local/redis/
bin  data  ect
[root@ShuaiJhou ~]# 


[root@ShuaiJhou ~]# cd /usr/local/redis/ect/
[root@ShuaiJhou ect]# vim redis.conf 
daemonize yes
dir /usr/local/redis/data


[root@ShuaiJhou redis-5.0.5]# cd /usr/local/redis
[root@ShuaiJhou redis]# vim /usr/lib/systemd/system/redis-server.service
[Unit]
Description=Redis
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/ect/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

[root@ShuaiJhou redis]# systemctl daemon-reload
[root@ShuaiJhou redis]# systemctl list-unit-files --type=service| grep redis
[root@ShuaiJhou redis]# systemctl start redis-server.service
[root@ShuaiJhou redis]# systemctl status redis-server.service
● redis-server.service - Redis
   Loaded: loaded (/usr/lib/systemd/system/redis-server.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-06-24 20:37:06 CST; 9min ago
 Main PID: 107036 (redis-server)
   CGroup: /system.slice/redis-server.service
           └─107036 /usr/local/redis/bin/redis-server 127.0.0.1:6379

Jun 24 20:37:06 ShuaiJhou systemd[1]: Starting Redis...
Jun 24 20:37:06 ShuaiJhou redis-server[107035]: 107035:C 24 Jun 2019 20:37:06.757 # oO0OoO0OoO0Oo Redis is starting oO...oO0Oo
Jun 24 20:37:06 ShuaiJhou redis-server[107035]: 107035:C 24 Jun 2019 20:37:06.757 # Redis version=5.0.5, bits=64, comm...arted
Jun 24 20:37:06 ShuaiJhou redis-server[107035]: 107035:C 24 Jun 2019 20:37:06.757 # Configuration loaded
Jun 24 20:37:06 ShuaiJhou systemd[1]: PID file /var/run/redis_6379.pid not readable (yet?) after start.
Jun 24 20:37:06 ShuaiJhou systemd[1]: Started Redis.
Hint: Some lines were ellipsized, use -l to show in full.
[root@ShuaiJhou redis]# 
[root@ShuaiJhou redis]# systemctl enable redis-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/redis-server.service to /usr/lib/systemd/system/redis-server.service.
[root@ShuaiJhou redis]# systemctl list-unit-files --type=service| grep redis
redis-server.service                          enabled 
[root@ShuaiJhou redis]# 
[root@ShuaiJhou redis]# systemctl stop redis-server.service
[root@ShuaiJhou redis]# systemctl start redis-server.service
[root@ShuaiJhou redis]# systemctl status redis-server.service
● redis-server.service - Redis
   Loaded: loaded (/usr/lib/systemd/system/redis-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-06-24 20:53:04 CST; 6s ago
  Process: 107104 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=0/SUCCESS)
  Process: 107118 ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/ect/redis.conf (code=exited, status=0/SUCCESS)
 Main PID: 107119 (redis-server)
   CGroup: /system.slice/redis-server.service
           └─107119 /usr/local/redis/bin/redis-server 127.0.0.1:6379

Jun 24 20:53:04 ShuaiJhou systemd[1]: Starting Redis...
Jun 24 20:53:04 ShuaiJhou redis-server[107118]: 107118:C 24 Jun 2019 20:53:04.739 # oO0OoO0OoO0Oo Redis is starting oO...oO0Oo
Jun 24 20:53:04 ShuaiJhou redis-server[107118]: 107118:C 24 Jun 2019 20:53:04.739 # Redis version=5.0.5, bits=64, comm...arted
Jun 24 20:53:04 ShuaiJhou redis-server[107118]: 107118:C 24 Jun 2019 20:53:04.739 # Configuration loaded
Jun 24 20:53:04 ShuaiJhou systemd[1]: PID file /var/run/redis_6379.pid not readable (yet?) after start.
Jun 24 20:53:04 ShuaiJhou systemd[1]: Started Redis.
Hint: Some lines were ellipsized, use -l to show in full.
[root@ShuaiJhou redis]# 

相关文章

网友评论

      本文标题:3.Redis配置成系统服务(CentOS7)

      本文链接:https://www.haomeiwen.com/subject/ledaqctx.html