zoukankan      html  css  js  c++  java
  • CentOS 7下systemd是如何stop mysql服务的

     

     

    【背景】

    有同事在研究mongo的服务启动方式,讨论到mysql5.7的服务管理时一起做了下面测试。

    MySQL5.7是用systemd来管理service的,它的配置文件/usr/lib/systemd/system/mysqld@.service中,只定义了ExecStart启动服务器的命令,

    但没有定义ExecStop参数,就是停止mysqld服务时执行的命令。systemd究竟是如何stop mysql服务的。

    【测试步骤】

    1、执行关闭服务的命令

    systemctl stop mysqld@replica02.service

    2、使用systemtap脚本来抓取kill进程时的信号量

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    global target;
    global signal;
     
    probe begin
    {
            printf("%-6s %-12s %-5s %-6s %6s ""FROM""COMMAND""SIG""TO",
                "RESULT");
    }
    probe nd_syscall.kill
    {
            target[tid()] = uint_arg(1);
            signal[tid()] = uint_arg(2);
    }
    probe nd_syscall.kill.return
    {
            if (target[tid()] != 0) {
                    printf("%-6d %-12s %-5d %-6d %6d ", pid(), execname(),
                        signal[tid()], target[tid()], int_arg(1));
                    delete target[tid()];
                    delete signal[tid()];
            }
    }

      

    3、可以看到上面的mysqld进程127531被systemd进程kill掉了,先传15,再传18两个信号量

    相当于执行了kill -15 127531,kill -18 127531两个命令

    4、从文档中也找到了说明,

    KillSignal参数可以指定停止进程时使用的信号,默认值为15 SIGTERM ,另外systemd会紧跟此信号再发送一个18 SIGCONT信号,以确保杀死已挂起的进程。

    KillSignal=Specifies which signal to use when killing a service. This controls the signal that is sent as first step of shutting down a unit (see above), and is usually followed by SIGKILL (see above and below). For a list of valid signals, see signal(7). Defaults to SIGTERM.

    Note that, right after sending the signal specified in this setting, systemd will always send SIGCONT, to ensure that even suspended tasks can be terminated cleanly.

  • 相关阅读:
    delphi7 stringgrid 点列头排序
    如何作为一个优秀的ERP实施顾问
    小米生态链去年收入150亿,今年目标200亿
    msys2 安装笔记(可以按照这个关键字搜索)
    MinGW 编译 libsndfile-1.0.25(只要有 MSYS,./configure make make install 就行了)
    Apache Ignite——新一代数据库缓存系统
    VS2015 C#6.0
    Webuploader 大文件分片上传
    requirejs
    require.js
  • 原文地址:https://www.cnblogs.com/DataArt/p/10250335.html
Copyright © 2011-2022 走看看