0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

haproxyをコマンドラインで操作

Posted at

socatのインストール(debian)

apt-get install socat

socat = ソケット関連の操作を行うことができるようになるコマンド

haproxyの設定

※ 現状のlilimoの設定だと、変更する必要ありません

コマンド

ステータスの確認

$ echo "show stat" | socat stdio /run/haproxy/admin.sock | grep web001

正常時

www-backend,web001,0,0,0,1,8192,49,46158,13083,,0,,0,0,0,0,UP,1,1,0,1,1,165,2731,,1,3,1,,49,,2,0,,6,L7OK,200,4,0,49,0,0,0,0,0,,,,0,0,,,,,3123,OK ,,0,1,1,79,

異常時

www-backend,web001,0,0,0,1,8192,49,46158,13083,,0,,0,0,0,0,DOWN,1,1,0,2,2,2,2733,,1,3,1,,49,,2,0,,6,L7STS,502,2,0,49,0,0,0,0,0,,,,0,0,,,,,3180,Bad Gateway,,0,1,1,79,

メンテナンスモード

メンテナンスモードにすることによって、haproxy側で特定のサーバを切り離すことができる
片方のサーバで見れないなどのダウンタイムがなくなる

実行

$ echo "disable server www-backend/web002" | socat stdio /run/haproxy/admin.sock

解除

$ echo "enable server www-backend/web002" | socat stdio /run/haproxy/admin.sock

メンテナンスモード時の画面表示

正常時

メンテナンスモード時

表示の色が茶色になる

デプロイ時の流れ

  1. メンテナンスモードにする
  2. haproxyとサーバが切り離されたことを確認する
  3. webサーバなどを再起動する
  4. メンテナンスモードを解除する
  5. メンテナンスモードが終り、haproxyとサーバが疎通したら次のサーバへ
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?