Auto-start MariaDB using systemd after it has crashed

7,648

After making changes to systemd units, you need to run systemctl daemon-reload for those changes to have effect.

Share:
7,648

Related videos on Youtube

Mahdi
Author by

Mahdi

Updated on September 18, 2022

Comments

  • Mahdi
    Mahdi over 1 year

    I am trying to set up MariaDB in a way that it automatically recovers -- basically restarts, from a crash.

    Based on this article -- scroll down to Auto-starting Services with systemd, I opened /etc/systemd/system/multi-user.target.wants/mariadb.service file but there were nothing like this as the article explains:

    [Service]
    ...
    ...
    Restart=always
    ...
    

    So I added the [Service] section and the Restart=always underneath, restarted the service and killed the process to see if it will start automatically, but it didn't.

    I was wondering if I'm editing the wrong file or if there are other ways of achieving the same thing. Server is a remote machine running CentOS 7.

    • sam_pan_mariusz
      sam_pan_mariusz about 8 years
      What signal has been used to stop the service? Try SIGSEGV.
    • Mahdi
      Mahdi about 8 years
      @sam_pan_mariusz kill -9 oh is that because it wasn't a crash it won't restart?
    • sam_pan_mariusz
      sam_pan_mariusz about 8 years
      I've seen Upstart (the former init program in Ubuntu) not restarting certain services when they received SIGTERM, so I assumed a similar issue may exist with systemd. Other signals however worked as expected, SIGKILL (9) including.
    • Mahdi
      Mahdi about 8 years
      @sam_pan_mariusz thanks, I will try to see if there are similar solutions for Upstart that I can't apply on systemd.