Démarrage automatique de service au boot d’un serveur Linux.

Linux boot :

Il existe plusieurs niveau de boot.

rc0.d Arrêt du serveur linux

rc1.d Débug mode console

rc2.d Débug mode console

à rc3.d Mode console

rc4.d Débug mode graphique

à rc5.d Mode graphique

rc6.d Reboot du serveur linux

runlevel pour connaitre le niveau de démarrage.

exemple : N 3 =====>rc3

N 2 3 =========> dabort le rc2 puis le rc3

vi /etc/inittab pour modifier le niveau de démarrage

# The default runlevel is defined here
id:3:initdefault:

On positionne les « services » à démarrer sur les rc3.d et rc5.d.

Les fichiers de commandes sont dans /etc/init.d pour pouvoir être appelés dans les différents rcX.d

Les chaines d’exécution sont dans les directories /etc/rcX.d

Il existe deux types de commandes K (kill) et S (Start)

Les commandes sont numérotées (chronologiquement) de 00 à 99.

K01xxx

K02yyy

K03zzz

….

S01xxx

S02yyy

S03zzz (par exemple)

Les commandes S99zzzzz sont des liens symboliques qui pointent sur des fichiers de commandes ou exécutables.

exemple

Le lien S99vtom.sh pointe sur /etc/rc.d/init.d/boot_start_vtom.sh

Le fichier boot_start_vtom.sh contient la commande à executer.

Création d’un lien symbolique :

Syntaxe : ln -s nom_du_fichier nom_du_lien

pour le supprimer : rm nom_du_lien

Démarrage : (client, moteur et serveur Vtom)

root@tic:/etc/rc5.d# ln -s ../init.d/boot_start_vtserver S99boot_start_vtserver

root@tic:/etc/rc5.d# cd ../init.d

root@tic:/etc/init.d# vi boot_start_vtserver

ajouter la ligne de commande

su -l vtom -c /opt/vtom/admin/boot_start_servers

su -l vtom -c /opt/vtom/admin/start_moteurs

su -l vtom -c /opt/vtom/admin/boot_start_client

root@tic:/etc/init.d# chmod 755 boot_start_vtserver

root@tic:/etc/rc5.d# cd ../rc3.d

root@tic:/etc/rc3.d# ln -s ../init.d/boot_start_vtserver S99boot_start_vtserver

Arrêt : (client, moteur et serveur Vtom)

root@tic:/etc/rc5.d# ln -s ../init.d/stop_vtserver K99stop_vtserver

root@tic:/etc/rc5.d# cd ../init.d

root@tic:/etc/init.d# vi stop_vtserver

ajouter la ligne de commande

su -l vtom -c /opt/vtom/admin/stop_servers

su -l vtom -c /opt/vtom/admin/stop_moteurs

su -l vtom -c /opt/vtom/admin/stop_client

root@tic:/etc/init.d# chmod 755 stop_vtserver

root@tic:/etc/rc5.d# cd ../rc3.d

root@tic:/etc/rc3.d# ln -s ../init.d/stop_vtserver K99stop_vtserver

Mémo pour start auto de VTOM :

cd /etc/rc.d/init.d

vi boot_start_vtom.sh

su -l vtom -c /opt/vtom53/admin/boot_start_client

vi boot_stop_vtom.sh

su -l vtom -c /opt/vtom53/admin/stop_client

cd /etc/rc3.d

ln -s ../init.d/boot_stop_vtom.sh K99boot_stop_client

ln -s ../init.d/boot_start_vtom.sh S99boot_start_client

cd /etc/rc5.d

ln -s ../init.d/boot_stop_vtom.sh K99boot_stop_client

ln -s ../init.d/boot_start_vtom.sh S99boot_start_client

Il faut tester :

[root@pdtb2 rc3.d]# ./K99boot_stop_client
Le client Visual TOM est arrete.
[root@pdtb2 rc3.d]# ./S99boot_start_client
Le client Visual TOM est actif sur pdtb2.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *