cenOS系统,chkconfig设置程序开机自启--mysql、tomcat、redis、fastdfs--nginx/fdfs_trackerd/fdfs_storaged

设置程序开机启动就是将程序的启动脚本添加到/etc/init.d目录下,或者将启动路径写入/etc/rc.d/rc.local文件里面.

设置mysql开机启动

cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysql
chkconfig --add mysql
chkconfig  mysql  on

设置fdfs_tracker开机启动

cp /usr/local/src/FastDFS/init.d/fdfs_trackerd /etc/init.d/
chkconfig --add fdfs_trackerd
chkconfig fdfs_trackerd on

设置fdfs_storafed开机启动

cp /usr/local/src/FastDFS/init.d/fdfs_storaged /etc/init.d/
chkconfig --add fdfs_storaged
chkconfig fdfs_storaged on

设置redis开机启动

cp  /usr/local/src/redis-stable/utils
./install_server.sh 

具体配置可以详见http://www.open-open.com/lib/view/open1355055890117.html

设置tomcat开机启动

在startup.sh文件中添加如下内容

vim  /usr/local/tomcat/bin/startup.sh
i            //代表进入文档输入模式
#!/bin/sh                 //#不能少
# chkconfig: 2345 97 00
# description:tomcat auto start
# processname: tomcat

在catalina.sh文件中增加如下内容

vim  /usr/local/tomcat/bin/catalina.sh
i                                                //进入输入模式
export CATALINA_BASE=/usr/local/tomcat          //根据实际情况填写路径
export CATALINA_HOME=/usr/local/tomcat         //根据实际情况填写路径
export CATALINA_TMPDIR=/usr/local/tomcat/temp  //根据实际情况填写路径
export JRE_HOME=/usr/java/jdk1.7.0_55
                                              //按esc键
:wq                                          //保存并退出

创建软连接

ln -s /usr/local/tomcat/bin/startup.sh /etc/init.d

设置启动

chkconfig --add tomcat
chkconfig tomcat on

设置nginx开机启动

在/etc/init.d目录下新建nginx文档

vim /etc/init.c/ngin 

写入一下命令并保存

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#              It has a lot of features, but it‘s not for everyone.
# processname: nginx
# pidfile: /usr/local/nginx/logs/nginx.pid    //根据实际情况修改
# config: /usr/local/nginx/conf/nginx.conf     //根据实际情况修改
nginxd=/usr/local/nginx/sbin/nginx    //根据实际情况修改
nginx_config=/usr/local/nginx/conf/nginx.conf    //根据实际情况修改
nginx_pid=/usr/local/nginx/logs/nginx.pid    //根据实际情况修改
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
   echo "nginx already running...."
   exit 1
fi
   echo -n $"Starting $prog: "
   daemon $nginxd -c ${nginx_config}
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
   return $RETVAL
}
# Stop nginx daemons functions.
stop() {
        echo -n $"Stopping $prog: "
        killproc $nginxd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx  /usr/local/nginx/logs/nginx.pid    //根据实际情况修改
}
# reload nginx service functions.
reload() {
    echo -n $"Reloading $prog: "
    #kill -HUP `cat ${nginx_pid}`
    killproc $nginxd -HUP
    RETVAL=$?
    echo
}
# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        stop
        start
        ;;
status)
        status $prog
        RETVAL=$?
        ;;
*)
        echo $"Usage: $prog {start|stop|restart|reload|status|help}"
       exit 1
esac
exit $RETVAL

设置开启启动

chkconfig --add  nginx
chkconfig nginx on

cenOS系统,chkconfig设置程序开机自启--mysql、tomcat、redis、fastdfs--nginx/fdfs_trackerd/fdfs_storaged,布布扣,bubuko.com

时间: 2024-10-21 03:03:41

cenOS系统,chkconfig设置程序开机自启--mysql、tomcat、redis、fastdfs--nginx/fdfs_trackerd/fdfs_storaged的相关文章

centos设置程序开机自启或禁止加载

1. 可以直接把需要启动的脚本写到/etc/rc.d/rc.local文件里,例如 vim /etc/rc.d/rc.local /usr/local/apache/bin/apachectl start 2. Chkconfig用法(旧版) (1)chkconfig --level [0123456] [service name] [on|off] chkconfig --level 23 dhcp3-server off ----设定dhcp server服务在level2,3下关闭. (2

cenOS设置程序开机自启动的方法

cenOS设置程序开机自启动的方法主要有两种 1.把启动程序的命令添加到/etc/rc.d/rc.local 文件夹中. eg1.设置开机启动mysql vim /etc/rc.d/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

VS2012+C语言+设置程序开机自动启动+示例

#include <stdio.h> #include <windows.h> #include <stdlib.h> char* ReplaceString(const char *srcStr, const char *src, const char *dest) //替换字符串,获得文件路径 { char *ptr; int len = strlen(srcStr); ptr = (char*)malloc(sizeof(char)*len+1); strcpy(

WPF 设置程序开机自动运行(+注册表项)

#region 设置程序开机自动运行(+注册表项) RegistryKey rgkRun = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (rgkRun == null) { rgkRun = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\Cur

C#如何设置程序开机自启动

如果想要将一个exe程序设置为开机自启动,其实就是在HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run注册表项中添加一个注册表变量,这个变量的值是程序的所在路径. 具体操作步骤是: 1.使用RegistryKey类的CreateSubKey方法打开HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Ru

CentOS设置程序开机自启动的方法

转自:http://www.centos.bz/2011/09/centos-setup-process-startup-boot/ 在CentOS系统下,主要有两种方法设置自己安装的程序开机启动. 1.把启动程序的命令添加到/etc/rc.d/rc.local文件中,比如下面的是设置开机启动httpd. #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put you

在Linux系统如何让程序开机时自动启动

核心提示:系统的服务在开机时一般都可以自动启动,那在linux系统下如果想要程序在开机时自动启动怎么办?我们知道在 windows系统"开始"-->"所有程序"-->"启动"里面放个快捷方式就行,那Linux系统下呢?...系统的服务在开机时一般都可以自动启动,那在linux系统下如果想要程序在开机时自动启动怎么办?我们知道在 windows系统"开始"-->"所有程序"-->&qu

[转]CentOS设置程序开机自启动的方法

在CentOS系统下,主要有两种方法设置自己安装的程序开机启动.1.把启动程序的命令添加到/etc/rc.d/rc.local文件中,比如下面的是设置开机启动httpd. #!/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 ful

CentOS设置程序开机启动程序/服务的方法(转)

注意:CentOS 6下基本没什么问题,CentOS 7估计不一定能行. 在CentOS系统下,主要有两种方法设置自己安装的程序开机启动. 1.把启动程序的命令添加到/etc/rc.d/rc.local文件中,比如下面的是设置开机启动httpd. #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in