如何使用 systemd来管理 部署mariadb服务
Systemd 服务管理方案
# 这是基于Systemd的服务管理架构 systemctl [start|stop|status|enable] your-service.service # step1 :如下方式修改systemd服务: sudo vi /usr/lib/systemd/system/mariadb.service
#step2: 修改了systemd配置文件后,需要加载配置(在你修改了任何服务配置文件后,必须执行此命令,使新的配置生效。) sudo systemctl daemon-reload #step3: 重启服务 sudo systemctl restart your-service.service #如果服务第一次启动,就使用启动命令,而不是重启命令: sudo systemctl start your-service.service
配置maradb.service
[Unit] Description=MariaDB database server After=syslog.target After=network.target [Service] Type=simple User=mysql Group=mysql ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n # Note: we set --basedir to prevent probes that might trigger SELinux alarms, # per bug #547485 ExecStart=/usr/bin/mysqld_safe --basedir=/usr ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID # Give a reasonable amount of time for the server to start up/shut down TimeoutSec=300 # Place temp files in a secure directory, not /tmp PrivateTmp=true [Install] WantedBy=multi-user.target

浙公网安备 33010602011771号