Blog Pages

Linux - Create a service for the new instance - using systemd

How to create a service for the new instance - using systems?

In this example: MySQL service.

1. Create “.service” file
Save in “/lib/systemd/system/” or “/etc/systemd/system”

touch mysql_3307.service
vi mysql_3307.service

 
[Unit]
Description=MySQL 3307 service
After=network.target
 
[Service]
Type=simple
Restart=always
User=mysql
Group=mysql
ExecStart=/etc/mysql/sudo mysqld --defaults-file=/etc/mysql/second_server.cnf
TimeoutSec=600
RuntimeDirectory=mysqld
RuntimeDirectoryMode=755
LimitNOFILE=5000
 
[Install]
WantedBy=multi-user.target

2. Start the service
Sudo systemctl start mysql_3307


3. Checking
systemctl status mysql_3307
 journalctl -xe


* Stop the service (if required)
systemctl stop mysql_3307

No comments:

Post a Comment