introduction to systemd

Systemd is a system and service manager for Linux operating systems. It is designed to be backwards compatible with SysV init scripts, and provides a number of features such as parallel startup of system services at boot time, on-demand activation of daemons, or dependency-based service control logic. In Red Hat Enterprise Linux 7, systemd replaces Upstart as the default init system.
– Red_Hat_Enterprise_Linux-7-System_Administrators_Guide 2017-12-11

start a second redis with systemctl on centos7

  1. get default redis.service path
[centos@offertest ~]$ sudo systemctl status redis
● redis.service - Redis persistent key-value database
   Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/redis.service.d
           └─limit.conf
   Active: active (running) since Thu 2018-05-03 07:55:48 UTC; 2h 7min ago
 Main PID: 4990 (redis-server)
   CGroup: /system.slice/redis.service
           └─4990 /usr/bin/redis-server 127.0.0.1:6379

May 03 07:55:48 offertest systemd[1]: Started Redis persistent key-value database.
May 03 07:55:48 offertest systemd[1]: Starting Redis persistent key-value database...
  1. copy and modify redis.service
sudo cp /usr/lib/systemd/system/redis.service /usr/lib/systemd/system/redis6380.service
cat /usr/lib/systemd/system/redis6380.service
# rename the description and a different pid file
[Unit]
Description=Redis 6380
After=network.target

[Service]
ExecStart=/usr/bin/redis-server /etc/redis6380.conf --daemonize no
User=redis
Group=redis
PrivateTmp=true
RuntimeDirectory=redis
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target
  1. copy and modify redis.conf
sudo cp /etc/redis.conf /etc/redis6380.conf
cat /etc/redis6380.conf
# a different port and pidfile for second redis instance
port 6380
pidfile /var/run/redis_6380.pid
  1. reload system daemon
sudo systemctl daemon-reload
sudo systemctl start redis6380
sudo systemctl enable redis6380