メインコンテンツまでスキップ
バージョン: V1.0.0

モニタリングコンポーネントの設定

obshell Dashboardのパフォーマンス監視およびアラート機能は、PrometheusとAlertmanagerツールに依存しています。本記事では、必要なモニタリングコンポーネントのデプロイ方法について説明します。

背景​

obshell Dashboardのパフォーマンス監視機能はobagentおよびPrometheusツールに依存し、アラート機能はAlertmanagerツールに依存します。obagentはHTTPインターフェースを提供し、seekdbからデータを収集できます。Prometheusは設定に基づいて定期的にobagentのインターフェースにアクセスし、監視データを収集して永続化ストレージに保存します。obshell Dashboardは、Prometheusが収集した監視データを表示するページを提供します。Alertmanagerは、Prometheusなどの監視システムからのアラートを処理し、アラートの重複除去、グループ化、ルーティング、サイレンシングなどの機能を提供します。

obagentのインストール​

seekdbの設定​

  1. ユーザーの準備

    OceanBaseデータベースに対する読み取り権限のみを付与した、読み取り専用ユーザーの使用を推奨します。

     create user monitor identified by '******';
    grant select on oceanbase.* to monitor;
  2. インスタンス名の設定

    Prometheusを使用して複数のseekdbインスタンスを監視する場合は、各seekdbインスタンスに異なるインスタンス名を設定し、インスタンス間を区別しやすくします。

    alter system set `cluster` = 'obcluster';
    ヒント

    インスタンス名を設定する際は、構成パラメータclusterにバッククォート(`)を付加する必要があります。

obagentの設定​

  1. obagentのインストール

    オープンソースイメージレジストリにアクセスし、ご利用の環境のアーキテクチャに対応するobagentインストールパッケージをダウンロードして、以下のコマンドでインストールします。最新バージョンのインストールを推奨します。

    [root@test ~]# rpm -ivh obagent-*.rpm

    obagentはデフォルトで /home/admin ディレクトリにインストールされます。

  2. obagentの設定

    以下のコマンドを実行して、収集アカウントのパスワードおよび必要なメタデータ情報を設定します。

    [root@test ~]# cd /home/admin/obagent
    [root@test obagent]# bin/ob_agentctl config --update monagent.ob.monitor.user=monitor,monagent.ob.monitor.password=******,monagent.ob.cluster.name=obcluster,monagent.pipeline.ob.status=active,agent.http.basic.auth.metricAuthEnabled=false

    コマンドパラメータの説明は以下のとおりです:

    • monagent.ob.monitor.user:収集アカウントを設定します。seekdbで作成された読み取り専用ユーザー(本記事ではmonitor)を指定します。
    • monagent.ob.monitor.password:収集アカウントのパスワードを設定します。seekdbの読み取り専用ユーザーのパスワードを指定します。
    • monagent.ob.cluster.name:seekdbインスタンスのインスタンス名です。インスタンスに接続後、SHOW PARAMETERS LIKE 'cluster'; コマンドを実行して確認できます。value列の値がインスタンス名です。
    • monagent.pipeline.ob.status:activeに設定すると、seekdb関連メトリクスの収集が有効になります。
    • agent.http.basic.auth.metricAuthEnabled:falseに設定すると、obagent HTTPインターフェースのBasic Auth認証が無効になります。

    コマンドの実行出力は次のとおりです:

    {"successful":true,"message":"success","error":""}
  3. obagentの起動

    [root@test obagent]# bin/ob_agentctl start

    コマンドの実行出力は次のとおりです:

    {"successful":true,"message":"ok","error":""}

検証​

プロセスを確認してobagentが正常に起動したかどうかを確認するか、データクエリインターフェースにアクセスして監視データを取得できるかどうかを検証できます。

  • プロセスの確認

    [root@test obagent]# ps -ef | grep agent

    出力は次のとおりです:

    root     27064     1  0 14:46 ?        00:00:00 /home/admin/obagent/bin/ob_agentd -c /home/admin/obagent/conf/agentd.yaml
    root 27071 27064 0 14:46 ? 00:00:00 /home/admin/obagent/bin/ob_mgragent
    root 27072 27064 0 14:46 ? 00:00:00 /home/admin/obagent/bin/ob_monagent
    root 27116 26122 0 14:47 pts/0 00:00:00 grep --color=auto agent
  • データクエリインターフェースへのアクセス

    [root@test obagent]# curl -L 'http://127.0.0.1:8088/metrics/ob/basic'

    出力は次のとおりです:

    # HELP ob_active_session_num monitor collected message
    # TYPE ob_active_session_num untyped
    ob_active_session_num{app="OB",ob_cluster_id="0",ob_cluster_name="obcluster",ob_tenant_id="1",obzone="",svr_ip="127.0.0.1",svr_port="2882",tenant_name="sys"} 0 1762135926015
    # HELP ob_all_session_num monitor collected message
    # TYPE ob_all_session_num untyped
    ob_all_session_num{app="OB",ob_cluster_id="0",ob_cluster_name="obcluster",ob_tenant_id="1",obzone="",svr_ip="127.0.0.1",svr_port="2882",tenant_name="sys"} 0 1762135926015
    # HELP ob_plan_cache_access_total monitor collected message
    # TYPE ob_plan_cache_access_total untyped
    ob_plan_cache_access_total{app="OB",ob_cluster_id="0",ob_cluster_name="obcluster",ob_tenant_id="1",obzone="",svr_ip="127.0.0.1",svr_port="2882",tenant_name="sys"} 33229 1762135926015
    # HELP ob_plan_cache_hit_total monitor collected message
    # TYPE ob_plan_cache_hit_total untyped
    ob_plan_cache_hit_total{app="OB",ob_cluster_id="0",ob_cluster_name="obcluster",ob_tenant_id="1",obzone="",svr_ip="127.0.0.1",svr_port="2882",tenant_name="sys"} 32051 1762135926015
    # HELP ob_plan_cache_memory_bytes monitor collected message
    # TYPE ob_plan_cache_memory_bytes untyped
    ob_plan_cache_memory_bytes{app="OB",ob_cluster_id="0",ob_cluster_name="obcluster",ob_tenant_id="1",obzone="",svr_ip="127.0.0.1",svr_port="2882",tenant_name="sys"} 1.15905078e+08 1762135926015
    # HELP ob_server_num monitor collected message
    # TYPE ob_server_num untyped
    ob_server_num{app="OB",ob_cluster_id="0",ob_cluster_name="obcluster",obzone="",server_ips="127.0.0.1",status="ACTIVE",svr_ip="127.0.0.1",svr_port="2882"} 1 1762135926015
    # HELP ob_sysstat monitor collected message
    # TYPE ob_sysstat untyped
    ob_sysstat{app="OB",ob_cluster_id="0",ob_cluster_name="obcluster",ob_tenant_id="1",obzone="",stat_id="10000",svr_ip="127.0.0.1",svr_port="2882",tenant_name="sys"} 2673 1762135926015
    ob_sysstat{app="OB",ob_cluster_id="0",ob_cluster_name="obcluster",ob_tenant_id="1",obzone="",stat_id="10001",svr_ip="127.0.0.1",svr_port="2882",tenant_name="sys"} 2.838626e+06 1762135926015
    ······# 以降の出力は省略

Prometheusの設定​

Prometheus公式サイトまたはオープンソースミラーコレクションにアクセスし、ご利用環境のアーキテクチャに応じた対応するインストールパッケージをダウンロードしてPrometheusをデプロイします。通常、すべてのseekdbインスタンスを監視するには、1つのPrometheusインスタンスだけで十分です。このセクションで提供されている設定例は参考用です。具体的なインストールおよび設定の詳細については、Prometheus公式ドキュメントを参照してください。

備考

obdのGitHubリポジトリにアクセスすると、OceanBaseが提供するPrometheusアラートルールファイルを確認できます。

global:
scrape_interval: 5s # スクレイピング間隔を15秒に設定します。デフォルトは1分です。
evaluation_interval: 5s # ルールの評価間隔を15秒に設定します。デフォルトは1分です。

# Alertmanager configuration, prometheus will push alerts to these addresses
alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093

# Rule files are loaded once and then evaluated periodically according to the global 'evaluation_interval'.
rule_files:
- "prometheus_rules.yaml"
# - "second_rules.yml"

scrape_configs:
- job_name: "ob-basic"
metrics_path: "/metrics/ob/basic"
# prometheus 3.x系では以下の設定を有効にする必要があります
# fallback_scrape_protocol: PrometheusText0.0.4
static_configs:
- targets: ["127.0.0.1:8088"]
- job_name: "ob-extra"
metrics_path: "/metrics/ob/extra"
# prometheus 3.x系では以下の設定を有効にする必要があります
# fallback_scrape_protocol: PrometheusText0.0.4
static_configs:
- targets: ["127.0.0.1:8088"]
- job_name: "ob-host"
metrics_path: "/metrics/node/host"
# prometheus 3.x系では以下の設定を有効にする必要があります
# fallback_scrape_protocol: PrometheusText0.0.4
static_configs:
- targets: ["127.0.0.1:8088"]

Prometheusの設定後、Prometheusのグラフィカルインターフェースにアクセスし、StatusをクリックしてTargetを選択すると、データ収集が正常に行われているかどうかを確認できます。

備考

Prometheusのバージョンによって画面の表示が異なります。Targetフィールドはここではあくまで例です。

Prometheus

Alertmanagerの設定​

Prometheus公式Webサイトまたはオープンソースイメージレジストリにアクセスし、使用環境のアーキテクチャに対応するインストールパッケージをダウンロードして解凍します。Alertmanagerドキュメントを参照して設定ファイル(alertmanager.yml)を修正し、完了後に作業ディレクトリに移動して以下のコマンドを実行してAlertmanagerを起動します。

[root@test alertmanager]# nohup ./alertmanager --config.file=alertmanager.yml --cluster.advertise-address=127.0.0.1:9093 > alertmanager.log 2>&1 &

例では、127.0.0.1:9093 がサービスアドレスを表し、nuohup は alertmanager プロセスをバックグラウンドで実行することを示します。