MariaDB Galera集群设置问题

2024-03-08

我正在尝试启动并运行 mariadb 集群,但它对我来说不起作用。现在我在 64 位 Red hat ES6 机器上使用 MariaDB Galera 5.5.36。我通过这里的存储库安装了 mariadb:

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5-galera/rhel6-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

在 server.conf 中,服务器 1 中有以下内容:

[mariadb]
log_error=/var/log/mariadb.log
query_cache_size=0
query_cache_type=0
binlog_format=ROW
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.211.133
wsrep_cluster_name='cluster'
wsrep_node_address='192.168.211.132'
wsrep_node_name='cluster1'
wsrep_sst_method=rsync

在服务器2上我有

[mariadb]
log_error=/var/log/mariadb.log
query_cache_size=0
query_cache_type=0
binlog_format=ROW
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.211.132
wsrep_cluster_name='cluster'
wsrep_node_address='192.168.211.133'
wsrep_node_name='cluster2'
wsrep_sst_method=rsync

当我使用以下命令启动服务器 1 时: sudo service mysql start --wsrep-new-cluster 它启动得很好,如果我打开 mysql 并检查 wsrep 的状态,它会说一切都已启动并正在运行,这很好,但是当我尝试在第二台服务器上执行 sudo service mysql start 我在错误日志中收到以下内容:

140609 14:47:55 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140609 14:47:56 mysqld_safe WSREP: Running position recovery with --log_error='/var/lib/mysql/wsrep_recovery.i5qfm2' --pid-file='/var/lib/mysql/localhost.localdomain-recover.pid'
140609 14:47:57 mysqld_safe WSREP: Recovered position 85448d73-ebe8-11e3-9c20-fbc1995fee11:0
140609 14:47:57 [Note] WSREP: wsrep_start_position var submitted: '85448d73-ebe8-11e3-9c20-fbc1995fee11:0'
140609 14:47:57 [Note] WSREP: Read nil XID from storage engines, skipping position init
140609 14:47:57 [Note] WSREP: wsrep_load(): loading provider library '/usr/lib64/galera/libgalera_smm.so'
140609 14:47:57 [Note] WSREP: wsrep_load(): Galera 25.3.2(r170) by Codership Oy <[email protected] /cdn-cgi/l/email-protection> loaded successfully.
140609 14:47:57 [Note] WSREP: CRC-32C: using hardware acceleration.
140609 14:47:57 [Note] WSREP: Found saved state: 85448d73-ebe8-11e3-9c20-fbc1995fee11:-1
140609 14:47:57 [Note] WSREP: Passing config to GCS: base_host = 192.168.211.133; base_port = 4567; cert.log_conflicts = no; gcache.dir = /var/lib/mysql/; gcache.keep_pages_size = 0; gcache.mem_size = 0; gcache.name = /var/lib/mysql//galera.cache; gcache.page_size = 128M; gcache.size = 128M; gcs.fc_debug = 0; gcs.fc_factor = 1; gcs.fc_limit = 16; gcs.fc_master_slave = NO; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; gcs.recv_q_hard_limit = 9223372036854775807; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = NO; repl.causal_read_timeout = PT30S; repl.commit_order = 3; repl.key_format = FLAT8; repl.proto_max = 5
140609 14:47:57 [Note] WSREP: Assign initial position for certification: 0, protocol version: -1
140609 14:47:57 [Note] WSREP: wsrep_sst_grab()
140609 14:47:57 [Note] WSREP: Start replication
140609 14:47:57 [Note] WSREP: Setting initial position to 85448d73-ebe8-11e3-9c20-fbc1995fee11:0
140609 14:47:57 [Note] WSREP: protonet asio version 0
140609 14:47:57 [Note] WSREP: Using CRC-32C (optimized) for message checksums.
140609 14:47:57 [Note] WSREP: backend: asio
140609 14:47:57 [Note] WSREP: GMCast version 0
140609 14:47:57 [Note] WSREP: (0c085f34-efe5-11e3-9f6b-8bfd1706e2a4, 'tcp://0.0.0.0:4567') listening at tcp://0.0.0.0:4567
140609 14:47:57 [Note] WSREP: (0c085f34-efe5-11e3-9f6b-8bfd1706e2a4, 'tcp://0.0.0.0:4567') multicast: , ttl: 1
140609 14:47:57 [Note] WSREP: EVS version 0
140609 14:47:57 [Note] WSREP: PC version 0
140609 14:47:57 [Note] WSREP: gcomm: connecting to group 'cluster', peer '192.168.211.132:,192.168.211.134:'
140609 14:48:00 [Warning] WSREP: no nodes coming from prim view, prim not possible
140609 14:48:00 [Note] WSREP: view(view_id(NON_PRIM,0c085f34-efe5-11e3-9f6b-8bfd1706e2a4,1) memb {
        0c085f34-efe5-11e3-9f6b-8bfd1706e2a4,0
} joined {
} left {
} partitioned {
})
140609 14:48:01 [Warning] WSREP: last inactive check more than PT1.5S ago (PT3.50775S), skipping check
140609 14:48:31 [Note] WSREP: view((empty))
140609 14:48:31 [ERROR] WSREP: failed to open gcomm backend connection: 110: failed to reach primary view: 110 (Connection timed out)
         at gcomm/src/pc.cpp:connect():141
