1
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 1 year has passed since last update.

IBM Cloud:Private GLBによるサービス稼働系切り替えにあわせた自動ルーティング設定

Last updated at Posted at 2022-07-15

概要

サービスを稼働する環境において、Active/Stanbyにて冗長化させる構成は多いかと思います。また、障害時にフェイルオーバーが発生すると、稼働系へのルーティングを切り替える必要があります。

本記事では、フェイルオーバークラスターを構成可能なSIOS Protection Suite for Linuxを用いてActive/Standbyノードを構成し、private GLBを用いて、Active/Standbyノードに対してヘルスチェック・稼働系のサービスに通信を転送するようにします。

前提

本記事の環境は以下の手順書に則り、LifeKeeper/DataKeeperを用いて構成します。
pdf:SIOS Protection Suite for Linux Step by Step Guide【IBM Cloud編】

手順書内では、フェイルオーバー時のルーティング切り替えにgeneric arkリソースをLifeKeeper上に作成しました。generic arkリソースとは、ノードの起動時/停止時に自作のスクリプトを実行してくれるリソースです。上記手順書では起動時にスクリプトを実行するようにgeneric arkリソースで設定し、実行時にスクリプト内のibmcloud CLIを用いてルーティングテーブルを書き換えるよう設定していました。またクライアントは、IPアドレスリソースを用いてNICに付与された仮想IPアドレスに対して接続します。

本記事では、generic ark・仮想IPアドレスの設定は行わず、LB Health Check Kit (LB Health Checkリソース) を使用しています。LB Health Checkリソースは、GLBからのヘルスチェックに対して応答を行うリソースです。
(バージョン9.6.1以前は同等機能として「Generic ARK for Load Balancer probe reply(Gen LB)」と呼ばれていたものが提供されていました)
private GLBを使用してルーティング切り替えするため、上記手順書で作成したgeneric arkリソースを削除し、LB Health Checkリソースを追加した環境で構成していますのでご注意ください。

(参考) [Linux]Generic ARK for Load Balancer probe reply の提供

genLBリソース / LifeKeeperの設定

genLBリソースでは、以下のような設定をしました。

項目
Switchback Type Intelligent
Server [Active node名]
Reply daemon Port 12345
Reply daemon message [空欄]
LB Health Check Resource Tag lb-check

genLBリソース作成後の階層構造を以下のように設定しています。

環境情報

構成は以下の通りです(上記手順書に従っています)。
nodeは仮想サーバと考えてください。この構成では、3つの仮想サーバがそれぞれ2つのNICを持っています。

  • node1:active ノード (通常、MySQL稼働)
  • node2:standby ノード (通常、MySQL停止)
  • node3:Witness ノード (Active/Standbyの死活監視)

図3-1 VPC構成図 (上記手順書より引用)
genLB有り.png

クライアントは、privateGLBでの名前解決によって、MySQLが稼働する仮想サーバのIPアドレスを取得して直接サーバと通信を行います。(※本構成のprivateGLBは、reverse proxyとして動作するわけではありません)

private GLBの設定手順

DNS Servicesの注文

本記事では省略します。

zoneの作成

右上の「ハンバーガーメニュー」→「リソースリスト」より、作成しているDNSリソースを開きます。
image.png

DNSリソースを開くと、左側にメニューがあるので、「Zones」→「Create zone」をクリックします。
image.png
以下のように名前を入力し、「Create zone」をクリックすると作成されます。

VPCからのアクセス許可

Zoneを作成すると、StatusがPendingになります。これは接続されているネットワークがないことが原因ですので接続します。
Permitted networks」→「Add network」をクリックし、対象VPCのリージョンと対象VPCを選択します。
image.png

Health Checksの作成

次にHealth Checksを作成します。Origin PoolへのHealth Checkの設定は必須です。
Global load balancer」→「Health checks」→「Create health check」をクリックします。
image.png

health check名、チェック対象のType/ポート番号を入力し「Create」をクリックします。
(TypeはHTTP/HTTPS/TCPが選択可能ですが、MySQLのポートアクセスをチェックしたいのでTCPを指定します)

作成できました!
image.png

pool作成

続いてpoolを作成します。「Health checks」タブの左にある「Origin pools」タブをクリックします。
image.png

Create origin pool」をクリックします。
(同じpoolでも作成可能ですが、GLB登録時に明示的にpolicyを分けるために、今回は仮想サーバ1と2、それぞれでpoolを作成してみます)
image.png

以下を登録します。

  • pool名
  • 登録するサーバ名(実際の仮想サーバー名と異なっても問題ないです)
  • サーバにあるMySQLにアクセス可能なprivate IPアドレス (今回は10.1.1.4 / 10.2.1.4)

Health Monitoringの登録

  • Health check:使用するHealth checkを選択
  • region、VPC、subnet:どのregionのVPC/subnetに対してhealth checkを行うかを選択

image.png

仮想サーバ1と2それぞれで作成しました。
仮想サーバ2ではMySQLを停止しているので、TCP:12345に対するLB Health Checkリソースの応答が停止し、privateGLBからのhealth checkが失敗します。そのため、mysqlpool2は「critical」になっています。
image.png

GLB作成

「Origin pools」タブの左にある「Load balancers」タブをクリックし、DNS zonesに作成したzoneを選択、「Crate load balancer」をクリックします。
image.png

balancer名を入力します。
次に、青文字の「Add default policy」をクリックします。
Screen Shot 2022-07-08 at 1.23.47.png

仮想サーバ1のpoolを選択します。
Screen Shot 2022-07-08 at 1.24.08.png

同様に、青文字の「Add fallback policy」をクリックし、仮想サーバ2のpoolを選択します。
Screen Shot 2022-07-08 at 1.24.20.png

以下のように入力したら「Add」をクリックします。
Screen Shot 2022-07-08 at 1.24.38.png
以上で設定完了です!!

テスト

仮想サーバ1 / 2と同じVPC、かつ別AZにあるクライアントサーバからアクセスしてみます。
また、途中でサービス稼働系を切り替えた時、同じFQDN (mysqldbtest.glbtest.local)でアクセスし続けられるかテストします。

[root@vsi-client ~]#  dig mysqldbtest.glbtest.local +short
10.1.1.4  (仮想サーバ1のIPアドレス)
[root@vsi-client ~]# mysql -uroot -h mysqldbtest.glbtest.local -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 28
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW VARIABLES WHERE Variable_name = 'hostname';
+---------------+-----------+
| Variable_name | Value     |
+---------------+-----------+
| hostname      | vsi1      |
+---------------+-----------+
1 row in set (0.00 sec)

mysql> quit
Bye


------------------------------------------------------------------------------------
           サービス稼働系を仮想サーバ1から仮想サーバ2に切り替え
------------------------------------------------------------------------------------


[root@vsi-client ~]#  dig mysqldbtest.glbtest.local +short
10.2.1.4  (仮想サーバ2のIPアドレス)
[root@vsi-client ~]# mysql -uroot -h mysqldbtest.glbtest.local -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SHOW VARIABLES WHERE Variable_name = 'hostname';
+---------------+-----------+
| Variable_name | Value     |
+---------------+-----------+
| hostname      | vsi2      |
+---------------+-----------+
1 row in set (0.01 sec)

mysql> quit
Bye
[root@vsi-client ~]#
1
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
1
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?