CentOS 7でMariaDB 10.1 Galera Clusterのブートストラップに失敗しました: 解決策
CentOS 7におけるMariaDB 10.1 Galera Clusterのブートストラップに関する問題の解決策
症状:
galera_new_cluster
コマンドを実行するとエラーが発生する。- MariaDBサービスが起動しない。
- エラーログに「wsrep_cluster_address に指定されたIPアドレスが起動していない」などのメッセージが表示される。
原因:
この問題は、いくつかの要因が考えられます。
- Galera Cluster構成が正しくない:
wsrep_cluster_address
設定が誤っている、またはすべてのノードが同じ構成ファイルを使用していない可能性があります。 - ファイアウォールがGalera通信をブロックしている: Galera Clusterは、ポート3306と4504で通信を行う必要があります。これらのポートがファイアウォールでブロックされていると、ブートストラップが失敗する可能性があります。
- MariaDBサービスが適切に初期化されていない: MariaDBサービスが適切に初期化されていない場合、Galera Clusterが起動できない可能性があります。
解決策:
以下の手順で問題を解決することができます。
- ファイアウォール設定を確認する: Galera Clusterが使用するポート3306と4504がファイアウォールでブロックされていないことを確認してください。
- MariaDBサービスを再起動する: MariaDBサービスを再起動すると、問題が解決する場合があります。
補足:
- 上記の手順で問題が解決しない場合は、ログファイルを調べて、詳細な情報を確認してください。
- 問題が解決しない場合は、フォーラムやコミュニティで助けを求めることもできます。
Creating a Galera Cluster configuration file
# /etc/my.cnf
[galera]
wsrep_cluster_name = "my_cluster"
wsrep_node_address = "192.168.1.10"
wsrep_initial_configuration = "
node1 address='192.168.1.10'
node2 address='192.168.1.11'
node3 address='192.168.1.12'
"
[mysqld]
binlog = /var/log/mariadb/galera-binlog.log
innodb_file_per_table=1
Bootstrapping a Galera Cluster
sudo galera_new_cluster
Starting the MariaDB service
sudo systemctl start mariadb
Checking the cluster status
sudo mysql -u root -p
mysql> SHOW STATUS LIKE '%wsrep%';
Adding a new node to the cluster
# On the new node
sudo yum install mariadb-server
sudo cp /etc/my.cnf /etc/my.cnf.new
sudo vim /etc/my.cnf.new
# Change the wsrep_node_address and wsrep_initial_configuration settings to match the cluster
sudo systemctl start mariadb
# On the node to be removed
sudo systemctl stop mariadb
sudo rm -rf /var/lib/mysql
sudo systemctl start mariadb
# On the remaining nodes
mysql> wsrep_remove_node 'node_id';
Note: These are just basic examples and the specific configuration will vary depending on your needs. Please refer to the MariaDB Galera Cluster documentation for more detailed information.
I hope this helps! Let me know if you have any other questions.
Method 1: Using the systemd unit file
- Create a systemd unit file for Galera Cluster:
[Unit]
Description=MariaDB Galera Cluster Service
After=network.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/sbin/mysqld --defaults-file=/etc/my.cnf --wsrep-cluster-address="gcluster1:3306,gcluster2:3306,gcluster3:3306" --wsrep-initial-configuration="node1 address='192.168.1.10', node2 address='192.168.1.11', node3 address='192.168.1.12'"
Restart=always
[Install]
WantedBy=multi-user.target
- Save the unit file as
/etc/systemd/system/mariadb-galera.service
. - Enable the unit file:
sudo systemctl enable mariadb-galera.service
sudo systemctl start mariadb-galera.service
- Add the following lines to the
/etc/my.cnf
configuration file:
[mysqld]
wsrep_cluster_name = "my_cluster"
wsrep_node_address = "192.168.1.10"
wsrep_initial_configuration = "
node1 address='192.168.1.10'
node2 address='192.168.1.11'
node3 address='192.168.1.12'
"
- Save the
/etc/my.cnf
file.
sudo systemctl restart mariadb.service
Method 3: Using the mysql command-line tool
- Start the MariaDB service on the first node:
sudo systemctl start mariadb.service
sudo mysql -u root -p
- Execute the following commands to bootstrap the cluster:
mysql> SET GLOBAL wsrep_cluster_name = 'my_cluster';
mysql> SET GLOBAL wsrep_node_address = '192.168.1.10';
mysql> SET GLOBAL wsrep_initial_configuration = '
node1 address='192.168.1.10'
node2 address='192.168.1.11'
node3 address='192.168.1.12'
';
mysql> START wsrep_cluster;
# On the second node
sudo systemctl start mariadb.service
# On the third node
sudo systemctl start mariadb.service
Note: These methods are all equivalent and will achieve the same result. Choose the method that is most convenient for you.
mariadb galera