Databases 25 min read

Mastering Chinese Domestic Databases: Deep Dive into DM, TiDB, and openGauss

Explore the technical features, architecture, deployment steps, performance tuning, monitoring, backup, security hardening, and comparative analysis of three leading Chinese databases—DM (Dameng), TiDB, and openGauss—providing a comprehensive guide for operations engineers to implement and manage these systems effectively.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Mastering Chinese Domestic Databases: Deep Dive into DM, TiDB, and openGauss

Introduction

With the rapid development of the digital economy and increasing data security requirements, domestic databases in China are experiencing unprecedented growth opportunities. This article examines three mainstream domestic databases—Dameng (DM), TiDB, and Huawei openGauss—from the perspective of operations engineers, covering technical characteristics, deployment architectures, and operational practices.

Domestic Database Overview

Development Background

Data security requirements : Critical information infrastructure needs autonomous and controllable database systems.

Policy support : The "Xinchuang" policy promotes domestic substitution.

Technical maturity : After years of development, technology is approaching international advanced levels.

Cost advantage : Compared with commercial databases, domestic solutions offer better cost‑performance.

Technical Development Roadmap

Traditional relational databases : e.g., Dameng, openGauss.

Distributed NewSQL databases : e.g., TiDB, OceanBase.

Dameng Database (DM)

Product Overview

Dameng is a high‑performance DBMS developed by Wuhan Dameng Database Co., Ltd., with full independent intellectual property rights.

Core Features:

Full SQL standard compatibility

ACID transaction support

High availability and disaster‑recovery capabilities

Strong security mechanisms

Good Oracle compatibility

Architecture Design

┌─────────────────────────────────────────────────────────────┐
│                     Application Layer                     │
├─────────────────────────────────────────────────────────────┤
│                     SQL Parser                           │
├─────────────────────────────────────────────────────────────┤
│          Query Optimizer | Execution Engine                │
├─────────────────────────────────────────────────────────────┤
│ Transaction Manager | Lock Manager | Cache Manager       │
├─────────────────────────────────────────────────────────────┤
│                     Storage Engine                        │
└─────────────────────────────────────────────────────────────┘

1. Environment Preparation

# OS requirements
# CentOS 7/8, RHEL 7/8, Galaxy Kirin, UnionTech UOS, etc.

# Create Dameng user
useradd -m dmdba
echo "dmdba:dameng123" | chpasswd

# Set system limits
echo "dmdba soft nofile 65536" >> /etc/security/limits.conf
echo "dmdba hard nofile 65536" >> /etc/security/limits.conf
echo "dmdba soft nproc 65536" >> /etc/security/limits.conf
echo "dmdba hard nproc 65536" >> /etc/security/limits.conf

2. Installation and Configuration

# Extract package
 tar -xf dm8_setup_rh7_64_ent_8.1.2.128_20200624.tar

# Run installer
 cd dm8_setup_rh7_64_ent_8.1.2.128_20200624
 ./DMInstall.bin -i

# Create instance
 su - dmdba
 ./dminit path=/dm8/data db_name=DAMENG instance_name=DMSERVER \
        port_num=5236 page_size=16 extent_size=16 \
        case_sensitive=y charset=1 length_in_char=y

3. Start and Connect

# Start DB
 ./dmserver /dm8/data/DAMENG/dm.ini

# Start listener
 ./dmldr /dm8/data/DAMENG/dm.ini

# Connect
 ./disql SYSDBA/SYSDBA@localhost:5236

Operations Management

1. Performance Monitoring

-- View system performance
SELECT * FROM V$SYSSTAT WHERE NAME LIKE '%CPU%';

-- View session info
SELECT * FROM V$SESSION;

-- View lock info
SELECT * FROM V$LOCK;

-- View wait events
SELECT * FROM V$SESSION_WAIT;

2. Backup Strategy

# Full backup
./dmrman
RMAN> backup database to '/backup/full_backup';

# Incremental backup
RMAN> backup incremental level 1 database to '/backup/inc_backup';

# Archive log backup
RMAN> backup archivelog all to '/backup/arch_backup';

3. High Availability Configuration

# Primary‑standby configuration
ALTER SYSTEM SET ARCH_INI=1;
ALTER SYSTEM SET RLOG_SEND_APPLY_MON=64;

# Standby configuration
ALTER SYSTEM SET RLOG_APPLY_MON=64;
ALTER SYSTEM SET RLOG_SEND_APPLY_MON=64;

# Start sync
./dmrman
RMAN> configure archivelog backup destination to 'REMOTE_IP:5237';

TiDB Database

Product Overview

TiDB is an open‑source distributed NewSQL database from PingCAP, supporting hybrid transactional and analytical processing (HTAP).

Core Features:

Horizontal elastic scaling

Strongly consistent distributed transactions

Cloud‑native architecture

MySQL protocol compatibility

Real‑time HTAP capability

Architecture Design

┌─────────────────────────────────────────────────────────────┐
│                     TiDB Server                           │
│        (stateless SQL layer, MySQL compatible)            │
├─────────────────────────────────────────────────────────────┤
│                     PD Server                              │
│          (cluster management, metadata storage)            │
├─────────────────────────────────────────────────────────────┤
│                     TiKV Cluster                           │
│          (distributed KV store, Raft protocol)              │
├─────────────────────────────────────────────────────────────┤
│                     TiFlash                                 │
│          (columnar storage, HTAP)                         │
└─────────────────────────────────────────────────────────────┘

Deployment Practice

1. Cluster Planning

# topology.yaml (excerpt)
global:
  user: "tidb"
  ssh_port: 22
  deploy_dir: "/tidb-deploy"
  data_dir: "/tidb-data"

pd_servers:
  - host: 192.168.1.10
  - host: 192.168.1.11
  - host: 192.168.1.12

tidb_servers:
  - host: 192.168.1.20
  - host: 192.168.1.21

tikv_servers:
  - host: 192.168.1.30
  - host: 192.168.1.31
  - host: 192.168.1.32

tiflash_servers:
  - host: 192.168.1.40
  - host: 192.168.1.41

monitoring_servers:
  - host: 192.168.1.50

grafana_servers:
  - host: 192.168.1.50

2. Deploy with TiUP

# Install TiUP
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
source ~/.bashrc

# Deploy cluster
tiup cluster deploy tidb-prod v6.5.0 topology.yaml --user root -p

# Start cluster
tiup cluster start tidb-prod

# Check status
tiup cluster display tidb-prod

3. Connect and Initialize

# Connect
mysql -h 192.168.1.20 -P 4000 -u root -p

# Create business user
CREATE USER 'app_user'@'%' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON app_db.* TO 'app_user'@'%';
FLUSH PRIVILEGES;

Operations Management

1. Cluster Monitoring

-- View cluster status
SELECT * FROM information_schema.cluster_info;

-- View slow queries
SELECT * FROM information_schema.slow_query 
WHERE time > '2024-01-01 00:00:00' 
ORDER BY query_time DESC LIMIT 10;

2. Performance Optimization

-- Analyze table statistics
ANALYZE TABLE table_name;

-- View execution plan
EXPLAIN ANALYZE SELECT * FROM table_name WHERE condition;

-- Optimizer hint example
SELECT /*+ USE_INDEX(table_name, index_name) */ * FROM table_name;

3. Backup and Restore

# Full backup with BR
tiup br backup full --pd "192.168.1.10:2379" \
  --storage "s3://backup-bucket/tidb-backup" \
  --s3.region "us-west-2"

# Restore
tiup br restore full --pd "192.168.1.10:2379" \
  --storage "s3://backup-bucket/tidb-backup" \
  --s3.region "us-west-2"

4. Scale‑out / Scale‑in

# Scale out TiKV nodes
tiup cluster scale-out tidb-prod tikv-scale-out.yaml

# Scale in a node
tiup cluster scale-in tidb-prod --node 192.168.1.32:20160

Huawei openGauss Database

Product Overview

openGauss is Huawei’s open‑source enterprise‑grade relational database, offering high performance, high availability, and high security.

Core Features:

High‑performance computing engine

Enterprise‑grade high availability

