'翻訳', 「Widget_file '=>' Selectセレクト/ tpw_select2.php「)); }?>

Ubuntu に MariaDB ガレラ クラスターをインストールするには、方法 16.04

Ubuntu に MariaDB ガレラ クラスターをインストールするには、方法 16.04

MariaDB ガレラは MariaDB のマルチ マスター クラスターです。. MariaDB 以来 10.1, MariaDB サーバーと MariaDB ガレラ サーバー パッケージが組み合わされている、ガレラ パッケージとその依存関係を取得自動的にインストール MariaDB をインストールするとき. 現在は, MariaDB Galera Cluster only supports the InnoDB/XtraDB storage engine. In MariaDB 10.0 そして 5.5, you will need to download it separately. MariaDB Galera adds redundancy for a site’s database. In MariaDB Galera Cluster, multiple database servers interconnected with each other and keep synchronized.

MariaDB Galera provides lots of features, それらのいくつかを以下に示します。

  1. Synchronous replication.
  2. Automatic node joining.
  3. Active-active multi-master topology.
  4. True parallel replication, on row level.
  5. Read and write scalability, Smaller client latencies.
  6. Failed nodes, automatic drop from the cluster.

このチュートリアルで, we will explain how to setup MariaDB Galera Cluster 10.1 と 3 nodes running on Ubuntu 16.04 サーバー. We will also test database replication between all the nodes.

要件

  • Three Nodes running Ubuntu 16.04 サーバー.
  • Node1 with static IP address 192.168.0.102, Node2 with static IP address 192.168.0.103 and Node3 with static IP address 192.168.0.104 サーバー上の設定.
  • Non-root user with sudo privileges setup on all the nodes.

作業の開始

まずは, you will need to update all the nodes with the latest version. You can update all of them with the following command:

sudo 適当です-行きます更新 y
sudo 適当です-行きますアップグレード -y

次に, restart all the nodes to apply these changes. そうしたら, log in with sudo user and proceed to the next step.

Install MariaDB Galera

MariaDB Server and MariaDB Galera Server packages are combined in the version MariaDB 10.1. 既定では, MariaDB 10.1 is not available in the default Ubuntu repositories, so you will need to add the MariaDB repository on all the nodes.

まずは, add the MariaDB repository key with the following command:

sudo apt キー adv –recv-keyskeyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

次に, add the repository and update the APT cache with the following command:

sudo add-apt-repository ‘deb [arch=amd64,i386,ppc64el] http://ftp.utexas.edu/mariadb/repo/10.1/ubuntu xenial main
sudo 適当です-行きます更新 y

Once the repository is updated, install MariaDB with the following command:

sudo apt-get install mariadb-server rsync -y

The above command will install MariaDB with Galera and several dependencies. The Galera parts remain dormant until configured, like a plugin or storage engine. Once the MariaDB is installed on all the nodes, you can proceed to secure MariaDB.

MariaDB インストール デフォルトで保護されていません。, MariaDB インストールをセキュリティで保護する必要がありますので. これは、mysql_secure_installation スクリプトを実行して行います。

須藤 mysql_secure_installation

このプロセスで, root のパスワードを設定していただきます, 匿名ユーザーを削除します。, リモートからの root ログインを許可しない、テスト データベースを削除. 次のようにすべての質問に答えます。

Enter current password for root (enter for none):
Change the root password? [Y/n] n
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Once the MariaDB is secured on all the nodes, 次のステップに進むことができます。.

Setup MariaDB Cluster on Node1

まずは, go to the Node1 and create a configuration file for Galera. 既定では, MariaDB reads configuration from /etc/mysql/conf.d/ directory. そうには, 次のコマンドを実行します。

sudo nano /etc/mysql/conf.d/galera.cnf

次の行を追加します。