140609 14:48:31 [ERROR] WSREP: gcs/src/gcs_core.c:gcs_core_open():196: Failed to open backend connection: -110 (Connection timed out)
140609 14:48:31 [ERROR] WSREP: gcs/src/gcs.c:gcs_open():1291: Failed to open channel 'cluster' at 'gcomm://192.168.211.132,192.168.211.134': -110 (Connection timed out)
140609 14:48:31 [ERROR] WSREP: gcs connect failed: Connection timed out
140609 14:48:31 [ERROR] WSREP: wsrep::connect() failed: 7
140609 14:48:31 [ERROR] Aborting

140609 14:48:31 [Note] WSREP: Service disconnected.
140609 14:48:32 [Note] WSREP: Some threads may fail to exit.
140609 14:48:32 [Note] /usr/sbin/mysqld: Shutdown complete

140609 14:48:32 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended

我不明白为什么第二台服务器无法检测到集群已启动并正在运行。这些机器可以很好地相互通信,我可以从一台机器通过 SSH 连接到另一台机器,并且它们可以互相 ping 通。我尝试删除 galera 缓存,尝试降级 mariadb galera 版本,尝试禁用 SELinux,尝试以其他用户身份运行 mysql 服务,验证正确的端口已打开,尝试在具有不同 IP 地址的不同计算机上的 2 个虚拟机上运行它们等等。有谁知道这里发生了什么,因为我已经搜索了 3 天试图解决这个问题,但似乎没有解决方案适合我。


这是我解决类似问题的方法。

CentOS 7 带 MariaDB Galera 10.1。

Node2 我看到了这个:

016-12-27 15:40:38 140703512762624 [Warning] WSREP: no nodes coming from prim view, prim not possible

读了一些书后,我尝试在node1上运行它。

service mysql start --wsrep-new-cluster

但这失败了,在日志中,我发现了这个......

2016-12-27 15:44:08 140438853814528 [ERROR] WSREP: It may not be safe to bootstrap the cluster from this node. It was not the last one to leave the cluster and may not contain all the updates. To force cluster bootstrap with this node, edit the grastate.dat file manually and set safe_to_bootstrap to 1 .

所以我编辑了文件/var/lib/mysql/grastate.dat,改变safe_to_bootstrap to 1.

然后我可以使用以下命令启动主节点:

service mysql start --wsrep-new-cluster

然后在其他方面,我只是使用

service mysql start

注意:这是在演示预生产环境中。在通过同时重新启动所有服务器使一切正常工作后,我立即破坏了它:P,但我知道没有写入,并且数据库是同步的。如果您在生产中并且发生这种情况,您可以使用以下命令来确定在哪个节点上运行“new-cluster”,这类似于说,让我成为主要节点。

mysqld_safe --wsrep-recover

如果这是一个生产问题,我强烈建议您阅读本文并在向损坏的客户端发出命令之前使用 CloneZilla 进行备份!

https://www.percona.com/blog/2014/09/01/galera-replication-how-to-recover-a-pxc-cluster/ https://www.percona.com/blog/2014/09/01/galera-replication-how-to-recover-a-pxc-cluster/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