Full‑ciphertext (all‑cipher) database

AI‑driven self‑tuning

High security level

Architecture Design

┌─────────────────────────────────────────────────────────────┐
│                Application Connection Layer                │
├─────────────────────────────────────────────────────────────┤
│                     SQL Execution Engine                    │
├─────────────────────────────────────────────────────────────┤
│          Transaction | Lock | Memory Management             │
├─────────────────────────────────────────────────────────────┤
│                     Storage Engine                         │
├─────────────────────────────────────────────────────────────┤
│                     Shared Storage                         │
└─────────────────────────────────────────────────────────────┘

Deployment Practice

1. Environment Preparation

# OS requirements
# openEuler 20.03 LTS, CentOS 7.6, Galaxy Kirin V10, etc.

# Create user and group
groupadd dbgrp
useradd -g dbgrp -m -s /bin/bash omm
echo "omm:openGauss@123" | chpasswd

# Set system limits
echo "omm soft nofile 1000000" >> /etc/security/limits.conf
echo "omm hard nofile 1000000" >> /etc/security/limits.conf
echo "omm soft nproc unlimited" >> /etc/security/limits.conf
echo "omm hard nproc unlimited" >> /etc/security/limits.conf

2. Single‑Node Installation

# Download package
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/3.1.0/x86/openGauss-3.1.0-CentOS-64bit.tar.bz2

# Extract and install
tar -xf openGauss-3.1.0-CentOS-64bit.tar.bz2
cd openGauss-3.1.0-CentOS-64bit

# Create data directory
mkdir -p /opt/gaussdb/data
chown -R omm:dbgrp /opt/gaussdb

# Initialize database
su - omm
gs_initdb -D /opt/gaussdb/data --nodename=gaussdb \
  -w "openGauss@123" --locale=en_US.UTF-8

3. Cluster Deployment (XML Config Example)

<ROOT>
  <CLUSTER>
    <PARAM name="clusterName" value="gaussCluster"/>
    <PARAM name="nodeNames" value="node1,node2,node3"/>
    <PARAM name="backIp1s" value="192.168.1.10,192.168.1.11,192.168.1.12"/>
    <PARAM name="gaussdbAppPath" value="/opt/gaussdb/app"/>
    <PARAM name="gaussdbLogPath" value="/opt/gaussdb/log"/>
    <PARAM name="gaussdbToolPath" value="/opt/gaussdb/tool"/>
    <PARAM name="corePath" value="/opt/gaussdb/corefile"/>
  </CLUSTER>
  <DEVICELIST>
    <DEVICE sn="node1">
      <PARAM name="name" value="node1"/>
      <PARAM name="azName" value="AZ1"/>
      <PARAM name="azPriority" value="1"/>
      <PARAM name="backIp1" value="192.168.1.10"/>
      <PARAM name="sshIp1" value="192.168.1.10"/>
      <PARAM name="dataNum" value="1"/>
      <PARAM name="dataPortBase" value="26000"/>
      <PARAM name="dataNode1" value="/opt/gaussdb/data/dn1"/>
    </DEVICE>
    ... (node2, node3 similar) ...
  </DEVICELIST>
</ROOT>

Operations Management

1. Cluster Management

# Check status
gs_om -t status --detail

# Start cluster
gs_om -t start

# Stop cluster
gs_om -t stop

# Restart cluster
gs_om -t restart

2. Performance Monitoring

-- Database status
SELECT * FROM pg_stat_database;

-- Slow queries
SELECT * FROM pg_stat_statements 
WHERE mean_time > 1000 
ORDER BY mean_time DESC;

-- Lock information
SELECT * FROM pg_locks;

-- Connection info
SELECT * FROM pg_stat_activity;

3. Backup and Restore

# Physical backup
gs_basebackup -D /backup/basebackup -Ft -Pv -U omm -h localhost -p 26000

# Logical backup
gs_dump -U omm -h localhost -p 26000 -d postgres -f /backup/postgres.sql

# Restore
gs_restore -U omm -h localhost -p 26000 -d postgres /backup/postgres.sql

Comparison of Domestic Databases

