Ajout suppression unité systemd principale si pas utilisé

This commit is contained in:
emorino 2021-11-19 10:15:01 +01:00
parent 777fa71dc2
commit 526ce99cfc

View file

@ -1631,52 +1631,20 @@ On préfère passer la commande « shutdown » en interne :
### Nettoyage
Si le *mysqld* principal n'est pas utilisé, on désactivera le script d'init.d /etc/init.d/mysql (en ajoutant `exit 0`
au début du script) et on pourra se créer un script `/etc/init.d/mysqld_instances` du type :
Si le *mysqld* principal n'est pas utilisé, on désactivera l'unité systemd comme ceci :
~~~{.bash}
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: mysqld_instances
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network $time
# Should-Stop: $network $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the mysql database server daemon
# Description: Controls the main MySQL database server daemon "mysqld"
# and its wrapper script "mysqld_safe".
### END INIT INFO
#
set -e
set -u
~~~
# systemctl stop mysql.service
# systemctl disable mysql.service
~~~
mkdir -p /run/mysqld_instances && chown root:mysql /run/mysqld_instances && chmod 770 /run/mysqld_instances
Pour géré les instances créer on utilisera l'unité systemd `mysqld@.service` :
case "$1" in
start)
mysqld_multi start
;;
stop)
for pid in /run/mysqld_instances/*/mysqld.pid; do
pkill -F "${pid}"
done
;;
status)
mysqld_multi report
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
~~~
# systemctl status mysqld@1
# systemctl stop mysqld@1
# systemctl start mysqld@1
# systemctl enable mysqld@1
~~~
### Administration