diff --git a/HowtoHearthbeat.md b/HowtoHearthbeat.md index 8fa1718f..3bd44c37 100644 --- a/HowtoHearthbeat.md +++ b/HowtoHearthbeat.md @@ -2,7 +2,7 @@ # Howto Hearthbeat -Documentation officielle : +Documentation officielle : ## Tuer un Hearthbeat planté diff --git a/HowtoMySQL/Percona.md b/HowtoMySQL/Percona.md new file mode 100644 index 00000000..c0abd6ca --- /dev/null +++ b/HowtoMySQL/Percona.md @@ -0,0 +1,65 @@ +--- +categories: databases +title: Howto Percona +... + +Le guide d'installation et d'usage courant, voir [HowtoMySQL](/HowtoMySQL). +La documentation sur [Percona](https://www.percona.com/software/documentation). + +## Monitoring d'une réplication + +### pt-heartbeat + +Dans le paquet `perconal-toolkit` on trouvera un outil pour mesurer la latence dans la réplication d'une meilleure façon que nativement. +L'astuce consiste à insérer une valeur datée de l'heure actuelle (timestamp) sur le master et comparer le timestamp avec la date du slave. + +~~~ +# mysql -e "CREATE DATABASE percona;" +# mysql -e "GRANT ALL PRIVILEGES ON \`percona\`.* TO 'percona'@'%' IDENTIFIED BY 'password';" +# mysql -e "GRANT REPLICATION CLIENT ON *.* TO 'percona'@'%';" +# adduser --disabled-password percona +# vim /home/percona/.my.cnf + +[client] +user = percona +password = password + +# chmod 600 /home/percona/.my.cnf +# chown percona: /home/percona/.my.cnf +# pt-heartbeat --defaults-file /home/percona/.my.cnf --create-table --database percona --table heartbeat --update +~~~ + +Le lancer en démon : + +~~~ +# pt-heartbeat --defaults-file /home/percona/.my.cnf --create-table --database percona --table heartbeat --update --daemonize +~~~ + +Le mettre dans une unité systemd `/etc/systemd/system/pt-heartbeat.service` : + +~~~ +[Unit] +Description=Check slave lag. +After=network.target mysql.service + +[Service] +User=percona +ExecStart=/usr/bin/pt-heartbeat --defaults-file /home/percona/.my.cnf --create-table --database percona --table heartbeat --update +Type=simple +Restart=always + +[Install] +WantedBy=default.target +~~~ + +Consulter la latence sur le slave : + +~~~ +# pt-heartbeat -defaults-file /home/percona/.my.cnf --create-table --database percona --table heartbeat --check +~~~ + +On pourra ensuite surveiller en temps réel la latence ou écrire un cron de surveillance, voir un check Nagios. + +~~~ +# pt-heartbeat -defaults-file /home/percona/.my.cnf --create-table --database percona --table heartbeat --monitor +~~~ diff --git a/HowtoMySQL/Replication.md b/HowtoMySQL/Replication.md index 76597f33..5adf535b 100644 --- a/HowtoMySQL/Replication.md +++ b/HowtoMySQL/Replication.md @@ -281,6 +281,7 @@ log-slave-updates ## Monitoring + ### Icinga/nagios Pour surveiller que la réplication se fait bien et n'est pas en retard ou cassé par une erreur, on peut mettre en place un check nrpe *mysql_slave* @@ -293,59 +294,7 @@ GRANT REPLICATION CLIENT on *.* TO 'nrpe'@'localhost' IDENTIFIED BY 'PASSWORD'; ### pt-heartbeat -Dans le paquet `perconal-toolkit` on trouvera un outil pour mesurer la latence dans la réplication d'une meilleure façon que nativement. -L'astuce consiste à insérer une valeur datée de l'heure actuelle (timestamp) sur le master et comparer le timestamp avec la date du slave. -~~~ -# mysql -e "CREATE DATABASE percona;" -# mysql -e "GRANT ALL PRIVILEGES ON \`percona\`.* TO 'percona'@'%' IDENTIFIED BY 'password';" -# mysql -e "GRANT REPLICATION CLIENT ON *.* TO 'percona'@'%';" -# adduser --disabled-password percona -# vim /home/percona/.my.cnf - -[client] -user = percona -password = password - -# chmod 600 /home/percona/.my.cnf -# chown percona: /home/percona/.my.cnf -# pt-heartbeat --defaults-file /home/percona/.my.cnf --create-table --database percona --table heartbeat --update -~~~ - -Le lancer en démon : - -~~~ -# pt-heartbeat --defaults-file /home/percona/.my.cnf --create-table --database percona --table heartbeat --update --daemonize -~~~ - -Le mettre dans une unité systemd `/etc/systemd/system/pt-heartbeat.service` : - -~~~ -[Unit] -Description=Check slave lag. -After=network.target mysql.service - -[Service] -User=percona -ExecStart=/usr/bin/pt-heartbeat --defaults-file /home/percona/.my.cnf --create-table --database percona --table heartbeat --update -Type=simple -Restart=always - -[Install] -WantedBy=default.target -~~~ - -Consulter la latence sur le slave : - -~~~ -# pt-heartbeat -defaults-file /home/percona/.my.cnf --create-table --database percona --table heartbeat --check -~~~ - -On pourra ensuite surveiller en temps réel la latence ou écrire un cron de surveillance, voir un check Nagios. - -~~~ -# pt-heartbeat -defaults-file /home/percona/.my.cnf --create-table --database percona --table heartbeat --monitor -~~~ ## Résolution des erreurs lors de la réplication