Cluster角色重新分配:
192.168.211.10 mgm + data + sql
192.168.211.9 data + sql
192.168.211.11 + sql (not used)
211.10上开始:
# lsof -i:1186 # 启动管理节点之前
# ndb_mgmd --ndb_nodeid=1 -f /var/lib/mysql-cluster/config.ini #启动管理节点
# lsof -i:1186
有以下提示信息:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ndb_mgmd 8097 root 8u IPv4 71559 TCP *:mysql-cluster (LISTEN)
ndb_mgmd 8097 root 9u IPv4 71560 TCP localhost.localdomain:53808->loc )
ndb_mgmd 8097 root 10u IPv4 71563 TCP localhost.localdomain:mysql-clus)
command:进程名称;FD:文件描述符,应用程序通过文件描述符来识别该文件;type:文件类型;device size:磁盘文件大小;node:索引节点,即文件在磁盘上的标识;name:打开文件的确切名称。
# ps -A | grep ndb
提示信息: 8097 ? 00:00:00 ndb_mgmd
# ndbd --ndb_nodeid=2 #启动数据节点
# lsof -i:2202
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ndbd 8166 root 9u IPv4 71794 TCP 192.168.211.10:imtc-map (LISTEN)
# ps -A | grep ndbd
提示信息:
8165 ? 00:00:00 ndbd
8166 ? 00:00:01 ndbd
# lsof -i:1186
提示信息:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ndb_mgmd 8097 root 8u IPv4 71559 TCP *:mysql-cluster (LISTEN)
ndb_mgmd 8097 root 9u IPv4 71560 TCP localhost.localdomain:53808->localhost.localdomain:mysql-cluster (ESTABLISHED)
ndb_mgmd 8097 root 10u IPv4 71563 TCP localhost.localdomain:mysql-cluster->localhost.localdomain:53808 (ESTABLISHED)
ndb_mgmd 8097 root 11u IPv4 71787 TCP 192.168.211.10:mysql-cluster->192.168.211.10:37721 (ESTABLISHED)
ndb_mgmd 8097 root 12u IPv4 71791 TCP 192.168.211.10:mysql-cluster->192.168.211.10:37722 (ESTABLISHED)
ndbd 8165 root 3u IPv4 71786 TCP 192.168.211.10:37721->192.168.211.10:mysql-cluster (ESTABLISHED)
ndbd 8166 root 3u IPv4 71786 TCP 192.168.211.10:37721->192.168.211.10:mysql-cluster (ESTABLISHED)
ndbd 8166 root 7u IPv4 71790 TCP 192.168.211.10:37722->192.168.211.10:mysql-cluster (ESTABLISHED)
# ndbd --ndb_nodeid=3 #211.9
# ps -A | grep ndb
7029 ? 00:00:00 ndbd
7030 ? 00:00:04 ndbd
# lsof -i:2202 # 211.9
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ndbd 7030 root 9u IPv4 14285 TCP 192.168.211.9:imtc-map (LISTEN)
ndbd 7030 root 12u IPv4 14288 TCP 192.168.211.9:52533->192.168.211.10:imtc-map (ESTABLISHED)
# lsof -i:2202 # 211.10
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ndbd 8166 root 9u IPv4 71794 TCP 192.168.211.10:imtc-map (LISTEN)
ndbd 8166 root 22u IPv4 71933 TCP 192.168.211.10:imtc-map->192.168.211.9:52533 (ESTABLISHED)
# lsof -i:1186 # 211.10
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ndb_mgmd 8097 root 8u IPv4 71559 TCP *:mysql-cluster (LISTEN)
ndb_mgmd 8097 root 9u IPv4 71560 TCP localhost.localdomain:53808->localhost.localdomain:mysql-cluster (ESTABLISHED)
ndb_mgmd 8097 root 10u IPv4 71563 TCP localhost.localdomain:mysql-cluster->localhost.localdomain:53808 (ESTABLISHED)
ndb_mgmd 8097 root 11u IPv4 71787 TCP 192.168.211.10:mysql-cluster->192.168.211.10:37721 (ESTABLISHED)
ndb_mgmd 8097 root 12u IPv4 71791 TCP 192.168.211.10:mysql-cluster->192.168.211.10:37722 (ESTABLISHED)
ndb_mgmd 8097 root 13u IPv4 71931 TCP 192.168.211.10:mysql-cluster->192.168.211.9:50749 (ESTABLISHED)
ndb_mgmd 8097 root 14u IPv4 71932 TCP 192.168.211.10:mysql-cluster->192.168.211.9:50750 (ESTABLISHED)
ndbd 8165 root 3u IPv4 71786 TCP 192.168.211.10:37721->192.168.211.10:mysql-cluster (ESTABLISHED)
ndbd 8166 root 3u IPv4 71786 TCP 192.168.211.10:37721->192.168.211.10:mysql-cluster (ESTABLISHED)
ndbd 8166 root 7u IPv4 71790 TCP 192.168.211.10:37722->192.168.211.10:mysql-cluster (ESTABLISHED)
# lsof -i:3306 # 211.9
# mysqld_safe --ndb_nodeid=5 --user=mysql & # 211.9
# ps -A | grep mysql
提示信息:
7094 pts/2 00:00:00 mysqld_safe
7252 pts/2 00:00:00 mysqld
# lsof -i:3306 # 211.9
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
mysqld 7252 mysql 17u IPv4 14530 TCP *:mysql (LISTEN)
# lsof -i:1186 # 211.10
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ndb_mgmd 8097 root 8u IPv4 71559 TCP *:mysql-cluster (LISTEN)
ndb_mgmd 8097 root 9u IPv4 71560 TCP localhost.localdomain:53808->localhost.localdomain:mysql-cluster (ESTABLISHED)
ndb_mgmd 8097 root 10u IPv4 71563 TCP localhost.localdomain:mysql-cluster->localhost.localdomain:53808 (ESTABLISHED)
ndb_mgmd 8097 root 11u IPv4 71787 TCP 192.168.211.10:mysql-cluster->192.168.211.10:37721 (ESTABLISHED)
ndb_mgmd 8097 root 12u IPv4 71791 TCP 192.168.211.10:mysql-cluster->192.168.211.10:37722 (ESTABLISHED)
ndb_mgmd 8097 root 13u IPv4 71931 TCP 192.168.211.10:mysql-cluster->192.168.211.9:50749 (ESTABLISHED)
ndb_mgmd 8097 root 14u IPv4 71932 TCP 192.168.211.10:mysql-cluster->192.168.211.9:50750 (ESTABLISHED)
ndb_mgmd 8097 root 15u IPv4 72005 TCP 192.168.211.10:mysql-cluster->192.168.211.9:45770 (ESTABLISHED)
ndbd 8165 root 3u IPv4 71786 TCP 192.168.211.10:37721->192.168.211.10:mysql-cluster (ESTABLISHED)
ndbd 8166 root 3u IPv4 71786 TCP 192.168.211.10:37721->192.168.211.10:mysql-cluster (ESTABLISHED)
ndbd 8166 root 7u IPv4 71790 TCP 192.168.211.10:37722->192.168.211.10:mysql-cluster (ESTABLISHED)
# lsof -i:3306 # 211.10
没有提示信息,端口没有被占用。
# mysqld_safe --ndb_nodeid=4 --user=mysql & # 211.10
# ps -A | grep mysql # 211.10
8290 pts/2 00:00:00 mysqld_safe
8448 pts/2 00:00:00 mysqld
# lsof -i:3306 # 211.10
没有提示信息,端口没有被占用。所以mysqld_safe命令启动时没有利用3306端口,而在my.cnf中是指定3306的。
# lsof -i:1186 # 211.10
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ndb_mgmd 8097 root 8u IPv4 71559 TCP *:mysql-cluster (LISTEN)
ndb_mgmd 8097 root 9u IPv4 71560 TCP localhost.localdomain:53808->localhost.localdomain:mysql-cluster (ESTABLISHED)
ndb_mgmd 8097 root 10u IPv4 71563 TCP localhost.localdomain:mysql-cluster->localhost.localdomain:53808 (ESTABLISHED)
ndb_mgmd 8097 root 11u IPv4 71787 TCP 192.168.211.10:mysql-cluster->192.168.211.10:37721 (ESTABLISHED)
ndb_mgmd 8097 root 12u IPv4 71791 TCP 192.168.211.10:mysql-cluster->192.168.211.10:37722 (ESTABLISHED)
ndb_mgmd 8097 root 13u IPv4 71931 TCP 192.168.211.10:mysql-cluster->192.168.211.9:50749 (ESTABLISHED)
ndb_mgmd 8097 root 14u IPv4 71932 TCP 192.168.211.10:mysql-cluster->192.168.211.9:50750 (ESTABLISHED)
ndb_mgmd 8097 root 15u IPv4 72005 TCP 192.168.211.10:mysql-cluster->192.168.211.9:45770 (ESTABLISHED)
ndb_mgmd 8097 root 16u IPv4 72190 TCP 192.168.211.10:mysql-cluster->192.168.211.10:38109 (ESTABLISHED)
ndbd 8165 root 3u IPv4 71786 TCP 192.168.211.10:37721->192.168.211.10:mysql-cluster (ESTABLISHED)
ndbd 8166 root 3u IPv4 71786 TCP 192.168.211.10:37721->192.168.211.10:mysql-cluster (ESTABLISHED)
ndbd 8166 root 7u IPv4 71790 TCP 192.168.211.10:37722->192.168.211.10:mysql-cluster (ESTABLISHED)
mysqld 8448 mysql 10u IPv4 72189 TCP 192.168.211.10:38109->192.168.211.10:mysql-cluster (ESTABLISHED)
# lsof -i:3307 # 修改过211.10上的my.cnf中的[mysqld] port = 3307
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
mysqld 8448 mysql 17u IPv4 72242 TCP *:opsession-prxy (LISTEN)
# lsof -i:1186 # 211.9
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ndbd 7029 root 3u IPv4 14279 TCP 192.168.211.9:50749->192.168.211.10:mysql-cluster (ESTABLISHED)
ndbd 7030 root 3u IPv4 14279 TCP 192.168.211.9:50749->192.168.211.10:mysql-cluster (ESTABLISHED)
ndbd 7030 root 7u IPv4 14282 TCP 192.168.211.9:50750->192.168.211.10:mysql-cluster (ESTABLISHED)
mysqld 7252 mysql 10u IPv4 14520 TCP 192.168.211.9:45770->192.168.211.10:mysql-cluster (ESTABLISHED)
# lsof -i:3306 # 211.9
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
mysqld 7252 mysql 17u IPv4 14530 TCP *:mysql (LISTEN)
从端口上来看,是连接成功的。但是为什么这样的集群环境中211.10上的SQL节点连接不上?
原因:在集群中,有可能遇到这种情况,有些SQL节点连接不上,比如,在>mgm show命令下面,提示55.10上的SQL节点连接不上,此时,通过检查该节点上的配置文件my.cnf正确,数据库初始化也正确,匿名用户也已经删除,就是找不到原因为什么连接不上,此时,大家可以去55.9上查看该节点的防火墙是否关闭,如果9上的防火墙关闭,那么10上的SQL节点是连接不进去的。而数据节点是可以连接的。