[systemd-devel] My experience with MySQL and systemctl
Kai Krakow
hurikhan77 at gmail.com
Tue Apr 11 13:34:50 UTC 2017
Am Tue, 11 Apr 2017 15:08:35 +0200
schrieb Lennart Poettering <lennart at poettering.net>:
> > Eventually, after checking all our backups, I decided to issue kill
> > -9 to mysqld. I then decided to try restarting the daemon using
> > systemctl. It did start up, the log output showed the crash recovery
> > procedure, but because it entered into the rollback recovery,
> > systemctl never considered that the process had finished starting
> > up, and then tried to kill it again, which failed (only kill -9
> > would work in this case). Again, log output was closed.
>
> Again, we really don't do that. Logging is actually pretty independent
> from service management when it comes to keeping the connections open:
> all systemd does is set up the connection, fork off the process and
> that's it. The forked processes can keep the connections open as long
> as they wish, or even pass them on to other processes if they like...
>
> That said, there's one long-standing race: if a process logs through
> syslog(), and very quickly after that exits we under some
> circumstances have trouble matching up the log output with the
> originating service. That's because the SCM_CREDENTIAL data we get for
> the logged messages might reference a PID which already disappeared
> from /proc/$PID which we hence cannot read the cgroup membership info
> from.
>
> Hence: maybe the logs are there, but the filtering didn't work the way
> you expect?
Chances are that he's using the mysqld_safe script which does all kinds
of stuff in a bash script, like detaching the daemon, pipe the logging,
do process monitoring. Essentially, what systemd can already do just
better. It's also doing the "kill -9" stuff.
I'd like to know first if the daemon is properly started by systemd
itself and not some intermediate script.
I'm using the following drop-in as a starter:
$ cat /etc/systemd/system/mysqld.service.d/override.conf
[Service]
Type=simple
Restart=on-failure
ExecStart=
ExecStart=/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --pid-file=/run/mysqld/mysqld.pid
RuntimeDirectory=mysqld
RuntimeDirectoryMode=0755
WorkingDirectory=/var/lib/mysql
--
Regards,
Kai
Replies to list-only preferred.
More information about the systemd-devel
mailing list