Embracing chkconfig to auto-start services (like mysql) on RHEL/CentOS/Fedora/etc.

I was at MODM4 yesterday, and as always, great fun was had. One common recurring theme though, was getting MySQL to start automatically upon a Linux server’s restart, something which I would have thought just came pretty naturally to sys-admin types. Upon further probing, these systems were all generally CentOS or RHEL based, and it wasn’t just MySQL that gave them problems – it was anything they’d installed out of the stock packages (lighttpd was a popular Apache replacement, that suffered from the same fate).

While I didn’t recollect the exact part of the manual it was stored in, I was informing everyone to make use of the chkconfig tool. Its really as simple as making sure there exists a /etc/init.d/mysql (it must be executable – chmod +x), doing a chkconfig --add mysql and making sure that it starts up at the correct runlevels (typically 3, 4 and 5). A simple chkconfig --level 345 mysql on and you’re ready to rock. Repeat, rinse for lighttpd or anything else, that has a startup script, really.

And read the manual – section 2.4.16.2.2. Starting and Stopping MySQL Automatically. chkconfig‘s manual page is a little sparse, so consider some of the Red Hat Knowledgebase entries: How do I use chkconfig to enable a script for a service that accepts start, stop, and status options? and Why does an installed service, like ypbind, not show up in the chkconfig list, but I am able to start it manually? Kudos to Red Hat’s open KB as well…

Technorati Tags: , , , ,

5 Comments

  1. […] works (well, the equivalent is service apache start), enabling things on boot using chkconfig (I wrote about it a while back) is replaced with […]

  2. paul says:

    minor correction, should be:

    chkconfig —-level 345 mysqld on

    :-)

  3. Nico says:

    Excellent! Thank you very much.
    Was wasting my time trying to solve the same silly thing.

  4. Manjula says:

    Let me know how to auto start mysql in fedora 10

  5. Nico says:

    Excellent! Thank you very much.
    Was wasting my time trying to solve the same silly thing.


i