Last active
November 18, 2019 14:24
-
-
Save michaeljoy/ac94cb9543237e8b9d7d5720fbd88600 to your computer and use it in GitHub Desktop.
pt-heartbeat systemd init script example - percona tookit systemd examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mysql] | |
host=localhost | |
socket=/var/run/mysqld/mysqld.sock | |
[client] | |
host=localhost | |
socket=/var/run/mysqld/mysqld.sock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
utc | |
replace | |
daemonize | |
pid=/var/run/pt-heartbeat-databasenamehere.pid | |
socket=/var/run/mysqld/mysqld.sock | |
database=databasenamehere | |
table=heartbeat | |
interval=0.01 | |
user=insert_low_privilege_mysql_user_here | |
password=insert_low_privilege_mysql_user_password_here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# pt-heartbeat systemd service file for databasenamehere | |
# | |
[Unit] | |
Description="pt-heartbeat" | |
After=network-online.target syslog.target | |
Wants=network-online.target | |
[Install] | |
WantedBy=multi-user.target | |
[Service] | |
Type=forking | |
PIDFile=/var/run/pt-heartbeat-databasenamehere.pid | |
ExecStart=/usr/bin/pt-heartbeat "--config=/etc/percona-toolkit/pt-heartbeat-databasenamehere.conf" "--defaults-file=/etc/percona-toolkit/my.cnf" "--update" | |
StandardOutput=syslog | |
StandardError=syslog | |
SyslogIdentifier=pt-heartbeat | |
Restart=on-abort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Grants for 'pt_heartbeat'@'10.%' | |
CREATE USER IF NOT EXISTS 'pt_heartbeat'@'10.%'; | |
ALTER USER 'pt_heartbeat'@'10.%' IDENTIFIED WITH 'mysql_native_password' AS 'INSERTREALLYSECUREPASSWORDHERE' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK; | |
GRANT DELETE, INSERT, SELECT, UPDATE ON `databasenamehere`.`heartbeat` TO 'pt_heartbeat'@'10.%'; | |
GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'pt_heartbeat'@'10.%'; | |
-- Grants for 'pt_heartbeat'@'127.0.0.1' | |
CREATE USER IF NOT EXISTS 'pt_heartbeat'@'127.0.0.1'; | |
ALTER USER 'pt_heartbeat'@'127.0.0.1' IDENTIFIED WITH 'mysql_native_password' AS 'INSERTREALLYSECUREPASSWORDHERE' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK; | |
GRANT DELETE, INSERT, SELECT, UPDATE ON `databasenamehere`.`heartbeat` TO 'pt_heartbeat'@'127.0.0.1'; | |
GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'pt_heartbeat'@'127.0.0.1'; | |
-- Grants for 'pt_heartbeat'@'localhost' | |
CREATE USER IF NOT EXISTS 'pt_heartbeat'@'localhost'; | |
ALTER USER 'pt_heartbeat'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS 'INSERTREALLYSECUREPASSWORDHERE' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK; | |
GRANT DELETE, INSERT, SELECT, UPDATE ON `databasenamehere`.`heartbeat` TO 'pt_heartbeat'@'localhost'; | |
GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'pt_heartbeat'@'localhost'; |
@michaeljoy I actually am running that systemd config on Amazon Linux 2(4.14.146-120.181.amzn2.x86_64).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I updated the gist with your suggested systemd configuration... just curious, which version of Ubuntu are you utilizing this on @jonathan-russo ? Originally this was implemented on Ubuntu 14.04 so it's quite a bit older than current at this point. Also, for posterity and anyone reading this, when running parallel GTID replication threads, replication lag is not consistent across all hosted databases. So you need to track this 'per database' in such cases that you're using parallel replication threads in some of the more enhanced MySQL replication configuration subsets.