• Centos7上关机流程


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

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

    关闭脚本

    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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    1. 手动关闭java程序
    # 查询Java程序
    jps -lmvV
    # 正常关闭
    kill -15 进程号
    # 关闭不掉强制关闭
    kill -9 进程号
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    附: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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    1. 关闭nginx相关脚本
    systemctl stop nginx.service
    systemctl start nginx.service
    systemctl status nginx.service
    systemctl restart nginx.service
    # 设置开机启动,一般都设置了
    systemctl enable nginx.service
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    4.mysql脚本

    #关闭mysql
    systemctl stop mysqld
    #启动mysql
    systemctl start mysqld
    #自动启动mysql
    systemctl enable mysqld
    #查看状态mysql
    systemctl status mysqld
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    1. redis
    # 其他同上
    systemctl start redis
    
    • 1
    • 2
    1. jenkins
    # 其他同上
     systemctl start jenkins
    
    • 1
    • 2

    7.gitlab

    gitlab-ctl stop
    gitlab-ctl restart
    gitlab-ctl start
    gitlab-ctl reconfigure
    gitlab-ctl status
    #其他命令用
    gitlab-ctl 查询
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
  • 相关阅读:
    【毕业设计】基于Vue与SSM的在线聊天系统
    Java - 单例模式详解
    C# 轻量级 ORM 框架 NPoco 的简单应用
    Spring之AOP
    链表的回文判断
    【微信小程序】使用webstorm进行开发,支持代码提示高亮等
    前端下载文件流
    C#中关于DevExpress的常用操作和帮助类项目工程内容说明
    Linux- 僵尸进程(Zombie Process)
    关于 SAP 电商云 Spartacus UI Navigation Service 执行的一些明细
  • 原文地址:https://blog.csdn.net/qq_37293230/article/details/133639032