MySQL 在 Ubuntu 11.04 上每 30 分钟重新启动一次

发布于 2024-12-12 20:25:39 字数 3413 浏览 4 评论 0原文

我遇到一个问题,MySQL 5.1.54 在 Ubuntu 11.04 上每 30 分钟重新启动一次。发生这种情况时,MySQL 日志中会出现以下内容:

111030 12:01:52 [Note] /usr/sbin/mysqld: Normal shutdown

111030 12:01:52 [Note] Event Scheduler: Purging the queue. 0 events
111030 12:01:52  InnoDB: Starting shutdown...
111030 12:01:54  InnoDB: Shutdown completed; log sequence number 0 875122
111030 12:01:54 [Note] /usr/sbin/mysqld: Shutdown complete

111030 12:01:55 [Note] Plugin 'FEDERATED' is disabled.
111030 12:01:55  InnoDB: Initializing buffer pool, size = 256.0M
111030 12:01:55  InnoDB: Completed initialization of buffer pool
111030 12:01:55  InnoDB: Started; log sequence number 0 875122
111030 12:01:55 [Note] Event Scheduler: Loaded 0 events
111030 12:01:55 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.54-1ubuntu4-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

这种情况每 30 分钟就会发生一次,因此显然是某些服务重新启动了它。

我检查了系统上每个用户(包括系统用户)的 crontab,他们都没有 crontab 设置,正如您在下面的输出中看到的:

# awk -F: '{print $1}' /etc/passwd | xargs -n 1 -i crontab -u {} -l  
no crontab for root
no crontab for daemon
no crontab for bin
no crontab for sys
no crontab for sync
no crontab for games
no crontab for man
no crontab for lp
no crontab for mail
no crontab for news
no crontab for uucp
no crontab for proxy
no crontab for www-data
no crontab for backup
no crontab for list
no crontab for irc
no crontab for gnats
no crontab for nobody
no crontab for libuuid
no crontab for syslog
no crontab for sshd
no crontab for landscape
no crontab for ubuntu
no crontab for statd
no crontab for myproxy
no crontab for condor
no crontab for messagebus
no crontab for avahi
no crontab for joe
no crontab for smmta
no crontab for smmsp
no crontab for postfix
no crontab for deploy
no crontab for mysql
no crontab for redis

我的 dmesg 每次重新启动时都会包含以下内容。我不是 apparmor 专家,但我相信这是每次 MySQL 服务启动时获得的正常消息:

[1165328.780405] type=1400 audit(1319976114.984:74): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=31985 comm="apparmor_parser"

另外,这里是 /etc/init/mysql.conf 中 MySQL upstart 配置的内容:

# MySQL Service

description     "MySQL Server"
author          "Mario Limonciello <[email protected]>"

start on (net-device-up
          and local-filesystems
      and runlevel [2345])
stop on runlevel [016]

respawn

env HOME=/etc/mysql
umask 007

# The default of 5 seconds is too low for mysql which needs to flush buffers
kill timeout 300

pre-start script
    #Sanity checks
    [ -r $HOME/my.cnf ]
    [ -d /var/run/mysqld ] || install -m 755 -o mysql -g root -d /var/run/mysqld
    /lib/init/apparmor-profile-load usr.sbin.mysqld
    LC_ALL=C BLOCKSIZE= df --portability /var/lib/mysql/. | tail -n 1 | awk '{ exit ($4<4096) }'
end script

exec /usr/sbin/mysqld

post-start script
   for i in `seq 1 30` ; do
        /usr/bin/mysqladmin --defaults-file="${HOME}"/debian.cnf ping && {
            exec "${HOME}"/debian-start
            # should not reach this line
            exit 2
        }
        sleep 1
    done
    exit 1
end script

知道可能是什么造成这个?它不会引起任何问题,除了 Monit 警报指出“PID 更改了服务 mysqld”(我有 Monit 监视 mysqld ——但它报告 mysqld 进程没有错误,除了每 30 分钟它有一个错误) MySQL 重新启动后 PID 发生变化)。

提前致谢。

I'm having an issue where MySQL 5.1.54 is restarting every 30 minutes on Ubuntu 11.04. When this occurs, the following appears in the MySQL log:

