Skip to content

Instantly share code, notes, and snippets.

@dotmanila
Last active March 31, 2019 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dotmanila/4a3811db1d1d6b2fb5882faf55d1f1e9 to your computer and use it in GitHub Desktop.
Save dotmanila/4a3811db1d1d6b2fb5882faf55d1f1e9 to your computer and use it in GitHub Desktop.
pt-heartbeat implementation via Orchestrator nodes.
#!/bin/bash
OC=/usr/bin/orchestrator-client
IPADDR=$(/sbin/ip ad sh dev eth0 scope global | grep -oE "inet\s(.*)\/" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}")
RAFTLEADER=$($OC -c raft-leader | cut -d: -f1)
if [ "x${IPADDR}" != "x${RAFTLEADER}" ]; then
exit 0
fi
for h in $($OC -c api --path masters | jq -r 'map(select(.IsDowntimed == false))[] | .Key.Hostname'); do
pt-heartbeat --create-table --create-table-engine=InnoDB --check-read-only \
--database=percona --table=heartbeat --host=$h --update --daemonize \
--run-time=299 --defaults-file=/etc/my.cnf.d/orchestrator.cnf
done
# pt-heartbeat --create-table --create-table-engine=InnoDB --check-read-only \
# --database=percona --table=heartbeat --host=localhost --update --daemonize \
# --run-time=299 --defaults-file=/root/.my.cnf --read-only-interval=298 --replace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment