The solution is as follows:
You must put the following two lines of comments in the front of the/etc/init. d/redis file:
# Chkconfig: 2345 90 10 # Description: redis is a persistent key-value Database |
The above comment indicates that the redis service must be started or shut down under runtime Level 2, 3, 4, 5. The priority of startup is 90, and the priority of shutdown is 10.
Appendix: Linux running level
The running level is the current running function level of the operating system. This level ranges from 0 to 6 and has different functions. These levels are specified in the/etc/inittab file. This file is INITProgramThe first service to run is the files in the/etc/rc. d directory.
Different runtime levels are defined as follows: (refer to/etc/inittab in Linux)
# The default running level. RHS uses the following levels:
0: Shutdown
1: single-user mode
2: multi-user mode without network support
3: multi-user mode with network support
4: reserved, not used
5. Multi-user mode with network support and X-window support
6. reboot the system.
Detailed explanation of each running level:
0 indicates that the machine is shut down.
1 is the single-user mode, just like the security mode in Win9x.
2: multi-user mode, but not supported by NFS.
3 is a complete multi-user mode, which is a standard operation level.
4. Generally, you can use it to do things in some special cases. For example, you can switch to this mode to make some settings when the battery of your laptop is exhausted.
5 is X11, And it enters the X Window System.
6. Restart the init 6 server.
Chkconfig usage
The chkconfig command can be used to check and set various services of the system.
Syntax:
Chkconfig [-- add] [-- del] [-- list] [System Service] Or chkconfig [-- level <level code>] [System Service] [ON/OFF/Reset]
Parameter usage:
-Add adds the specified system service, enables the chkconfig command to manage it, and adds relevant data in the system startup description file.
-Del: deletes the specified system service. It is no longer managed by the chkconfig command, and relevant data is also deleted in the description file started by the system.
-Level <level code> specifies the execution level of the read system service.
Example:
Chkconfig-list all system services
Chkconfig-add redis to add redis services
Chkconfig-del redis Delete redis Service
Chkconfig-level redis 2345 on sets redis to on (Enabled) when the running level is 2, 3, 4, and 5.