问题描述
我在 2 个 CentOs 6.6 服务器上安装了 2 个 Mariadb Galera 节点 (mariadb-galera-10.0.27-linux-x86_64.tar.gz).
I installed 2 Mariadb Galera nodes (mariadb-galera-10.0.27-linux-x86_64.tar.gz) on 2 CentOs 6.6 servers.
安装后,我用参数--wsrep-new-cluster
启动node1,然后不用这个参数启动node2.它们工作正常,数据在 2 个节点之间成功同步.
After installed, I start node1 with parameter --wsrep-new-cluster
, then start node2 without this parameter.They work fine, data is synchronized successfully between 2 nodes.
但是,当我关闭 node1.Node2 仍在运行,但是当我尝试访问数据库时.它显示此错误:
But, when I shutdown node1. Node2 still running, but when I try to access database. It show this error:
use testdb;
ERROR 1047 (08S01): WSREP has not yet prepared node for application use
在这种情况下会发生什么?这是我在 2 个节点上的配置(只是不同的 IP 地址)
What's happen in this case?Here is my configuration on 2 NODES (Just different IP address)
[galera]
wsrep_on=ON
wsrep_cluster_name='mysql-cluster'
wsrep_provider='/home/mariadb/mariadb-galera/lib/galera/libgalera_smm.so'
wsrep_provider_options="gcache.size=1G"
wsrep_cluster_address="gcomm://10.211.26.116:4567?
pc.wait_prim=no"
wsrep_sst_method=rsync
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
wsrep_node_address=10.211.26.117:4567
wsrep_node_name='db2'
推荐答案
双节点集群
在双节点集群中,单节点故障会导致另一个停止工作.
In a two-node cluster, a single-node failure causes the other to stop working.
情况
您有一个仅由两个节点组成的集群.其中一个节点不优雅地离开集群.也就是说,它不是通过 init 或 systemd 关闭,而是崩溃或失去网络连接.剩下的节点变得不可操作.在第三方(例如人工操作员或其他节点)提供一些额外信息之前,它一直如此.
You have a cluster composed of only two nodes. One of the nodes leaves the cluster ungracefully. That is, instead of being shut down through init or systemd, it crashes or suffers a loss of network connectivity. The node that remains becomes nonoperational. It remains so until some additional information is provided by a third party, such as a human operator or another node.
如果节点在另一个节点不正常地离开集群后仍然运行,则两个节点中的每个节点都可能认为自己是主要组件.为防止这种情况,节点将变为不可操作.
If the node remained operational after the other left the cluster ungracefully, there would be the risk that each of the two nodes will think itself as being the Primary Component. To prevent this, the node becomes nonoperational.
解决方案
您可以使用两种解决方案:
- 您可以使用 pc.boostrap wsrep Provider 选项引导幸存节点以形成新的主组件.为此,请登录数据库客户端并运行以下命令:
SET GLOBAL wsrep_provider_options='pc.bootstrap=YES';
这会将幸存的节点引导为新的主要组件.当其他节点重新上线或恢复与该节点的网络连接时,它将发起状态转移并赶上该节点.
This bootstraps the surviving node as a new Primary Component. When the other node comes back online or regains network connectivity with this node, it will initiate a state transfer and catch up with this node.
- 如果您希望节点继续运行,可以使用 pc.ignore_sb wsrep Provider 选项.为此,请登录数据库客户端并运行以下命令:
SET GLOBAL wsrep_provider_options='pc.ignore_sb=TRUE';
节点会继续处理更新并将继续这样做,即使它怀疑存在裂脑情况.
The node resumes processing updates and it will continue to do so, even in the event that it suspects a split-brain situation.
注意警告:在多主机设置中启用 pc.ignore_sb 是危险的,因为存在上述脑裂情况的风险.但是,它确实简化了主从集群中的事情(尤其是在您只使用两个节点的情况下).
除了上面提供的解决方案之外,您还可以使用 Galera Arbitrator 完全避免这种情况.Galera Arbitrator 在仲裁计算中充当奇数节点.这意味着,如果您在双节点集群中的一个节点上启用 Galera Arbitrator,则该节点仍然是主要组件,即使另一个节点发生故障或失去网络连接.
In addition to the solutions provided above, you can avoid the situation entirely using Galera Arbitrator. Galera Arbitrator functions as an odd node in quorum calculations. Meaning that, if you enable Galera Arbitrator on one node in a two-node cluster, that node remains the Primary Component, even if the other node fails or loses network connectivity.
http://galeracluster.com/documentation-webpages/twonode.html
这篇关于mariadb galera - 节点关闭时出错 ERROR 1047 WSREP 尚未准备好节点以供应用程序使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!