The three databases differ in architecture, compatibility, scalability, transaction model, and analytical capabilities. Dameng follows a traditional relational architecture with strong Oracle compatibility and vertical scaling. TiDB adopts a distributed NewSQL design with horizontal scaling, MySQL compatibility, and HTAP features. openGauss uses a shared‑storage architecture, compatible with PostgreSQL, and focuses on high performance, AI‑driven self‑tuning, and strong security.

Operational Best Practices

1. Monitoring System Construction

# Prometheus configuration (simplified)
apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-config
data:
  prometheus.yml: |
    global:
      scrape_interval: 15s
    scrape_configs:
    - job_name: 'dameng'
      static_configs:
      - targets: ['dameng-exporter:9090']
    - job_name: 'tidb'
      static_configs:
      - targets: ['tidb-server:10080']
    - job_name: 'opengauss'
      static_configs:
      - targets: ['opengauss-exporter:9187']

2. Automated Operations

#!/bin/bash
# Database health check script
DB_TYPE=$1
DB_HOST=$2
DB_PORT=$3

case $DB_TYPE in
  "dameng")
    echo exit | /dm8/bin/disql SYSDBA/SYSDBA@$DB_HOST:$DB_PORT
    ;;
  "tidb")
    mysql -h $DB_HOST -P $DB_PORT -u root -e "SELECT 1"
    ;;
  "opengauss")
    gsql -h $DB_HOST -p $DB_PORT -d postgres -c "SELECT 1"
    ;;
esac

if [ $? -eq 0 ]; then
  echo "Database $DB_TYPE is healthy"
  exit 0
else
  echo "Database $DB_TYPE is unhealthy"
  exit 1
fi

3. Disaster‑Recovery Strategy

#!/bin/bash
# Cross‑region backup script
BACKUP_TYPE=$1
SOURCE_DB=$2
TARGET_STORAGE=$3

case $BACKUP_TYPE in
  "dameng")
    /dm8/bin/dmrman <<EOF
backup database to '$TARGET_STORAGE/dameng_backup_$(date +%Y%m%d)';
exit;
EOF
    ;;
  "tidb")
    tiup br backup full --pd "$SOURCE_DB:2379" \
      --storage "$TARGET_STORAGE/tidb_backup_$(date +%Y%m%d)"
    ;;
  "opengauss")
    gs_basebackup -D $TARGET_STORAGE/opengauss_backup_$(date +%Y%m%d) \
      -h $SOURCE_DB -p 26000 -U omm
    ;;
esac

Performance Tuning Guides

1. Dameng Tuning

-- Memory parameters
ALTER SYSTEM SET BUFFER_POOL_SIZE = 2048;  -- 2GB buffer pool
ALTER SYSTEM SET SHARED_POOL_SIZE = 512;   -- 512MB shared pool

-- Log parameters
ALTER SYSTEM SET LOG_BUFFER_SIZE = 64;    -- 64MB log buffer
ALTER SYSTEM SET RLOG_BUF_SIZE = 256;    -- 256MB redo log buffer

-- Concurrency parameters
ALTER SYSTEM SET MAX_SESSIONS = 1000;    -- Max sessions
ALTER SYSTEM SET MAX_PARALLEL_DEGREE = 8; -- Max parallelism

2. TiDB Tuning

-- System variables
SET GLOBAL tidb_mem_quota_query = 34359738368;   -- 32GB query memory limit
SET GLOBAL tidb_distsql_scan_concurrency = 15; -- Scan concurrency
SET GLOBAL tidb_index_serial_scan_concurrency = 1; -- Index scan concurrency

-- Statistics update
SET GLOBAL tidb_auto_analyze_ratio = 0.5;
SET GLOBAL tidb_auto_analyze_start_time = '00:00 +0800';
SET GLOBAL tidb_auto_analyze_end_time = '06:00 +0800';

3. openGauss Tuning

-- Memory parameters
ALTER SYSTEM SET shared_buffers = '2GB';
ALTER SYSTEM SET effective_cache_size = '8GB';
ALTER SYSTEM SET work_mem = '256MB';

