NDB Operator 版本发布说明
在 Kubernetes 集群中运行的应用程序可以使用这些提取的信息,无需任何额外设置即可访问 MySQL 集群中的数据。
NDB 集群工具(例如 ndb_mgm)可以使用管理节点服务名称作为连接字符串来连接到管理服务器。MySQL 客户端(例如 mysql)可以使用 mysqld-ext
服务和存储在 rootPasswordSecretName
中的密码来连接到 SQL 节点。
首先需要使用 kubectl
登录到 NDB 集群 Pod,如下所示
> kubectl exec -it example-ndb-mysqld-599bcfbd45-hq8ll
现在,您可以使用管理节点服务名称作为连接字符串执行 ndb_mgm 来启动 NDB 管理客户端
> ndb_mgm -c example-ndb-mgmd-ext
在 ndb_mgm 中,您可以发出所有通常的管理客户端命令,如下所示
-- NDB Cluster -- Management Client --
ndb_mgm> SHOW
Connected to Management Server at: example-ndb-mgmd-ext:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=3 @172.17.0.6 (mysql-8.4.0 ndb-8.4.0, Nodegroup: 0, *)
id=4 @172.17.0.7 (mysql-8.4.0 ndb-8.4.0, Nodegroup: 0)
[ndb_mgmd(MGM)] 2 node(s)
id=1 @172.17.0.5 (mysql-8.4.0 ndb-8.4.0)
id=2 @172.17.0.8 (mysql-8.4.0 ndb-8.4.0)
[mysqld(API)] 5 node(s)
id=145 @172.17.0.10 (mysql-8.4.0 ndb-8.4.0)
id=146 @172.17.0.9 (mysql-8.4.0 ndb-8.4.0)
id=147 (not connected, accepting connect from any host)
id=148 (not connected, accepting connect from any host)
id=149 (not connected, accepting connect from any host)
ndb_mgm> ALL STATUS
Node 5: started (mysql-8.4.0 ndb-8.4.0)
Node 6: started (mysql-8.4.0 ndb-8.4.0)
ndb_mgm> EXIT
要使用 mysql 客户端连接到 MySQL,请使用服务名称 example-ndb-mysqld-ext
作为主机名,如下所示
> mysql -h example-ndb-mysqld-ext -uroot -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 500
Server version: 8.4.0-cluster MySQL Cluster Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT * FROM INFORMATION_SCHEMA.ENGINES
> WHERE ENGINE LIKE "ndb%"\G
*************************** 1. row ***************************
ENGINE: ndbinfo
SUPPORT: YES
COMMENT: MySQL Cluster system information storage engine
TRANSACTIONS: NO
XA: NO
SAVEPOINTS: NO
*************************** 2. row ***************************
ENGINE: ndbcluster
SUPPORT: YES
COMMENT: Clustered, fault-tolerant tables
TRANSACTIONS: YES
XA: NO
SAVEPOINTS: NO
2 rows in set (0.00 sec)