1,创建启动脚本
vi /home/minio/start.sh
#!/bin/bash
ROOT_DIR=/home/minio
MINIO_ROOT_USER=admin MINIO_ROOT_PASSWORD=Nidw8asz91.s6 $ROOT_DIR/minio server $ROOT_DIR/data --address=":9000" --console-address=":9001" &
echo $(ps -ef|grep "minio server"|grep -v "grep"|awk '{print $2}') > /var/run/minio_9000.pid
2,创建开机自启脚本
vi /etc/rc.d/init.d/minio
#!/bin/bash
### BEGIN INIT INFO
# Provides: minio_9000
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Minio server
# Description: Minio server
### END INIT INFO
EXEC=/home/minio/start.sh
PIDFILE=/var/run/minio_9000.pid
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Minio server..."
sh $EXEC
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
kill -9 $PID
rm -rf $PIDFILE
echo "Minio stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
3,配置权限
chmod +x /etc/rc.d/init.d/minio
4,配置服务
chkconfig --add minio
chkconfig minio on
5,启动服务
service minio start