MariaDB Galera集群设置问题 的相关文章

  • 限制分页页数

    objConnect mysql connect localhost root or die mysql error objDB mysql select db Test strSQL SELECT FROM UserAddedRecord
  • 使用php插入sql数据库时出错

    我有一个带有 MySQL 插入查询的程序 sql INSERT INTO people person id name username password email salt VALUES person id name username p
  • 使用来自另一个的 SELECT 更新表,但字段为 SUM(someField)

    基本上我有这样的事情 UPDATE Table SET Table col1 other table col1 FROM Table INNER JOIN other table ON Table id other table id 问题是
  • PHP 和 MySQL 的重音字符错误

    我的问题是 直接通过 PHP 编写的内容是正确重音的 但是当重音单词来自 MySQL 时 字母会像这样 我尝试使用html charset as ISO 8859 1它修复了 MySQL 字母 但破坏了其他字母 解决这一切的一种方法是设置我
  • MySQL 中布尔值的 TINYINT 与 ENUM(0, 1)

    MyISAM 表和 MySQL 5 1 中具有 0 和 1 值的 Tinyint 或 ENUM 0 1 哪个更好 您可以使用BIT 1 如中提到的MySQL 5 1 参考 http dev mysql com doc refman 5 1
  • 数据读取过程中遇到致命错误

    我正在进行定期更新表扫描 Using connect1 As New MySqlConnection ConnectLocalhost serverString connect1 Open Dim cmd New MySqlCommand
  • MYSQL 按喜欢/不喜欢和受欢迎程度排序

    我有评论表 其中包括喜欢和不喜欢的内容 现在我在正确的顺序上遇到了问题 实际上 我的系统在顶部显示了最多点赞的评论 我正在 youtube 上寻找类似系统的东西 这意味着 100like 100dislikes 的评论的顺序高于 1 1 我
  • mod_rewrite, .htaccess 连接mysql数据库

    我希望 htaccess 文件中的 mod rewrite 链接到 mysql 数据库以向我提供映射信息 具体来说 我使用单个代码库来托管多个站点 因此 如果用户请求图像 例如 http www example com images car
  • MySQL SELECT OpenCarts 数据库中的重复行

    只是玩一下 OpenCart DB 看看我是否能学到一些东西 如果我使用以下SELECT结果返回重复的行 SELECT DISTINCT p product id AS pid p model AS modelo SUBSTRING p m
  • 用于全文搜索和 2 亿多条记录的数据库

    我即将创建一个包含至少 2 亿个条目的庞大数据库 数据库需要可使用全文进行搜索 并且速度应该很快 我的数据库从许多不同的数据源获取数据 我需要定期导入新的或更新的数据 将我的所有数据存储在像 mysql 这样的关系数据库中 然后创建一个 n
  • MySQL Tinybit(1) 通过视图的列

    我有一个连接 2 个表的视图 其中一个表具有表示布尔值的tinyint 1 类型的列 该表在连接时并不总是有条目 因此当行丢失时视图需要采用 0 false 值 我希望视图公开 TINYINT 1 类型且 NOT NULL 类型的列 因为它
  • 如何在 Ansible 中运行 MySQL 查询

    我需要编写一个 Ansible 脚本来在 MySQL 数据库中执行 SQL 查询 这是我尝试过的 你能指导一下吗 hosts localhost tasks name retrive data command mysql u root h
  • 使用 Laravel 和 Eloquent 从表中选择全部

    我正在使用 Laravel 4 设置我的第一个模型 以从名为的表中提取所有行posts 在标准 MySQL 中我会使用 SELECT FROM posts 如何在 Laravel 4 模型中实现这一目标 我的完整模型源代码如下
  • MySQL 薛定谔表:存在,但不存在

    我遇到了最奇怪的错误 有时 在创建或更改表时 我会收到 表已存在 错误 但是 DROP TABLE 返回 1051 未知表 所以我得到了一个无法创建 无法删除的表 当我尝试删除数据库时 mysql 崩溃了 有时它有助于创建另一个具有不同名称
  • PHP-MySQLi 连接随机失败并显示“无法分配请求的地址”

    大约两周以来 我一直在处理 LAMP 堆栈中最奇怪的问题之一 长话短说 与 MySQL 服务器的随机连接失败并显示错误消息 Warning mysqli real connect HY000 2002 Cannot assign reque
  • 蟒蛇 | MySQL | AttributeError:模块“mysql.connector”没有属性“connect”

    我正在学习 python 中的一个新库 mysql 我尝试执行以下命令 import mysql connector mydb mysql connector connect host localhost user root passwd
  • MySQL 两种日期格式之间的转换

    用户将以这种格式输入日期 2017 年 2 月 17 日 存储在 mysql 数据库中的日期格式如下 2015 02 17 00 00 00 我想做的是 SELECT FROM insurance where DATE FORMAT in
  • 批处理文件并与数据库比较

    目前我正在开发一个 Spring Boot 应用程序 该应用程序定期尝试处理包含用户数据的文件 其中每行都包含userId and departamentId隔开 例如123534 13 该文件将包含数百万条记录 我的要求是以这样的方式将此
  • Mysql加密/存储敏感数据,

    我的 PHP 网站有以下内容 启用 SSL 饼干 session set cookie params cookieParams lifetime cookieParams path cookieParams domain secure ht
  • 如何统计订单总价?

    我有这些表 Orders id status user id address id 1 await 1 1 products id name price quantity 1 test1 100 5 2 test2 50 5 order p

随机推荐