Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cheng10/0af0b2d98698e733b61e40826959a9b3 to your computer and use it in GitHub Desktop.
Save cheng10/0af0b2d98698e733b61e40826959a9b3 to your computer and use it in GitHub Desktop.
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...
2. copy and modify redis.service
```bash
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
```
3. copy and modify redis.conf
```bash
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
```
4. reload system daemon
```bash
sudo systemctl daemon-reload
sudo systemctl start redis6380
sudo systemctl enable redis6380
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment