Centos7上关机流程

关闭程序及服务 -请依次检查存在那些程序需要被关闭

  1. 关闭JAVA应用程序(后端)
  2. 关闭nginx反向代理(前端) 80,443
  3. 关闭mysql数据库,先主后从 3306
  4. 关闭redis缓存 6379
  5. 关闭jenkins
  6. 关闭git服务
# 依据监听端口查询进程
netstat -tunlp |grep 6379

关闭脚本

  1. 关闭java 程序,附脚本,替换report.jar为你的程序名
AppName=report.jar;
PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'`

if [ x"$PID" != x"" ]; then
	kill -15 $PID
	echo "$AppName (pid:$PID) exiting..."
	sleep 3
else
	echo "$AppName already stopped."
fi
  1. 手动关闭java程序
# 查询Java程序
jps -lmvV
# 正常关闭
kill -15 进程号
# 关闭不掉强制关闭
kill -9 进程号

附:jenkins重启java程序脚本

BUILD_ID=dontKillMe
echo "打包路径:" 
echo ${WORKSPACE}

cp ${WORKSPACE}/target/report.jar /home/report/report.jar;

cd /home/report;
AppName=report.jar;
PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'`

if [ x"$PID" != x"" ]; then
	kill -9 $PID
	echo "$AppName (pid:$PID) exiting..."
	sleep 3
else
	echo "$AppName already stopped."
fi

rm -f nohup.out
nohup java -jar $AppName --spring.profiles.active=prod >/dev/null 2>&1 &
echo "Start $AppName success..."
  1. 关闭nginx相关脚本
systemctl stop nginx.service
systemctl start nginx.service
systemctl status nginx.service
systemctl restart nginx.service
# 设置开机启动,一般都设置了
systemctl enable nginx.service

4.mysql脚本

#关闭mysql
systemctl stop mysqld
#启动mysql
systemctl start mysqld
#自动启动mysql
systemctl enable mysqld
#查看状态mysql
systemctl status mysqld
  1. redis
# 其他同上
systemctl start redis
  1. jenkins
# 其他同上
 systemctl start jenkins

7.gitlab

gitlab-ctl stop
gitlab-ctl restart
gitlab-ctl start
gitlab-ctl reconfigure
gitlab-ctl status
#其他命令用
gitlab-ctl 查询

你可能感兴趣的:(运维)