[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://192.168.0.102,192.168.0.103,192.168.0.104"

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
wsrep_node_address="192.168.0.102"
wsrep_node_name="Node1"

完了したら、ファイルを保存します。.

メモ: 192.168.0.102 is the IP address of the Node1

Add Node2 on Galera Cluster

次に, go to the Node2 and create a configuration file for Galera:

sudo nano /etc/mysql/conf.d/galera.cnf

次の行を追加します。

[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://192.168.0.102,192.168.0.103,192.168.0.104"

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
wsrep_node_address="192.168.0.103"
wsrep_node_name="Node2"

完了したら、ファイルを保存します。.

メモ: 192.168.0.103 is the IP address of the Node2.

Add Node3 on Galera Cluster

次に, go to the Node3 and create a configuration file for Galera:

sudo nano /etc/mysql/conf.d/galera.cnf

次の行を追加します。

[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://192.168.0.102,192.168.0.103,192.168.0.104"

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
wsrep_node_address="192.168.0.104"
wsrep_node_name="Node3"

完了したら、ファイルを保存します。.

メモ: 192.168.0.104 is the IP address of the Node3.

ファイアウォールを構成します。

Galera Cluster uses four ports 3306 for MySQL client connection, 4444 for State Snapshot Transfer, 4567 for Galera Cluster replication traffic and 4568 for Incremental State Transfer. So you will need to allow all these ports using the UFW firewall. You can do this by running the following command on all the nodes:

まずは, enable the UFW firewall with the following command:

ufw の sudo を有効にします。

次に, allow all the ports with the following command:

sudo ufw allow 3306/tcp
sudo ufw allow 4444/tcp
sudo ufw allow 4567/tcp
sudo ufw allow 4568/tcp
sudo ufw allow 4567/udp

You can then check the status of the firewall with the following command:

須藤 ufw のステータス

Once the UFW firewall is configured on all the nodes, 次のステップに進むことができます。.

Start MariaDB Galera Cluster

After successfully configuring all the nodes, go to the Node1 and start Galera Cluster.

Before Galera can start, you need to ensure that MariaDB service is stopped on all the nodes.

Run the following command on all the nodes:

sudo systemctl stop mysql

今, start the Galera Cluster on Node1 with the following command:

sudo galera_new_cluster

今, check whether the cluster is running or not with the following command:

mysql u ルート p e “show status like ‘wsrep_cluster_size'

If everything is fine you should see the following output:

+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 1     |
+--------------------+-------+

On the Node2, start the MariaDB service:

須藤 systemctl 開始 mysql

You can check the status of MariaDB service whether it is working or not with the following command:

sudo systemctl status mysql

すべてが正常である場合, you should see the following output:

?? mariadb.service - MariaDB database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2017-09-17 10:11:20 EDT; 10min ago
  Process: 715 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 713 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
  Process: 545 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $?-eq 0 ]   && systemctl set
  Process: 535 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 514 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
 Main PID: 661 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 26 (制限。 4915)
   CGroup: /system.slice/mariadb.service
           ??????661 /usr/sbin/mysqld

Sep 17 10:11:11 debian systemd[1]: Starting MariaDB database server...
9 月 17 10:11:15 debian mysqld[661]: 2017-09-17 10:11:15 140287134630464 [Note] /usr/sbin/mysqld (mysqld 10.1.26-MariaDB-0+deb9u1) starting as process
Sep 17 10:11:20 debian systemd[1]: Started MariaDB database server.

今, your second node should’ve automatically linked to the cluster. You can verify that with the following command:

mysql u ルート p e “show status like ‘wsrep_cluster_size'

If everything is working well, the cluster size should be set to two:

+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 2     |
+--------------------+-------+

On the Node3, start the MariaDB service:

須藤 systemctl 開始 mysql
mysql u ルート p e “show status like ‘wsrep_cluster_size'

If everything is working well, the cluster size should be set to three:

+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 3     |
+--------------------+-------+

You cluster is now working and communicating each other.

Test Database Replication

今, all the nodes are online, it’s time to test database replication across the Galera Cluster. Let’s start by creating a database on Node1 and check whether it is replicated on all the nodes.

まずは, login to MariaDb console with the following command:

mysql u ルート-p

Enter your root password and create a database with name test_db:

[(なし)] MariaDB> create database test_db;
[(なし)] MariaDB> データベースを表示します。

+--------------------+
|データベース |
+--------------------+
| test_db            |
+--------------------+

Now go to the Node2 and Node3, then check replication is working or not:

mysql u ルート-p
[(なし)] MariaDB> データベースを表示します。

+--------------------+
|データベース |
+--------------------+
| test_db            |
+--------------------+

Congratulations! you have successfully installed and configured MariaDB Galera Cluster on Ubuntu 16.04 サーバー.

結論

I hope you have now enough knowledge to install and configure MariaDB Galera Cluster on Ubuntu 16.04. You can now easily scaled up to several, or even dozens, of distinct nodes. If you have any doubt or more query, then refer the link Galera Cluster Doc

ソース