When: Anytime - no in use
Prerequisites: https://wikitech.wikimedia.org/wiki/MariaDB/Primary_switchover
Checklist:
NEW primary: es2039
OLD primary: es2038
- Check configuration differences between new and old primary:
sudo pt-config-diff --defaults-file /root/.my.cnf h=es2038.codfw.wmnet h=es2039.codfw.wmnet
Failover prep:
- Silence alerts on all hosts:
sudo cookbook sre.hosts.downtime --hours 1 -r "Primary switchover es7 T400435" 'A:db-section-es7'
- Set NEW primary with weight 0 (and depool it from API or vslow/dump groups if it is present).
sudo dbctl instance es2039 set-weight 0 sudo dbctl config commit -m "Set es2039 with weight 0 T400435"
- Topology changes, move all replicas under NEW primary
sudo db-switchover --read-only-master --replicating-master --timeout=25 --only-slave-move es2038 es2039
- Disable puppet on both nodes
sudo cumin 'es2038* or es2039*' 'disable-puppet "primary switchover T400435"'
- Merge gerrit puppet change to promote NEW primary: https://gerrit.wikimedia.org/r/1172511
Failover:
- Log the failover:
!log Starting es7 codfw failover from es2038 to es2039 - T400435
- Switch primaries:
sudo db-switchover --read-only-master --replicating-master --skip-slave-move es2038 es2039 echo "===== es2038 (OLD)"; sudo db-mysql es2038 -e 'show slave status\G' echo "===== es2039 (NEW)"; sudo db-mysql es2039 -e 'show slave status\G'
- Promote NEW primary in dbctl, and remove read-only
sudo dbctl --scope codfw section es7 set-master es2039 sudo dbctl config commit -m "Promote es2039 to es7 primary T400435"
- Clean up heartbeat table(s).
sudo db-mysql es2039 heartbeat -e "delete from heartbeat where file like 'es2038%';"
- Restart puppet on both hosts:
sudo cumin 'es2038* or es2039*' 'run-puppet-agent -e "primary switchover T400435"'
Clean up tasks:
- change events for query killer:
curl -sS 'https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/+/refs/heads/master/dbtools/events_coredb_master.sql?format=TEXT' | base64 -d | sudo db-mysql es2039 curl -sS 'https://gerrit.wikimedia.org/r/plugins/gitiles/operations/software/+/refs/heads/master/dbtools/events_coredb_slave.sql?format=TEXT' | base64 -d | sudo db-mysql es2038
- Update candidate primary dbctl and orchestrator notes
sudo dbctl instance es2038 set-candidate-master --section es7 true sudo dbctl instance es2039 set-candidate-master --section es7 false sudo cumin 'dborch*' 'orchestrator-client -c untag -i es2039 --tag name=candidate' sudo cumin 'dborch*' 'orchestrator-client -c tag -i es2038 --tag name=candidate'
- Check zarcillo was updated
- db-switchover should do this. If it fails, do it manually: https://phabricator.wikimedia.org/P13956
sudo db-mysql db1215 zarcillo -e "select * from masters where section = 'es7';"
- (If needed): Depool es2038 for maintenance.
sudo dbctl instance es2038 depool sudo dbctl config commit -m "Depool es2038 T400435"
- Change es2038 weight to mimic the previous weight es2039:
sudo dbctl instance es2038 edit
- Update/resolve this ticket.