CentOS - chkconfig
Having a problem keeping your web services running after a reboot? This article will help you through the .rpm architecture version of run level start up manipulation. We're going to go over setting a service (i.e. Apache, MySQL, etc.) to start on boot or any specific run level.
There are two things to take away from this article, first is a basic knowledge of runlevels, and how to just get a service to run at boot so you don't have to worry about it if your server has to be rebooted.
Here is a little bit of information I've pulled together, I'm trying to stay very topical with this information, cause you can get really deep in system architecture with run levels:
Red Hat as well as most of its derivatives (such as CentOS) uses runlevels like this: ID Description 0 Halt 1 Single user 2 Full multi-user with no networking 3 Full multi-user, console logins only 4 Not used/User definable 5 Full multi-user, with display manager as well as console logins 6 Reboot
Using the diagram above you see in the .rpm architecture there are 7 basic run levels. Pretty easily defined, they all have their purpose but for our use in this article will be 3 and 5. These are your normal operating run levels, level 3 is command line only, level 5 is the same as 3 but will include the X-Window system.
Check the list
First thing we are going to want to do is check the list of available services already configured in chkconfig, you can run this with the following command:
# chkconfig --list
For as much information is spouted out by this command its fairly easy to read, you get a listed service and an "on" status label. Those that are on will start working if not already started when the system changes to the particular run level.
Make a service start for normal usage
This is easy, chkconfig lets you do custom configurations and will allow you to make certain services start only on certain runlevels. For this example we will make a service start on 3,4,and 5:
# chkconfig httpd on
Thats it, turn it on, now apache will start when ever the server is rebooted.
I've got an init script but its not listed in chkconfig
Ok, backing up a little bit chkconfig will only start if there is an available init script(automated service startup script) to start from. If you have this init file listed in /etc/init.d/ you only need to run two commands to get it running at boot:
# chkconfig --config example # chkconfig example on
Keep in mind that "example" is also the name of the init script, they must match.
This was a very topical view of chkconfig that will help you administer your server. If you need to do a more complex configuration or want a more indepth knowledge of the init system in linux you can read the man page for chkconfig or check out http://www.redhat.com/docs/manuals/linux/RHL-7.2-Manual/ref-guide/s1-init-boot-shutdown-init.html.
Brandon Woodward, RHCE 14:06, 6 April 2009 (CDT)
© 2015 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER