Mysql

MariaDB Galera Clustering - Active Active - Operation not allowed 錯誤

  • September 11, 2013

我遇到了在 RHEL 6.4 和 6.2 64 位伺服器上執行的 MariaDB 和 Galera 問題,並將它們加入集群。我為 Galera 集群安裝了所需的 RPM:

  • MariaDB-Galera-伺服器
  • MariaDB 客戶端
  • MariaDB 兼容
  • MariaDB-common
  • MariaDB 共享
  • MariaDB 測試
  • 伙計們

然後在安裝 MariaDB 及其所有組件後,我檢查了它通常保存文件的目錄,/var/lib/mysql//var/log/mysql/執行了

chown -R mysql:mysql /var/lib/mysql/
chown -R mysql:mysql /var/log/mysql/

我以獨立模式啟動了兩台伺服器並配置了一個複制使用者:

grant all privileges on *.* to 'mariadb-user'@'localhost' identified by 'password' with grant option;
grant all privileges on *.* to 'mariadb-user'@'%' identified by 'password' with grant option;

這樣,我將有一個使用者與數據庫進行通信。然後我在主節點和從節點上編輯了我的配置:

#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]
general_log_file=/var/log/mysql/mysqld.log
general_log=1
log_warning=2
log-error=/var/log/mysql/error.log
#log-bin=/var/log/mysql-bin.log
log-slow-queries=/var/log/mysql-slow-queries.log
# this is only for the mysqld standalone daemon
[mysqld]

# this is only for embedded server
[embedded]

# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]

# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
wsrep_cluster_address=gcomm://mariadb-master.net,mariadb-slave.net
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
innodb_locks_unsafe_for_binlog=1
wsrep_cluster_name=corp-zabbix-server
wsrep_debug=on
wsrep_sst_auth=mariadb-user:cerner
##wsrep_sst_auth=root:
wsrep_sst_method=mysqldump
##wsrep_sst_method=xtrabackup
[mariadb-5.5]

一旦配置到位,我確保防火牆允許流量通過,基本上只是將它們清除iptables -F。然後我使用以下方法在主伺服器上初始化集群:

/etc/init.d/mysql start --wsrep_cluster_address=gcomm://

該程序出現在主節點上,並在從節點上使用:

service mysql start

然後從節點連接一段時間,交換狀態,然後退出,表示不允許該操作。

Pastebin.com 上的 MariaDB_Error_Log

這是來自的輸出/var/log/mysql/mysql.log

/usr/sbin/mysqld, Version: 5.5.32-MariaDB-log (MariaDB Server, wsrep_23.7.5.rXXXX). started with:
Tcp port: 0  Unix socket: (null)
Time                 Id Command    Argument
/usr/sbin/mysqld, Version: 5.5.32-MariaDB-log (MariaDB Server, wsrep_23.7.5.rXXXX). started with:
Tcp port: 0  Unix socket: (null)
Time                 Id Command    Argument
130910  8:18:48     3 Connect   mariadb-user@mariadb-master.net as anonymous on
                   3 Query     select @@version_comment limit 1
                   3 Query     SET wsrep_on=OFF
                   3 Query     SELECT @@GENERAL_LOG
                   3 Quit
                   4 Connect   mariadb-user@mariadb-master.net as anonymous on
                   4 Query     select @@version_comment limit 1
                   4 Query     SET wsrep_on=OFF
                   4 Query     SELECT @@SLOW_QUERY_LOG
                   4 Quit
                   5 Connect   mariadb-user@mariadb-master.net as anonymous on
                   5 Query     select @@version_comment limit 1
                   5 Query     SET wsrep_on=OFF
                   5 Query     SET GLOBAL GENERAL_LOG=OFF
/usr/sbin/mysqld, Version: 5.5.32-MariaDB-log (MariaDB Server, wsrep_23.7.5.rXXXX). started with:
Tcp port: 3306  Unix socket: /var/lib/mysql/mysql.sock
Time                 Id Command    Argument
130910  8:18:50     7 Query     SET GLOBAL SLOW_QUERY_LOG=1
                   7 Quit
130910  8:18:51     8 Connect   mariadb-user@mariadb-master.net as anonymous on
                   8 Query     select @@version_comment limit 1
                   8 Query     SET wsrep_on=OFF
                   8 Query     SELECT @@GENERAL_LOG
                   8 Quit
                   9 Connect   mariadb-user@mariadb-master.net as anonymous on
                   9 Query     select @@version_comment limit 1
                   9 Query     SET wsrep_on=OFF
                   9 Query     SELECT @@SLOW_QUERY_LOG
                   9 Quit
                  10 Connect   mariadb-user@mariadb-master.net as anonymous on
                  10 Query     select @@version_comment limit 1
                  10 Query     SET wsrep_on=OFF
                  10 Query     SET GLOBAL GENERAL_LOG=OFF
/usr/sbin/mysqld, Version: 5.5.32-MariaDB-log (MariaDB Server, wsrep_23.7.5.rXXXX). started with:
Tcp port: 3306  Unix socket: /var/lib/mysql/mysql.sock
Time                 Id Command    Argument
130910  8:18:52    12 Query     SET GLOBAL SLOW_QUERY_LOG=1
                  12 Quit
130910  8:18:53    13 Connect   mariadb-user@mariadb-master.net as anonymous on
                  13 Query     select @@version_comment limit 1
                  13 Query     SET wsrep_on=OFF
                  13 Query     SELECT @@GENERAL_LOG
                  13 Quit
                  14 Connect   mariadb-user@mariadb-master.net as anonymous on
                  14 Query     select @@version_comment limit 1
                  14 Query     SET wsrep_on=OFF
                  14 Query     SELECT @@SLOW_QUERY_LOG
                  14 Quit
                  15 Connect   mariadb-user@mariadb-master.net as anonymous on
                  15 Query     select @@version_comment limit 1
                  15 Query     SET wsrep_on=OFF
                  15 Query     SET GLOBAL GENERAL_LOG=OFF
/usr/sbin/mysqld, Version: 5.5.32-MariaDB-log (MariaDB Server, wsrep_23.7.5.rXXXX). started with:
Tcp port: 3306  Unix socket: /var/lib/mysql/mysql.sock
Time                 Id Command    Argument
130910  8:18:55    17 Query     SET GLOBAL SLOW_QUERY_LOG=1
                  17 Quit

我不確定我還應該做什麼。我之前讓這個集群工作過,但在我完成作業系統基線後立即恢復到快照。所以,在我看來,它應該以同樣的方式工作,但事實並非如此。我應該在與數據庫使用者同名的盒子上創建一個本地使用者嗎?

如果您查看 pastebin 連結上的錯誤消息,在第 18 和 19 行,有一個參考:

130906 12:47:32 [ERROR] mysqld: File '/var/log/mysql-slow-queries.log' not found (Errcode: 13)
130906 12:47:32 [ERROR] Could not use /var/log/mysql-slow-queries.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it.

我所做的是當我製作我的配置文件時,我捏造了一行:

log-slow-queries=/var/log/mysql-slow-queries.log

一旦我編輯了這一行以反映:

log-slow-queries=/var/log/mysql/mysql-slow-queries.log

集群神奇地工作了。我能夠在數據庫之間複製並讓它們現在起作用。我不確定為什麼那一行會阻止一切正常工作,但確實如此。

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