ln -s /etc/init.d/heartbeat /etc/rc.d/rc0.d/K05heartbeat
ln -s /etc/init.d/heartbeat /etc/rc.d/rc3.d/S75heartbeat
ln -s /etc/init.d/heartbeat /etc/rc.d/rc5.d/S75heartbeat
ln -s /etc/init.d/heartbeat /etc/rc.d/rc6.d/K05heartbeat
或者
chkconfig --level 0356 heartbeat on
S是start执行的意思,K是Kill关闭不执行
0 - 停机
1 - 单用户模式
2 - 多用户,但是没有NFS ,不能使用网络
3 - 完全多用户模式,我最喜欢的模式
4 - “打酱油” 模式,没有用到
5 - X11 桌面模式
6 - 重新启动 (如果将默认启动模式设置为6,Linux将会不断重启)
其中,k05,s75数字表示运行的优先级,数字越大,优先级越小
自动启动
新建脚本 /etc/init.d/ 目录下
[[email protected] rc6.d]# more /etc/init.d/killheartbeat
#!/bin/sh
ps -ef | grep heartbeat |grep -v grep | awk {'print $2'} | xargs kill -9
分加在 rc0.d rc3.d rc6.d 目录下建立 软连接 (文件名开头K(关机)数字+名子。如
K05killheartbeat -> /etc/init.d/killheartbeat
ln -s /etc/init.d/killheartbeat K05killheartbeat
还要在/var/lock/subsys/下面 copy 或 软件连接 killheartbeat 脚本。
在rc.local 添加启动脚本。
[[email protected] ~]# more /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/root/apache-tomcat-7.0.29/bin/startup.sh
#/root/htkey/test &
ln -s /etc/init.d/killheartbeat /var/lock/subsys/killheartbeat
sleep 140 #主机才设置
/etc/init.d/heartbeat start &