111030 12:01:52 [Note] /usr/sbin/mysqld: Normal shutdown

111030 12:01:52 [Note] Event Scheduler: Purging the queue. 0 events
111030 12:01:52  InnoDB: Starting shutdown...
111030 12:01:54  InnoDB: Shutdown completed; log sequence number 0 875122
111030 12:01:54 [Note] /usr/sbin/mysqld: Shutdown complete

111030 12:01:55 [Note] Plugin 'FEDERATED' is disabled.
111030 12:01:55  InnoDB: Initializing buffer pool, size = 256.0M
111030 12:01:55  InnoDB: Completed initialization of buffer pool
111030 12:01:55  InnoDB: Started; log sequence number 0 875122
111030 12:01:55 [Note] Event Scheduler: Loaded 0 events
111030 12:01:55 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.54-1ubuntu4-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

This occurs like clockwork every 30 minutes, so it's obviously some service restarting it.

I have checked the crontab of every user on the system (including system users), and none of them have a crontab setup, as you can see in the output below:

# awk -F: '{print $1}' /etc/passwd | xargs -n 1 -i crontab -u {} -l  
no crontab for root
no crontab for daemon
no crontab for bin
no crontab for sys
no crontab for sync
no crontab for games
no crontab for man
no crontab for lp
no crontab for mail
no crontab for news
no crontab for uucp
no crontab for proxy
no crontab for www-data
no crontab for backup
no crontab for list
no crontab for irc
no crontab for gnats
no crontab for nobody
no crontab for libuuid
no crontab for syslog
no crontab for sshd
no crontab for landscape
no crontab for ubuntu
no crontab for statd
no crontab for myproxy
no crontab for condor
no crontab for messagebus
no crontab for avahi
no crontab for joe
no crontab for smmta
no crontab for smmsp
no crontab for postfix
no crontab for deploy
no crontab for mysql
no crontab for redis

My dmesg contains the following each time it is restarted. I'm not an apparmor expert, but I believe this is a normal message obtained each time the MySQL service starts:

[1165328.780405] type=1400 audit(1319976114.984:74): apparmor="STATUS" operation="profile_replace" name="/usr/sbin/mysqld" pid=31985 comm="apparmor_parser"

Also, here are the contents of the MySQL upstart configuration in /etc/init/mysql.conf:

# MySQL Service

description     "MySQL Server"
author          "Mario Limonciello <[email protected]>"

start on (net-device-up
          and local-filesystems
      and runlevel [2345])
stop on runlevel [016]

respawn

env HOME=/etc/mysql
umask 007

# The default of 5 seconds is too low for mysql which needs to flush buffers
kill timeout 300

pre-start script
    #Sanity checks
    [ -r $HOME/my.cnf ]
    [ -d /var/run/mysqld ] || install -m 755 -o mysql -g root -d /var/run/mysqld
    /lib/init/apparmor-profile-load usr.sbin.mysqld
    LC_ALL=C BLOCKSIZE= df --portability /var/lib/mysql/. | tail -n 1 | awk '{ exit ($4<4096) }'
end script

exec /usr/sbin/mysqld

post-start script
   for i in `seq 1 30` ; do
        /usr/bin/mysqladmin --defaults-file="${HOME}"/debian.cnf ping && {
            exec "${HOME}"/debian-start
            # should not reach this line
            exit 2
        }
        sleep 1
    done
    exit 1
end script

Any idea what might be causing this? It doesn't cause any problems, other than Monit alerts stating that "PID changed Service mysqld" (I have Monit monitoring mysqld -- but it reports no errors with the mysqld process, other than the fact that every 30 minutes, it has its PID changed since MySQL is restarted).

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

内心激荡 2024-12-19 20:25:39

您使用的是 Chef 或 Puppet,它们可能正在做一些触发重启的事情?

are you using chef or puppet, which might be doing something that triggers the reboot?

靑春怀旧 2024-12-19 20:25:39

你能检查(并可能发布)你的 mysql 工作在 upstart 中的定义吗? (/etc/init/mysql.conf)。好的=尝试删除“重生”。它不像新贵文档中记录的那样工作。通常,如果该进程被其他进程杀死,它会用于重新生成该进程,但它似乎没有按预期运行。您可以看到为什么 apparmour 总是加载 - 因为脚本中的预启动节。
由于新贵是非常新的,并且仍在不断发展,因此更好的是使用 SysV 方式。