-- Concurrency parameters
ALTER SYSTEM SET max_connections = 1000;
ALTER SYSTEM SET max_worker_processes = 16;

-- Checkpoint tuning
ALTER SYSTEM SET checkpoint_completion_target = 0.9;
ALTER SYSTEM SET wal_buffers = '16MB';

Fault Handling Cases

Case 1: Dameng Deadlock Resolution

-- Find deadlock sessions
SELECT s.sess_id, s.sql_text, l.lock_mode, l.lock_type
FROM v$session s, v$lock l
WHERE s.sess_id = l.sess_id AND l.blocked = 1;

-- Terminate deadlock session
CALL sp_close_session(session_id);

Case 2: TiDB Hot Region Issue

-- Identify hot regions
SELECT * FROM information_schema.tidb_hot_regions
WHERE type = 'write'
ORDER BY flow_bytes DESC LIMIT 10;

-- Mitigation: split table or adjust partitioning
ALTER TABLE hot_table SPLIT REGIONS BY (1000000), (2000000), (3000000);

Case 3: openGauss Performance Diagnosis

-- Slow query analysis
SELECT query, mean_time, calls
FROM pg_stat_statements
WHERE mean_time > 1000
ORDER BY mean_time DESC LIMIT 10;

-- Wait event inspection
SELECT wait_event_type, wait_event, count(*)
FROM pg_stat_activity
WHERE state = 'active'
GROUP BY wait_event_type, wait_event;

Security Hardening Recommendations

1. Network Security

# Open required ports
firewall-cmd --permanent --add-port=5236/tcp   # Dameng
firewall-cmd --permanent --add-port=4000/tcp   # TiDB
firewall-cmd --permanent --add-port=26000/tcp  # openGauss
firewall-cmd --reload

2. Access Control

-- Dameng user creation
CREATE USER app_user IDENTIFIED BY 'StrongPassword123!';
GRANT CONNECT, RESOURCE TO app_user;

-- TiDB user creation
CREATE USER 'app_user'@'%' IDENTIFIED BY 'StrongPassword123!';
GRANT SELECT, INSERT, UPDATE, DELETE ON app_db.* TO 'app_user'@'%';

-- openGauss user creation
CREATE USER app_user WITH PASSWORD 'StrongPassword123!';
GRANT CONNECT ON DATABASE app_db TO app_user;

3. Data Encryption

-- Dameng transparent data encryption
ALTER SYSTEM SET ENCRYPT_NAME = 'AES256';
ALTER SYSTEM SET ENCRYPT_KEY = 'MyEncryptionKey123456789012345';

-- openGauss full‑cipher (all‑cipher) setup
CREATE CLIENT MASTER KEY client_key WITH (KEY_STORE = gs_ktool, KEY_PATH = 'key_path');
CREATE COLUMN ENCRYPTION KEY column_key WITH VALUES (CLIENT_MASTER_KEY = client_key);

Development Trends and Recommendations

Technical Development Directions

Cloud‑native transformation : Support containerized deployment and provide cloud service versions.

AI capability enhancement : Intelligent tuning, fault prediction, and automated operations.

Ecosystem improvement : Enrich toolchains and third‑party integrations.

Performance optimization : Continuous improvements for both OLTP and OLAP workloads.

Security strengthening : Support for privacy computing and zero‑trust architectures.

Selection Advice

Dameng is suitable for traditional enterprise applications, government projects, financial core systems, and scenarios requiring strong Oracle compatibility.

TiDB fits internet‑scale applications, big‑data analytics, real‑time data warehouses, and micro‑service architectures that need elastic scaling.

openGauss is ideal for performance‑critical workloads, Huawei ecosystem integrations, and environments with stringent security requirements.

Conclusion

Deep Understanding : Grasp the technical characteristics and appropriate scenarios of each product.

Core Skills : Master deployment, configuration, and operational procedures.

Robust Operations : Build comprehensive monitoring, backup, and emergency response mechanisms.

Stay Updated : Follow technology trends and best‑practice guides.

Community Participation : Contribute operational experience to the community to promote the growth of domestic databases.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

databaseperformance tuning
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.