I want to start pt-heartbeat as a systemd service, but it doesn’t work. Here is what I have done so far:
I created a database, heartbeat, and a user, heart with password heartbeat (or something…).
I can start pt-heartbeat with pt-heartbeat -D heartbeat --daemonize --update --ask-pass --utc, and I can see the command in the process list. But of course, I can only do this manually, and I want to start it from a systemd service. I’ve tried different variants of:
pt-heartbeat -D heartbeat --daemonize --update --utc -u heart -pheartbeat
This failed at first with:
DBD::mysql::db selectrow_hashref failed: Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation [for Statement “SHOW MASTER STATUS”] at /usr/bin/pt-heartbeat line 6189.
This means that a connection was successful, but a privilege were missing, so I granted that. Now I get no error, but it also doesn’t turn up in the process list, and the table is not updated.
What am I doing wrong here?
Can you share your entire unit file?
1 Like
I can:
rgs-mi-db-1 root = cat /etc/systemd/system/heartbeat.service
[Unit]
Description=Percona Heartbeat Service
After=mysql.service
Documentation=https://www.percona.com/doc/percona-toolkit/2.1/pt-heartbeat.html
[Service]
Type=simple
ExecStart=/usr/bin/pt-heartbeat -D heartbeat --update -u heart -pheartbeat --utc --daemonize
ExecStop=/usr/bin/pt-heartbeat --stop
StandardOutput=null
Restart=on-failure
[Install]
Alias=heartbeat.service
But I don’t think this is relevant - when I run the command manually, it simply doesn’t fork off a child process, although it clearly connects with the database.
Edit
I’ve run a few more experiments - all failed: I’ve tried various combinations of not specifying the user, using --ask-pass etc, and it seems that no versions work now, not even the one I had working at first:
/usr/bin/pt-heartbeat -D heartbeat --update --ask-pass --utc --daemonize
Unfortunately I don’t do perl, so although I canread the code, there’s a lot of cnnstruction in there that I don’t quite get.
1 Like
After reading the man page carefully, it turns out that it is in fact the ExecStop
clause in the service file:
ExecStop=/usr/bin/pt-heartbeat --stop
--stop
creates a sentinel file, which then hangs around indefinitely and stops the script from daemonizing. I’ll have to look for another way to shut down, I suppose.
1 Like
I would use --pid
option to create a pid file and supply that to the unit file. That way systemd can control the script with simple KILL signals.