部署NDB Cluster后无法连接MySQL数据库的问题求助
问题:MySQL NDB Cluster搭建后无法连接MySQL服务
问题描述
尝试将单实例MySQL迁移至NDB Cluster实现冗余,操作后遇到无法解决的问题:已创建集群config.ini并修改my.cnf指向管理服务器,但连接MySQL时出现错误:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 104
NDB管理器运行正常,MySQL预启动进程成功退出(状态码0),但服务一直处于server startup in progress状态,伴随错误码22(无效参数)。已反复核对IP地址,仍无法解决。
相关状态输出
ndb_mgmd服务状态
执行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
MySQL服务状态
执行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进行测试,求解决方法。
内容的提问来源于stack exchange,提问作者Shawn Mccausland
相关产品推荐
相关产品推荐

