Chkconfig command is mainly used to update run-level information (start or stop) and query system services. Remember chkconfig not immediately automatically disable or activate a service, it simply changes the symbolic link.
First, chkconfig usage syntax
1, chkconfig [--add] [- del] [- list] [system service] or chkconfig [--level < levels Level code>] [System Services] [on / off / reset]
2, the parameter usage:
--add increase in the specified system services to chkconfig command to manage it, and at the same time increasing the relevant data in the system startup file description.
--del delete the specified system service is no longer managed by the chkconfig command and delete related data in the system startup file description.
--level < level code> Specify read System Services To turn on or off the completion of execution in which a hierarchy.
Level 0 means: showing off
Level 1 means: single-user mode
Level 2 indicates: no network connection multi-user command line mode
Level 3 means: multi-user command line mode with networking
Level 4 indicates: System Reserved
Level 5 indicates: multi-user mode with GUI
Level 6, said: Restart
3. It should be noted, level option to specify the run level you want to view and not necessarily the current run level. For each run level, only one startup script or a stop script. When switching run level, init does not restart the service has been launched, it will not have to stop to stop the service again.
4, chkconfig --list [name]: Displays the operating status of all information systems and services run level (on or off). If you specify a name, then display only the specified service status at different operating levels.
5, chkconfig --add name: to add a new service. chkconfig to ensure that each class has a running start (S) or killed (K) entrance. If anything is missing, it will automatically created from the default init scripts.
chkconfig --del name: delete the service, and the related symbolic link from /etc/rc[0-6].d.
chkconfig [--level levels] name: set a service running at the specified level is to be started, stopped or reset.
6, run the file level:
Each needed chkconfig management services under the corresponding init.d script plus two more lines or comment lines. The first line tells chkconfig default startup run level and start and stop priority. If a service is not in any default run level start, use - instead of run level. The second line of the service description, you can use \ interbank comment.
For example, random.init contain three lines:
# Chkconfig: 2345 20 80
# Description: Saves and restores system entropy pool for \
# Higher quality random number generation.
Use of examples:
chkconfig --list # List all system services
chkconfig --add httpd # service httpd increase
chkconfig --del httpd # delete httpd service
chkconfig --level 2345 httpd on # httpd set in the case of 2,3,4,5 runlevel is on (open) state
chkconfig --list # lists all system services startup situation
chkconfig --list mysqld # listed mysqld service settings circumstances
chkconfig --level 35 mysqld on # set mysqld in grades 3 and 5 to start running services, - level 35 indicates the operation in grades 3 and 5 perform only, on start showing, off means closed
chkconfig mysqld on # mysqld set in each grade on, "each grade" rating include 2,3,4,5
7, how to add a service: A Case Study in mysqld
(1), service script must be stored in the /etc/init.d/ directory;
(2), chkconfig --add mysqld # added services, increase service chkconfig tool in the list of services, then the service will be given in /etc/rc.d/rcN.d in K / S inlet;
(3), chkconfig --level 35 mysqld on # to modify the default service startup level.
Second, the service startup / shutdown
1, system services: it remains in memory, and has been running and providing services is called a service;
2, while the service is running, then the program is running is called daemons;
3, the startup script for these services are generally placed in: /etc/init.d
4, CentOS service startup scripts in: /etc/rc.d/init.d and accepted this directory /etc/init.d directory is a link file in the /etc/init.d centos
5, / etc / sysconfig service initialization environment variable configuration in this file.
6, the database / var / lib various services generated in this directory, the easiest to use vim found here mysql open you can see, the name of the database you created and the default database generated in the inside!
7, the start / stop / restart services: /etc/init.d/ serverName start / stop / restart / status
8, start / stop / restart services: service serverName start / stop / restart Why can write?
9, service is a script that he can analyze your behind assigned parameters, and then according to your parameters to /etc/init.d go get the proper service to stop start restart