Ubuntu

設置 MariaDB Galera 集群 Ubuntu Zesty

  • May 3, 2017

我不知道如何在 Ubuntu Zesty 上初始化 MariaDB Galera 集群。我已經按照文件進行了操作,但似乎缺少一些東西。我無法讓第一個節點出現。

我使用標準包安裝:

apt install mariadb-server

我已經在/etc/mysql/mariadb.conf.d/90-cluster.cnf

[mariadb]
bind-address = 0.0.0.0
binlog-format = ROW
innodb-autoinc-lock-mode = 2
innodb-flush-log-at-trx-commit = 0
wsrep-on = ON
wsrep-sst-method = rsync
wsrep-cluster-name = "example"
wsrep-cluster-address = "gcomm://maria01.example.com,maria02.example.com"
wsrep-node-address = "maria01"
wsrep-node-name = "maria01.example.com"

注意:我還嘗試將 wsrep-cluster-address 設置為“gcomm://”

我嘗試通過停止服務並從專用腳本開始來引導:

systemctl stop mariadb
galera_new_cluster

然後我連接到實例並檢查狀態:

show global variables like 'wsrep%';
+---------------------------------+-----------------------------------------+
| wsrep_osu_method                | TOI                                     |
| wsrep_auto_increment_control    | ON                                      |
| wsrep_causal_reads              | OFF                                     |
| wsrep_certify_nonpk             | ON                                      |
| wsrep_cluster_address           | gcomm://                                |
| wsrep_cluster_name              | example                                 |
| wsrep_convert_lock_to_trx       | OFF                                     |
| wsrep_data_home_dir             | /var/lib/mysql/                         |
| wsrep_dbug_option               |                                         |
| wsrep_debug                     | OFF                                     |
| wsrep_desync                    | OFF                                     |
| wsrep_dirty_reads               | OFF                                     |
| wsrep_drupal_282555_workaround  | OFF                                     |
| wsrep_forced_binlog_format      | NONE                                    |
| wsrep_gtid_domain_id            | 0                                       |
| wsrep_gtid_mode                 | OFF                                     |
| wsrep_load_data_splitting       | ON                                      |
| wsrep_log_conflicts             | OFF                                     |
| wsrep_max_ws_rows               | 0                                       |
| wsrep_max_ws_size               | 2147483647                              |
| wsrep_mysql_replication_bundle  | 0                                       |
| wsrep_node_address              | maria01                                 |
| wsrep_node_incoming_address     | AUTO                                    |
| wsrep_node_name                 | maria01.example.com                     |
| wsrep_notify_cmd                |                                         |
| wsrep_on                        | OFF                                     |
| wsrep_patch_version             | wsrep_25.16                             |
| wsrep_provider                  | none                                    |
| wsrep_provider_options          | pc.bootstrap=1                          |
| wsrep_recover                   | OFF                                     |
| wsrep_replicate_myisam          | OFF                                     |
| wsrep_restart_slave             | OFF                                     |
| wsrep_retry_autocommit          | 1                                       |
| wsrep_slave_fk_checks           | ON                                      |
| wsrep_slave_uk_checks           | OFF                                     |
| wsrep_slave_threads             | 1                                       |
| wsrep_sst_auth                  |                                         |
| wsrep_sst_donor                 |                                         |
| wsrep_sst_donor_rejects_queries | OFF                                     |
| wsrep_sst_method                | rsync                                   |
| wsrep_sst_receive_address       | AUTO                                    |
| wsrep_start_position            | 00000000-0000-0000-0000-000000000000:-1 |
| wsrep_sync_wait                 | 0                                       |
+---------------------------------+-----------------------------------------+

show status like 'wsrep%';
+--------------------------+----------------------+
| wsrep_cluster_conf_id    | 18446744073709551615 |
| wsrep_cluster_size       | 0                    |
| wsrep_cluster_state_uuid |                      |
| wsrep_cluster_status     | Disconnected         |
| wsrep_connected          | OFF                  |
| wsrep_local_bf_aborts    | 0                    |
| wsrep_local_index        | 18446744073709551615 |
| wsrep_provider_name      |                      |
| wsrep_provider_vendor    |                      |
| wsrep_provider_version   |                      |
| wsrep_ready              | ON                   |
| wsrep_thread_count       | 0                    |
+--------------------------+----------------------+

特別注意wsrep_cluster_size,它是0,但是galera_new_cluster按照文件執行後應該是1。

Maria 日誌內容不多,但集群似乎已初始化:

systemd[1]: Starting MariaDB database server...
sh[4083]: 2017-05-03 22:11:40 139734663651904 [Note] /usr/sbin/mysqld (mysqld 10.1.22-MariaDB-) starting as process 4203 ...
sh[4083]: WSREP: Recovered position 00000000-0000-0000-0000-000000000000:-1
mysqld[4238]: 2017-05-03 22:11:44 140634874606144 [Note] /usr/sbin/mysqld (mysqld 10.1.22-MariaDB-) starting as process 4238 ...
systemd[1]: Started MariaDB database server.

看起來您的集群配置缺少一些東西:

  1. wsrep_provider應該設置為 Galera wsrep 庫的路徑
  2. wsrep_on應設置為“開”。

看起來您實際上需要修改大部分配置以使用下劃線而不是破折號。狀態輸出中的關鍵問題是沒有wsrep_provider並且wsrep_on設置為關閉。您可以在MariaDB 頁面上查看強製配置設置。

引用自:https://serverfault.com/questions/848126