实施NDB Cluster后无法连接到MySQL数据库

Cannot connect to MySQL database after implementing NDB Cluster

提问人:Shawn Mccausland 提问时间:4/12/2023 最后编辑:Sanushi SalgadoShawn Mccausland 更新时间:4/15/2023 访问量:176

问:

我正在尝试从 mysql 数据库的单个实例转变为使用集群进行冗余,按照我从这里找到的步骤,我认为这是我需要的解决方案,但现在我收到一个错误,我似乎找不到在线解决方案。我已经创建了集群config.ini文件,并修改了mysql的my.cnf文件以指向我的管理服务器,但是当我现在尝试连接到MySQL时,我收到一个错误,我无法弄清楚到底出了什么问题。NDB 管理器说一切正常,MySQL 成功退出,错误代码为 0 表示成功,但它一直处于“服务器启动正在进行中”的状态,并给了我一个错误 22 的“无效参数”。请帮忙,我已经做了一个多星期了,我一辈子都想不通。ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 104

systemctl status ndb_mgmd返回:

ndb_mgmd.service - MySQL NDB Cluster Management Server
     Loaded: loaded (/etc/systemd/system/ndb_mgmd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-04-11 19:43:56 UTC; 2s ago
    Process: 5463 ExecStart=/usr/sbin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini (code=exited, status=0/SUCCESS)
   Main PID: 5464 (ndb_mgmd)
      Tasks: 12 (limit: 8500)
     Memory: 2.4M
        CPU: 52ms
     CGroup: /system.slice/ndb_mgmd.service
             └─5464 /usr/sbin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini

systemctl status mysql返回:

mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: activating (start) since Tue 2023-04-11 19:44:09 UTC; 825ms ago
    Process: 5733 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 5741 (mysqld)
     Status: "Server startup in progress"
      Error: 22 (Invalid argument)
      Tasks: 31 (limit: 8500)
     Memory: 364.0M
        CPU: 524ms
     CGroup: /system.slice/mysql.service
             └─5741 /usr/sbin/mysqld

尝试连接然后输入密码会给出:mysql -u root -p

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 104

/etc/mysql/my.cnf:

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
# Options for mysqld process:
ndbcluster                      # run NDB storage engine

[mysql_cluster]
# Options for NDB Cluster processes:
ndb-connectstring=192.168.195.101  # location of management server

/var/lib/mysql-cluster/config.ini:

[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=1  # Number of replicas

[ndb_mgmd]
# Management process options:
hostname=192.168.195.101 # Hostname of the manager
datadir=/var/lib/mysql-cluster  # Directory for the log files

[ndbd]
hostname=192.168.195.167 # Hostname/IP of the second data node
NodeId=2                       # Node ID for this data node
datadir=/usr/local/mysql/data   # Remote directory for the data files

[mysqld]
# SQL node options:
hostname=192.168.195.101 # In our case the MySQL server/client is on the same Droplet as the cluster manager

我已经对 IP 地址进行了三倍检查,但自从我开始尝试使用第二个单元进行集群以来,我什至无法连接到 MySQL 进行任何进一步的测试。如何解决这个问题?

集群计算 冗余 mysql-cluster ndb

评论

0赞 Zak 4/12/2023
最新消息是什么?它应该在“中止”报告之前给你一些错误行。/var/log/mysql/error.log
0赞 Shawn Mccausland 4/12/2023
感谢您的快速回复扎克!mysql 的 error.log 文件中的最后一条消息是:unkown option '--ndbcluster' - Aborting
0赞 Zak 4/12/2023
也许可以看看这篇文章,以确保你的集群已正确设置和连接。IT 包含一个与该确切错误相对应的区域。
0赞 Mauritz Sundell 4/12/2023
在 8.0.31 之前,需要使用 mysql-cluster 软件包中的 mysqld 来支持 --ndbcluster。从 8.0.31 开始,标准 mysqld 也应该支持 --ndbcluster。除非您的包管理器决定明确排除对 ndbcluster 的支持,否则在这种情况下,您仍然需要使用 mysql-cluster 包中的 mysqld。

答: 暂无答案