can you check (and probably post) the definition of your mysql job in upstart? (/etc/init/mysql.conf). OK = try removing the "respawn". It does not work as documented in the upstart documentation. Generally it's used to respawn the process if it's killed by other process, but it seems it does not function as expected. You can see why the apparmour is always loading - because of the pre-start stanza in the script.
As upstart is very new, and is still evolving, better is to use the SysV way.

呢古 2024-12-19 20:25:39

您应该尝试在没有 AppArmor 的情况下运行它:只需运行 /usr/bin/mysqld_safe/usr/bin/mysqld 而不使用 upstart 并等待 30 分钟。如果 mysql 没有自动重启,则在 /etc/init/mysql.conf 文件中禁用 AppArmor,或者进行不同的配置。

如果问题仍然存在,请阅读mysql的日志。如果默认情况下未启用日志,则可以在启动 mysqld 时使用选项--log-error=/tmp/mysql.log --log-warnings

You should try to run it without AppArmor: just run /usr/bin/mysqld_safe or /usr/bin/mysqld without using upstart and wait 30 minutes. If mysql does not auto-restart, then disable AppArmor in the /etc/init/mysql.conf file, or configure it differently.

If the problem is still there, read mysql's log. If the log is not enabled by default, you can use the option --log-error=/tmp/mysql.log --log-warnings when launching mysqld.

漆黑的白昼 2024-12-19 20:25:39

似乎将 /etc/init.d/mysql 启动脚本转换为 sysV 样式而不是作为新贵脚本似乎为我纠正了问题。

Seems converting the /etc/init.d/mysql start up script to sysV style rather than as an upstart script seemed to correct the problem for me.

假装不在乎 2024-12-19 20:25:39

我在升级到 Ubuntu 14.04 时遇到了同样的问题。我发现这个问题是因为它提到了 AppArmor 日志消息,所以谢谢!否则我可能没有意识到 MySQL 正在重新启动。

在调查 /var/log/daemon.log 后,我发现 /etc/mysql/debian-start 的输出重复出现。相关部分是这样的:

May 18 06:48:18 tom /etc/mysql/debian-start[15525]: Upgrading MySQL tables if necessary.
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: Looking for 'mysql' as: /usr/bin/mysql
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: Error: Server version (5.5.35-1ubuntu1) does not match with the version of
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: the server (5.5.37) with which this program was built/distributed. You can
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: use --skip-version-check to skip this check.
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: FATAL ERROR: Upgrade failed

我通读了 /etc/mysql/debian-start 脚本并尝试按照脚本中的方式运行升级命令,希望能够调试它(MySQL 服务器需要运行在time):

/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf

然后我发现这毫无怨言地起作用,从那时起一切都正常了。我不知道为什么它一开始就失败了,但这似乎解决了它。从那以后MySQL就没有重新启动过。

I had this same problem upgrading to Ubuntu 14.04. I found this question because it mentions the AppArmor log message, so thanks! I may not have realised MySQL was restarting otherwise.

Upon investigating /var/log/daemon.log, I found the output of /etc/mysql/debian-start appearing repeatedly. The relevant part was this:

May 18 06:48:18 tom /etc/mysql/debian-start[15525]: Upgrading MySQL tables if necessary.
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: /usr/bin/mysql_upgrade: the '--basedir' option is always ignored
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: Looking for 'mysql' as: /usr/bin/mysql
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: Error: Server version (5.5.35-1ubuntu1) does not match with the version of
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: the server (5.5.37) with which this program was built/distributed. You can
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: use --skip-version-check to skip this check.
May 18 06:48:18 tom /etc/mysql/debian-start[15528]: FATAL ERROR: Upgrade failed

I read through the /etc/mysql/debian-start script and tried running the upgrade command as in the script, hoping to debug it (MySQL server needs to be running at the time):

/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf

I then found that this worked without complaint and everything simply worked from that point onward. I don't know why it was failing in the first place, but that seemed to fix it. MySQL hasn't restarted itself since.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文