Skip to content

Instantly share code, notes, and snippets.

@uorat
Created December 1, 2017 05:55
Show Gist options
  • Save uorat/3ade458340d3b3fe54403248776f94d1 to your computer and use it in GitHub Desktop.
Save uorat/3ade458340d3b3fe54403248776f94d1 to your computer and use it in GitHub Desktop.
# 1. 継続利用する Node Endpoint read1 - 3 の weight を 1 にする
ansible -m 'shell' -i production haproxy -s -a'echo "set weight mysql/reader1 1" | sudo socat stdio /var/lib/haproxy/stats'
ansible -m 'shell' -i production haproxy -s -a'echo "set weight mysql/reader2 1" | sudo socat stdio /var/lib/haproxy/stats'
ansible -m 'shell' -i production haproxy -s -a'echo "set weight mysql/reader3 1" | sudo socat stdio /var/lib/haproxy/stats'
# 2. Reader Endpoint 経由でクエリが流れないように Reader Endpoint の weight を 0 にする
ansible -m 'shell' -i production haproxy -s -a'echo "set weight mysql/reader 0" | sudo socat stdio /var/lib/haproxy/stats'
# 3. (縮退する場合は)削除予定の Replica Node にクエリが流れてこないことを確認する
# 4. 構成変更作業を進める
# 5. 構成変更作業が終わったら、 Reader Endpoint の weight を 1 に戻す
ansible -m 'shell' -i production haproxy -s -a'echo "set weight mysql/reader 1" | sudo socat stdio /var/lib/haproxy/stats'
# 6. さらに、 Node Endpoint の weight を 0 に戻す
ansible -m 'shell' -i production haproxy -s -a'echo "set weight mysql/reader1 0" | sudo socat stdio /var/lib/haproxy/stats'
ansible -m 'shell' -i production haproxy -s -a'echo "set weight mysql/reader2 0" | sudo socat stdio /var/lib/haproxy/stats'
ansible -m 'shell' -i production haproxy -s -a'echo "set weight mysql/reader3 0" | sudo socat stdio /var/lib/haproxy/stats'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment