ja:quickguides:ha_percona_xtradb

文書の過去の版を表示しています。


Percona XtraDB Cluster を用いた HA 環境

Pandora FMS is based on a MySQL database to configure and store data. We know that in order to scale (grow) “horizontally” there is the Pandora FMS Metaconsole for monitoring all the necessary devices. However, there are certain scenarios that can be too small for the use of the Metaconsole, with the difficulty that it causes in its management, as well as they can be too big to store all the data in a single database.

Pandora FMS は、設定およびデータを保存するために MySQL データベースを利用しています。“水平方向に” スケール(拡張)するためには、必要なデバイスをすべて監視できるようにする Pandora FMS メタコンソールがあります。ただし、メタコンソールを使用するには小さすぎ管理が難しくなるものの、すべてのデータを単一のデータベースに格納するには大きすぎるといった特別な場面もありえます

To solve this problem we rely on Percona XtraDB Cluster, which offers the possibility of using in multimaster mode (several main servers) for the read and write tasks of these servers. In this way, the load is distributed among the different servers where this cluster is hosted, giving more processing capacity to the database than a standalone node can offer. This way, the number of metrics to monitor in a single Pandora FMS node can be increased.

この問題を解決するために、Percona XtraDB Cluster を使用します。これは、複数のサーバからの読み取りおよび書き込みタスクに対して、マルチマスターモード(複数のメインサーバ)で使用できるようにする環境を提供します。 このようにして、負荷はこのクラスターが実装されている複数のサーバに分散され、スタンドアロンノードが対応できるよりも多くの処理能力をデータベースに提供します。 このようにして、単一の Pandora FMS ノードで監視するメトリックの数を増やすことができます。

The representation of this scheme offers the possibility of installing in the same server, a Percona XtraDB Cluster replication node together with the Pandora FMS server and the Web Console or separate the installation of them. It will be enough to point each one of the Pandora FMS servers or Pandora FMS Web Console to the node where it is needed to write or read, being able to distribute the load of the environment as it is more convenient in each environment.

このスキームでは、Percona XtraDB Cluster のレプリケーションノードと同じサーバに Pandora FMS サーバおよび Web コンソールを一緒にインストールすることができます。または、分けてインストールすることもできます 。 Pandora FMS サーバーまたは Pandora FMS Webコンソールのそれぞれを、書き込みまたは読み取りノードにポイントするだけで十分です。各環境でより便利なように、環境の負荷を分散できます。


The minimum number of nodes for the cluster to work is 3 nodes and there should always be 2 of them active for the database to be operative.


クラスタが機能するためのノードの最小数は 3ノードであり、データベースが機能するためには常に 2つのノードがアクティブである必要があります。

To perform a correct installation of Percona XtraDB Cluster, first the Percona XtraDB Cluster server and client must be installed in all the nodes.

Percona XtraDB Cluster を正しくインストールするには、最初に Percona XtraDB Cluster サーバとクライアントをすべてのノードにインストールする必要があります。

The data of the nodes to be used in the example will be the following:

例で使用するノードの情報は次の通りです。

NODE 1:

ノード1:

pandora001
192.168.80.111

NODE 2:

ノード2:

pandora002
192.168.80.112

NODE 3:

ノード3:

pandora003
192.168.80.113
# yum install Percona-XtraDB-Cluster-server-57 Percona-XtraDB-Cluster-client-57

Once installed on all nodes, start the service on each node and set up a password that is common for the root user, as well as a user (in this case sstuser) that will be used for replication between all nodes. Execute:

すべてのノードにインストールしたら、各ノードでサービスを開始し、root ユーザと、全ノード間のレプリケーションに使用されるユーザ(この場合は sstuser)に共通のパスワードを設定します。 以下を実行します:

# systemctl start mysqld

Get a temporary password for root and login with it to the MySQL server (remember to run on all nodes):

root の一時パスワードを取得し、それを使用して MySQL サーバにログインします(すべてのノードで実行することを忘れないでください)。

# mysql -uroot -p$(grep "temporary password" /var/log/mysqld.log | \ rev | cut -d' ' -f1 | rev)> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('Pandor4!');
> UNINSTALL PLUGIN validate_password;
> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('pandora');

Now proceed to create the user sstuser:

続いて、ユーザ sstuser を作成します:

mysql> create user sstuser@'%' identified by 'pandora';> grant all on *.* to sstuser@'%';
> flush privileges;
> quit

Stop the mysql service on all nodes after finishing this configuration:

ここまでの設定が終わったら、全ノードで mysql サービスを停止します。

# systemctl stop mysqld

Once you have stopped all servers, you must start one of them in bootstrap mode, so that it acts as the main server to perform replication between the other two nodes.

すべてのサーバを停止したら、そのうちの 1つをブートストラップモードで起動して、他の 2つのノード間でレプリケーションを実行するメインサーバとして機能するようにする必要があります。

To do this you have to add a specific configuration in the node that you choose as the main one, in this case the pandora001 node.

これを行うには、メインとして選択したノード(この場合は pandora001 ノード)に特定の設定を追加する必要があります。

Modify the /etc/my.cnf file of the pandora001 node adding correctly the parameters indicated between the two lines # Modified for PFMS:

pandora001 ノードの /etc/my.cnf ファイルを編集し、2行の # Modified for PFMS の間に示す設定を正しく追加します。

[mysqld]
# Modified for PFMS\
server-id=1
# Modified for PFMS/

datadir=/var/lib/mysql
character-set-server=utf8
skip-character-set-client-handshake

# Add configuration for Percona XtraDB Cluster.
# Cache size depends on the server resources. Recommended 1G - 10 GB.
# Modified for PFMS\
wsrep_provider_options="gcache.size=10G; gcache.page_size=10G"
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so

wsrep_cluster_name=pandora-cluster
wsrep_cluster_address=gcomm://
wsrep_node_name=pandora001
wsrep_node_address=192.168.80.111

wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:pandora
# Modified for PFMS/

pxc_strict_mode=PERMISSIVE

# Mysql optimizations for Pandora FMS node with 4G RAM
max_allowed_packet = 64M
innodb_buffer_pool_size = 1G
innodb_lock_wait_timeout = 90
innodb_file_per_table innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
innodb_log_file_size = 64M
innodb_log_buffer_size = 16M
innodb_io_capacity = 100
innodb_autoinc_lock_mode=2
thread_cache_size = 8192
thread_stack = 256K
max_connections = 8192
wait_timeout = 900
key_buffer_size=4M
read_buffer_size=128K
read_rnd_buffer_size=128K
sort_buffer_size=128K
join_buffer_size=4M
query_cache_type = 0
query_cache_size = 0
sql_mode=""
binlog_format=ROW
expire_logs_days=1

Start with this configuration the mysql service in the pandora001 node, in bootstrap mode:

pandora001 ノードにて、bootstrap モードで mysql サービスを起動します。

# systemctl start mysql@bootstrap

In the nodes pandora002 and pandora003 modify the file /etc/my.cnf indicating the following parameters indicated between the two lines # Modified for PFMS:

pandora002 および pandora003 ノードで /etc/my.cnf を編集し、次に示す 2行の # Modified for PFMS の間の設定を追加します。

  • Node pandora002:
  • ノード pandora002:
[mysqld]
server-id=2
datadir=/var/lib/mysql
character-set-server=utf8
skip-character-set-client-handshake
# add configuration for Percona XtraDB Cluster.
# Cache size depends on the server resources. Recommended 1G - 10 GB.
# Modified for PFMS\
wsrep_provider_options="gcache.size=10G; gcache.page_size=10G"
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so

wsrep_cluster_name=pandora-cluster
wsrep_cluster_address=gcomm:pandora001,pandora003

wsrep_node_name=pandora002
wsrep_node_address=192.168.80.112

wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:pandora

pxc_strict_mode=PERMISSIVE
# Modified for PFMS/

# Mysql optimizations for Pandora FMS
max_allowed_packet = 64M
innodb_buffer_pool_size = 1G
innodb_lock_wait_timeout = 90
innodb_file_per_table
innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
innodb_log_file_size = 64M
innodb_log_buffer_size = 16M
innodb_io_capacity = 100
innodb_autoinc_lock_mode=2
thread_cache_size = 8192
thread_stack    = 256K
max_connections = 8192
wait_timeout = 900
key_buffer_size=4M
read_buffer_size=128K
read_rnd_buffer_size=128K
sort_buffer_size=128K
join_buffer_size=4M
query_cache_type = 0
query_cache_size = 0
sql_mode=""
binlog_format=ROW
expire_logs_days=1
  • Node pandora003:
  • ノード pandora003:
[mysqld]
server-id=3
datadir=/var/lib/mysql
character-set-server=utf8
skip-character-set-client-handshake
# add configuration for Percona XtraDB Cluster.
# Cache size depends on the server resources. Recommended 1G - 10 GB.
# Modified for PFMS\
wsrep_provider_options="gcache.size=10G; gcache.page_size=10G"
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so

wsrep_cluster_name=pandora-cluster
wsrep_cluster_address=gcomm:pandora001,pandora003

wsrep_node_name=pandora002
wsrep_node_address=192.168.80.112

wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:pandora

pxc_strict_mode=PERMISSIVE
# Modified for PFMS/

# Mysql optimizations for Pandora FMS
max_allowed_packet = 64M
innodb_buffer_pool_size = 1G
innodb_lock_wait_timeout = 90
innodb_file_per_table
innodb_flush_log_at_trx_commit = 0
innodb_flush_method = O_DIRECT
innodb_log_file_size = 64M
innodb_log_buffer_size = 16M
innodb_io_capacity = 100
innodb_autoinc_lock_mode=2
thread_cache_size = 8192
thread_stack    = 256K
max_connections = 8192
wait_timeout = 900
key_buffer_size=4M
read_buffer_size=128K
read_rnd_buffer_size=128K
sort_buffer_size=128K
join_buffer_size=4M
query_cache_type = 0
query_cache_size = 0
sql_mode=""
binlog_format=ROW
expire_logs_days=1

Start in the nodes pandora002 and pandora003 the mysqld service to start the synchronization:

pandora002 および pandora003 ノードで、同期するために mysqld サービスを起動します。

#systemctl start mysqld

At this point you can perform the installation of the Pandora FMS database on node 1 and observe how it replicates correctly between the other two servers.

この時点で、ノード1 に Pandora FMS データベースのインストールを実行し、他の 2つのサーバ間でデータベースがどのように正しく複製されるかを観察できます。

Once you have verified the correct operation of the replication, stop the node that has started in bootstrap mode (in this case the pandora001 node):

レプリケーションの正しい動作を確認したら、bootstrap モードで開始したノード(この場合は pandora001 ノード)を停止します。

(NODO1) # systemctl stop mysql@bootstrap

Change inside the my.cnf file of the NODE 1 the parameter wsrep_cluster_address to add the other 2 nodes of the cluster to it, it has to be as follows:

ノード1 の my.cnf ファイル内でパラメータ wsrep_cluster_address を変更し、クラスタの他の 2つのノードを追加します。次のようにする必要があります。

wsrep_cluster_address=gcomm:pandora002,pandora003

Start again the mysqld service in the node pandora001, but this time in normal mode, so that it synchronizes with the other 2 nodes already active.

ノード pandora001mysqld サービスを再開しますが、今回は通常モードで、すでにアクティブになっている他の 2つのノードと同期します。

systemctl start mysqld

To avoid problems with deadlocks due to the constant writings and readings that are produced in parallel, it is necessary to modify the following Pandora FMS tables with the following modifications:

並行して行われる書き込みと読み取りによるデッドロックの問題を回避するために、以下に示す内容で Pandora FMS の該当テーブルを変更する必要があります。

