Implementation:4paradigm OpenMLDB CLI Client
| Knowledge Sources | |
|---|---|
| Domains | Deployment, Database |
| Last Updated | 2026-10-12 12:00 GMT |
Overview
Command-line interface client for verifying OpenMLDB cluster health and executing administrative commands via the openmldb binary.
Description
The CLI Client is built into the openmldb binary itself. By setting --role=ns_client or --role=client, the binary runs in client mode and connects to the cluster through ZooKeeper to issue administrative commands. The --cmd flag specifies the command to execute (e.g. showns, showtablet, showtable). The --role=sql_client mode executes SQL statements against the cluster. The --interactive=false flag enables non-interactive (scriptable) mode.
Usage
Use this client to verify cluster health after deployment, execute SQL scripts, or perform administrative queries. It is the primary tool for cluster verification and SQL script execution in demo workflows.
Code Reference
Source Location
- Repository: OpenMLDB
- File: src/flags.cc (role definitions at L25-27, cmd at L27)
Signature
# Nameserver client (administrative commands)
openmldb --role=ns_client \
--zk_cluster=<zk> --zk_root_path=<path> \
--interactive=false \
--cmd=<command>
# Tablet client (tablet-level commands)
openmldb --role=client \
--endpoint=<tablet_endpoint> \
--interactive=false \
--cmd=<command>
# SQL client (SQL statement execution)
openmldb --role=sql_client \
--zk_cluster=<zk> --zk_root_path=<path> \
--interactive=false \
--cmd=<sql_statement>
Key gflags (from src/flags.cc)
DEFINE_string(role, "", "tablet | nameserver | client | ns_client | sql_client | apiserver"); // L25-26
DEFINE_string(cmd, "", "the command str, DO NOT add multi sqls"); // L27
DEFINE_string(zk_cluster, "", "config the zookeeper cluster"); // L34
DEFINE_string(zk_root_path, "/openmldb", "config the root path of zookeeper"); // L35
DEFINE_bool(enable_distsql, false, "enable or disable distribute sql"); // L78
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| role | string | Yes | ns_client, client, or sql_client
|
| cmd | string | Yes | Command to execute (e.g. showns, showtablet, SQL statement)
|
| zk_cluster | string | Yes (ns_client/sql_client) | ZooKeeper cluster address |
| zk_root_path | string | Yes (ns_client/sql_client) | ZK root path |
| endpoint | string | Yes (client) | Tablet endpoint for tablet-level commands |
| interactive | bool | No | Set to false for non-interactive/scriptable mode
|
| enable_distsql | bool | No | Enable distributed SQL for sql_client |
Outputs
| Name | Type | Description |
|---|---|---|
| stdout | text | Command output (table-format text for showns/showtablet, SQL result for sql_client) |
| exit code | int | 0 on success, non-zero on failure |
Usage Examples
Verify Cluster Health
# Show nameservers
openmldb --role=ns_client \
--zk_cluster=127.0.0.1:6181 \
--zk_root_path=/onebox \
--interactive=false \
--cmd=showns
# Show tablets
openmldb --role=ns_client \
--zk_cluster=127.0.0.1:6181 \
--zk_root_path=/onebox \
--interactive=false \
--cmd=showtablet
Execute SQL Script
# Execute SQL script via sql_client
openmldb --role=sql_client \
--zk_cluster=127.0.0.1:6181 \
--zk_root_path=/openmldb \
--interactive=false \
< cluster_quickstart.sql
# Execute a single SQL command
openmldb --role=sql_client \
--zk_cluster=127.0.0.1:6181 \
--zk_root_path=/openmldb \
--interactive=false \
--cmd="SHOW DEPLOYMENT demo"
Related Pages
Implements Principle
- Principle:4paradigm_OpenMLDB_Server_Role_Configuration
- Principle:4paradigm_OpenMLDB_Cluster_Health_Verification
- Principle:4paradigm_OpenMLDB_SQL_Feature_Engineering
- Principle:4paradigm_OpenMLDB_SQL_Online_Deployment