一.mysql
1.vi mysqldauto
#!/bin/sh
# Version: 0.1 by orczhou@gmail.com
mysqld_safe=`which mysqld_safe`
$mysqld_safe --defaults-file=/data/my.cnf &
2.chmod +x mysqldauto
3.mv mysqldauto /etc/rc.d/init.d/
4.ln -s /etc/rc.d/init.d/mysqldauto /etc/rc.d/rc3.d/S99mysqld
二、mongod
1.vi mongodauto
#!/bin/sh
/usr/local/mongodb/bin/mongod --config /mongodb/rs1/mongod.conf
2.chmod +x mongodauto
3.mv mongodauto/etc/rc.d/init.d/
4.ln -s /etc/rc.d/init.d/mongodauto /etc/rc.d/rc3.d/S99mongod
参考博客1