alter table tagent_access add column `id_tagent_access` bigint(20) unsigned NOT NULL;
alter table tagent_access add primary key (id_tagent_access);
alter table tagent_access modify id_tagent_access bigint(20) auto_increment;
alter table tagente_datos add column `id_tagente_datos` bigint(20) unsigned NOT NULL;
alter table tagente_datos add primary key (id_tagente_datos);
alter table tagente_datos modify id_tagente_datos bigint(20) auto_increment;
alter table tagente_datos_inc add column `id_tagente_datos_inc` bigint(20) unsigned NOT NULL;
alter table tagente_datos_inc add primary key (id_tagente_datos_inc);
alter table tagente_datos_inc modify id_tagente_datos_inc bigint(20) auto_increment;
alter table tagente_datos_string add column `id_tagente_datos_string` bigint(20) unsigned NOT NULL;
alter table tagente_datos_string add primary key (id_tagente_datos_string);
alter table tagente_datos_string modify id_tagente_datos_string bigint(20) auto_increment;
alter table tagente_datos_inventory add column `id_tagente_datos_inventory` bigint(20) unsigned NOT NULL;
alter table tagente_datos_inventory add primary key (id_tagente_datos_inventory);
alter table tagente_datos_inventory modify id_tagente_datos_inventory bigint(20) auto_increment;
alter table torigen add primary key (`origen`);
alter table tusuario add primary key (`id_user`);

For its correct operation, these changes should be applied with the database without data, only with the schema.

正しく動作させるには、これらの変更をスキーマのみのデータが入っていないデータベースに適用する必要があります。

In this scenario, it is necessary to rebuild the tables where the necessary modifications have been added to avoid deadlocks in the environment. The process would be as follows:

このシナリオは、デッドロックを回避するために、すでにデータが入っているテーブルに対して変更を適用して再構築する場合の例です。処理は次のようになります。

1.- DUMP (export data) all the tables involved separately, excluding the DROP and create TABLE fields:

1.- DROP および create TABLE フィールドを除く、個別に関係するすべてのテーブルを DUMP (データのエクスポート) します。

#mysqldump -u root -p pandora tagent_access --skip-add-drop-table --complete-insert --no-create-info> tagent_access.sql
#mysqldump -u root -p pandora tagente_datos --skip-add-drop-table --complete-insert --no-create-info> tagente_datos.sql
#mysqldump -u root -p pandora tagente_datos_inc --skip-add-drop-table --complete-insert --no-create-info> tagente_datos_inc.sql
#mysqldump -u root -p pandora tagente_datos_string --skip-add-drop-table --complete-insert --no-create-info> tagente_datos_string.sql
#mysqldump -u root -p pandora tagente_datos_inventory --skip-add-drop-table --complete-insert --no-create-info> tagente_datos_inventory.sql

2.- Delete the affected tables:

2.- 影響のあるテーブルを削除します。

mysql>drop table tagent_access;
mysql>drop table tagente_datos;
mysql>drop table tagente_datos_inc;
mysql>drop table tagente_datos_string;
mysql>drop table tagente_datos_inventory;

3.- Create again all the tables with all the ALTER and with all the new columns so that the environment works without problems. To create the tables again it is necessary to use the create table of the file /var/www/html/pandora_console/pandoradb.sql of the tables tagent_access, tagente_datos_inc, tagente_datos_string, tagente_datos_inventory.

3.- 環境が問題なく動作するように、新しい列を含むすべてのテーブルを ALTER で再度作成します。 テーブルを再度作成するには、テーブル作成が記載されているファイル /var/www/html/pandora_console/pandoradb.sqltagent_accesstagente_datostagente_datos_inctagente_datos_stringtagente_datos_inventory を利用し、正しい動作のための Pandora FMS スキーマの変更 の内容を実施します。

4.- Incorporate with source all the DUMP data created in step 1.

4.- 手順1 で作成したすべての DUMP データを source で読み込みます。

#mysql -u root -p pandora
mysql> source tagent_access.sql:
mysql> source tagente_datos.sql:
mysql> source tagente_datos_inc;
mysql> source tagente_datos_string;
mysql> source tagente_datos_inventory;

At the end of the process, all the tables will have the incremental IDs created from scratch in all of them.

処理が終わると、すべてのテーブルに、最初から作成されたインクリメンタル ID が含まれます。

クイックガイド一覧に戻る

  • ja/quickguides/ha_percona_xtradb.1655505816.txt.gz
  • 最終更新: 2022/06/17 22:43
  • by junichi