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)