Implementation:4paradigm OpenMLDB Nameserver Startup
| Knowledge Sources | |
|---|---|
| Domains | Deployment, Distributed_Systems |
| Last Updated | 2026-10-12 12:00 GMT |
Overview
Configuration pattern for starting OpenMLDB nameserver processes using gflags command-line flags.
Description
The Nameserver is the metadata management and coordination component of OpenMLDB. It manages table schemas, partition assignments, replica distribution, leader election, and failover. The nameserver discovers tablet servers through ZooKeeper and orchestrates cluster operations. It is started by invoking the openmldb binary with --role=nameserver and connecting to the same ZooKeeper cluster as the tablets. In standalone mode, a single nameserver connects directly to a single tablet via the --tablet flag without ZooKeeper.
Usage
Use this pattern when starting nameserver servers as part of a cluster deployment. For HA, run multiple nameservers (typically 3) — one will be elected leader via ZooKeeper. For standalone mode, a single nameserver with --tablet flag suffices.
Code Reference
Source Location
- Repository: OpenMLDB
- File: onebox/start_onebox.sh (start_cluster at L107-129, start_standalone at L136-160), src/flags.cc (flag definitions at L25-39)
Signature
# Cluster mode
openmldb \
--role=nameserver \
--endpoint=<ip:port> \
--zk_cluster=<zk_endpoints> \
--zk_root_path=<zk_path> \
--tablet_offline_check_interval=<ms> \
--tablet_heartbeat_timeout=<ms> \
--openmldb_log_dir=<log_dir>
# Standalone mode (no ZooKeeper needed)
openmldb \
--role=nameserver \
--endpoint=<ip:port> \
--tablet=<tablet_endpoint> \
--tablet_offline_check_interval=<ms> \
--tablet_heartbeat_timeout=<ms> \
--openmldb_log_dir=<log_dir>
Key gflags (from src/flags.cc)
DEFINE_string(role, "", "Set the openmldb role: tablet | nameserver | ..."); // L25-26
DEFINE_string(endpoint, "", "ip:port, config the ip and port that openmldb serves for"); // L19
DEFINE_string(zk_cluster, "", "config the zookeeper cluster"); // L34
DEFINE_string(zk_root_path, "/openmldb", "config the root path of zookeeper"); // L35
DEFINE_string(tablet, "", "config the endpoint of tablet"); // L38
DEFINE_uint32(tablet_heartbeat_timeout, 5*60*1000, "heartbeat of tablet offline (ms)"); // L32
DEFINE_uint32(tablet_offline_check_interval, 1000, "check interval of tablet offline (ms)"); // L33
DEFINE_bool(auto_failover, false, "enable or disable auto failover"); // L62
DEFINE_uint32(partition_num, 8, "config the default partition_num"); // L64
DEFINE_uint32(replica_num, 3, "config the default replica_num"); // L65
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| endpoint | string | Yes | ip:port for nameserver service (e.g. 127.0.0.1:9622)
|
| zk_cluster | string | Yes (cluster) | ZooKeeper cluster address (not needed in standalone) |
| zk_root_path | string | Yes (cluster) | ZK root path |
| tablet | string | Yes (standalone) | Tablet endpoint for standalone mode |
| tablet_heartbeat_timeout | uint32 | No | Heartbeat timeout in ms (onebox uses 1) |
| tablet_offline_check_interval | int32 | No | Check interval in ms (onebox uses 1) |
| auto_failover | bool | No | Enable auto-failover (default: false) |
| partition_num | uint32 | No | Default partitions per table (default: 8) |
| replica_num | uint32 | No | Default replicas per partition (default: 3) |
Outputs
| Name | Type | Description |
|---|---|---|
| Running nameserver process | process | Nameserver registered in ZooKeeper (cluster) or connected to tablet (standalone) |
| Cluster metadata | ZooKeeper nodes | Table/partition metadata stored under zk_root_path |
Usage Examples
Onebox Cluster Nameserver
# Start a nameserver for onebox cluster (from start_onebox.sh)
OPENMLDB_BIN=build/bin/openmldb
$OPENMLDB_BIN \
--role=nameserver \
--endpoint=127.0.0.1:9622 \
--zk_cluster=127.0.0.1:6181 \
--zk_root_path=/onebox \
--tablet_offline_check_interval=1 \
--tablet_heartbeat_timeout=1 \
--enable_status_service=true \
--openmldb_log_dir="/work/onebox/logs/ns0"
Standalone Mode
# Start nameserver in standalone mode (no ZooKeeper)
$OPENMLDB_BIN \
--endpoint=127.0.0.1:6527 \
--role=nameserver \
--tablet=127.0.0.1:9921 \
--tablet_offline_check_interval=1 \
--tablet_heartbeat_timeout=1 \
--openmldb_log_dir="/work/logs/standalone-ns"
Related Pages
Implements Principle
- Principle:4paradigm_OpenMLDB_Server_Role_Configuration
- Principle:4paradigm_OpenMLDB_Distributed_Coordination