MariaDB Galera Clustering - Active Active - 操作不允许错误

MariaDB Galera Clustering - Active Active - 操作不允许错误

我在 RHEL 6.4 & 6.2 64 位服务器上运行 MariaDB 和 Galera 时遇到问题,无法将它们加入集群。我安装了 Galera 集群所需的 RPM:

  • MariaDB-Galera 服务器
  • MariaDB 客户端
  • 兼容 MariaDB
  • MariaDB-通用
  • 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   [email protected] 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   [email protected] 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   [email protected] 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   [email protected] 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   [email protected] 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   [email protected] 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   [email protected] 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   [email protected] 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   [email protected] 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

我不确定我还应该做什么。我之前曾让这个集群工作过,但在完成操作系统基线后,我立即恢复到快照。所以,在我看来,它应该以相同的方式工作,但事实并非如此。我是否应该在盒子上创建一个与数据库用户同名的本地用户?

答案1

如果您查看 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

集群奇迹般地工作了。我能够在数据库之间进行复制,并使它们现在正常运行。我不太清楚为什么那一行会阻止一切工作,但事实确实如此。

相关内容