mycat增加开机自启

一、安装及配置:

https://github.com/MyCATApache/Mycat-Server

二、增加开机自启:

1、添加开机自启脚本:vim /etc/init.d/mycat.sh,脚本内容如下:

#!/bin/sh
#
# Simple Mycat init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

### BEGIN INIT INFO
# Provides:     mycat
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Mycat data structure server
# Description:          Mycat data structure server. See https://github.com/MyCATApache/Mycat-Server
### END INIT INFO

EXEC=/usr/local/mycat/bin/mycat
PIDFILE=/usr/local/mycat/logs/mycat.pid

case "$1" in
    start)
        if [ -f $PIDFILE ]
        then
                echo "$PIDFILE exists, process is already running or crashed"
        else
                echo "Starting Mycat server..."
                $EXEC start
        fi
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
                echo "$PIDFILE does not exist, process is not running"
        else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                $EXEC stop
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for Mycat to shutdown ..."
                    sleep 1
                done
                echo "Mycat stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac

2、更改执行权限:chmod u+x mycat.sh

3、增加开机自启:chkconfig mycat.sh on

4、启动mycat服务:systemctl start mycat

5、查看mycat状态:systemctl status mycat

6、停止mycat服务:systemctl stop mycat

 

posted @ 2020-04-20 17:10  水云间月掌柜  阅读(545)  评论(0编辑  收藏  举报