欢迎光临
我们一直在努力

DM 数据库安装配置与运维实战:构建企业级国产数据库核心能力

一、DM 数据库概述与体系架构

1.1 DM 数据库简介

DM 数据库是达梦数据推出的新一代大型通用关系型数据库管理系统,具有高安全性、高可靠性、高兼容性等特点,广泛应用于政府、金融、能源、电信等关键行业领域。作为国产数据库的标杆产品,DM 数据库全面支持 SQL 标准,提供完备的事务处理能力,并高度兼容 Oracle 语法体系,大大降低了迁移成本。

DM 数据库的核心优势包括:

  • 完全自主知识产权,通过国家信息安全测评中心 EAL4 级安全认证。
  • 支持 SQL-92、SQL-99、SQL-2003 等国际标准。
  • 高度兼容 Oracle 语法,支持 PL/SQL 存储过程。
  • 支持集群部署,提供主备、读写分离、分布式等多种高可用方案。
  • 跨平台支持 Linux、Windows、UNIX 等主流操作系统。
  • 1.2 DM 数据库体系架构

    DM 数据库采用经典的实例与数据库分离架构体系,实例由一组内存结构和后台进程组成,数据库则是磁盘上的物理文件集合。理解这一架构是进行后续运维与调优的基础。

    #publish-mermaid-1786595696157-0{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-1786595696157-0 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-1786595696157-0 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-1786595696157-0 .error-icon{fill:#552222;}#publish-mermaid-1786595696157-0 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-1786595696157-0 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-1786595696157-0 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-1786595696157-0 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-1786595696157-0 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-1786595696157-0 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-1786595696157-0 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-1786595696157-0 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-1786595696157-0 .marker.cross{stroke:#333333;}#publish-mermaid-1786595696157-0 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-1786595696157-0 p{margin:0;}#publish-mermaid-1786595696157-0 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-1786595696157-0 .cluster-label text{fill:#333;}#publish-mermaid-1786595696157-0 .cluster-label span{color:#333;}#publish-mermaid-1786595696157-0 .cluster-label span p{background-color:transparent;}#publish-mermaid-1786595696157-0 .label text,#publish-mermaid-1786595696157-0 span{fill:#333;color:#333;}#publish-mermaid-1786595696157-0 .node rect,#publish-mermaid-1786595696157-0 .node circle,#publish-mermaid-1786595696157-0 .node ellipse,#publish-mermaid-1786595696157-0 .node polygon,#publish-mermaid-1786595696157-0 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1786595696157-0 .rough-node .label text,#publish-mermaid-1786595696157-0 .node .label text,#publish-mermaid-1786595696157-0 .image-shape .label,#publish-mermaid-1786595696157-0 .icon-shape .label{text-anchor:middle;}#publish-mermaid-1786595696157-0 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-1786595696157-0 .rough-node .label,#publish-mermaid-1786595696157-0 .node .label,#publish-mermaid-1786595696157-0 .image-shape .label,#publish-mermaid-1786595696157-0 .icon-shape .label{text-align:center;}#publish-mermaid-1786595696157-0 .node.clickable{cursor:pointer;}#publish-mermaid-1786595696157-0 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-1786595696157-0 .arrowheadPath{fill:#333333;}#publish-mermaid-1786595696157-0 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-1786595696157-0 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-1786595696157-0 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1786595696157-0 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696157-0 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696157-0 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-1786595696157-0 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-1786595696157-0 .cluster text{fill:#333;}#publish-mermaid-1786595696157-0 .cluster span{color:#333;}#publish-mermaid-1786595696157-0 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-1786595696157-0 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-1786595696157-0 rect.text{fill:none;stroke-width:0;}#publish-mermaid-1786595696157-0 .icon-shape,#publish-mermaid-1786595696157-0 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1786595696157-0 .icon-shape p,#publish-mermaid-1786595696157-0 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-1786595696157-0 .icon-shape .label rect,#publish-mermaid-1786595696157-0 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696157-0 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-1786595696157-0 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-1786595696157-0 .node .neo-node{stroke:#9370DB;}#publish-mermaid-1786595696157-0 [data-look=\”neo\”].node rect,#publish-mermaid-1786595696157-0 [data-look=\”neo\”].cluster rect,#publish-mermaid-1786595696157-0 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696157-0 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-1786595696157-0 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1786595696157-0 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696157-0 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-1786595696157-0 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696157-0 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-1786595696157-0 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696157-0 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696157-0 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

    DM 数据库系统

    数据库实例 Instance

    数据库 Database

    内存结构

    后台进程

    共享内存池

    数据缓冲区

    重做日志缓冲区

    SQL 缓冲区

    数据库服务进程

    日志写入进程

    检查点进程

    异步线程

    数据文件 .DBF

    重做日志文件 .LOG

    控制文件 .CTL

    归档日志文件

    参数文件 dm.ini

    从架构图可以看出,DM 数据库的内存结构主要包括以下几部分:

  • 共享内存池: 为系统提供共享内存分配服务,所有线程共享使用。
  • 数据缓冲区: 缓存从磁盘读取的数据页,减少物理 I/O 操作。
  • 重做日志缓冲区: 缓存事务产生的重做日志,提升写入性能。
  • SQL 缓冲区: 缓存已解析的 SQL 执行计划,加速重复查询响应。
  • 1.3 DM 数据库核心特性

    DM 数据库在安全性、高性能与兼容性方面具有突出优势,下表汇总了核心特性:

    | 特性类别 | 具体能力 | 说明 |

    |———|———|——|

    | 安全特性 | 三权分立 | 数据库管理员 DBA、数据库安全员 SSO、数据库审计员 AUDITOR 三权相互制约 |

    | 安全特性 | 强制访问控制 | 基于策略的安全标签机制,实现细粒度数据访问控制 |

    | 高可用 | 数据守护 | 主备集群模式,支持故障自动切换 |

    | 高可用 | 读写分离 | 读操作分流到备库,提升整体并发处理能力 |

    | 兼容性 | Oracle 兼容 | 支持 Oracle 数据类型、SQL 语法、PL/SQL 存储过程 |

    | 分布式 | MPP 架构 | 大规模并行处理,支持海量数据分析 |

    二、DM 数据库安装与部署

    2.1 环境准备

    在正式安装 DM 数据库之前,需要完成必要的系统环境准备工作。以下以 CentOS 7.9 为例进行说明。

    #publish-mermaid-1786595696282-1{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-1786595696282-1 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-1786595696282-1 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-1786595696282-1 .error-icon{fill:#552222;}#publish-mermaid-1786595696282-1 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-1786595696282-1 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-1786595696282-1 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-1786595696282-1 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-1786595696282-1 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-1786595696282-1 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-1786595696282-1 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-1786595696282-1 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-1786595696282-1 .marker.cross{stroke:#333333;}#publish-mermaid-1786595696282-1 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-1786595696282-1 p{margin:0;}#publish-mermaid-1786595696282-1 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-1786595696282-1 .cluster-label text{fill:#333;}#publish-mermaid-1786595696282-1 .cluster-label span{color:#333;}#publish-mermaid-1786595696282-1 .cluster-label span p{background-color:transparent;}#publish-mermaid-1786595696282-1 .label text,#publish-mermaid-1786595696282-1 span{fill:#333;color:#333;}#publish-mermaid-1786595696282-1 .node rect,#publish-mermaid-1786595696282-1 .node circle,#publish-mermaid-1786595696282-1 .node ellipse,#publish-mermaid-1786595696282-1 .node polygon,#publish-mermaid-1786595696282-1 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1786595696282-1 .rough-node .label text,#publish-mermaid-1786595696282-1 .node .label text,#publish-mermaid-1786595696282-1 .image-shape .label,#publish-mermaid-1786595696282-1 .icon-shape .label{text-anchor:middle;}#publish-mermaid-1786595696282-1 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-1786595696282-1 .rough-node .label,#publish-mermaid-1786595696282-1 .node .label,#publish-mermaid-1786595696282-1 .image-shape .label,#publish-mermaid-1786595696282-1 .icon-shape .label{text-align:center;}#publish-mermaid-1786595696282-1 .node.clickable{cursor:pointer;}#publish-mermaid-1786595696282-1 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-1786595696282-1 .arrowheadPath{fill:#333333;}#publish-mermaid-1786595696282-1 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-1786595696282-1 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-1786595696282-1 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1786595696282-1 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696282-1 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696282-1 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-1786595696282-1 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-1786595696282-1 .cluster text{fill:#333;}#publish-mermaid-1786595696282-1 .cluster span{color:#333;}#publish-mermaid-1786595696282-1 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-1786595696282-1 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-1786595696282-1 rect.text{fill:none;stroke-width:0;}#publish-mermaid-1786595696282-1 .icon-shape,#publish-mermaid-1786595696282-1 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1786595696282-1 .icon-shape p,#publish-mermaid-1786595696282-1 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-1786595696282-1 .icon-shape .label rect,#publish-mermaid-1786595696282-1 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696282-1 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-1786595696282-1 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-1786595696282-1 .node .neo-node{stroke:#9370DB;}#publish-mermaid-1786595696282-1 [data-look=\”neo\”].node rect,#publish-mermaid-1786595696282-1 [data-look=\”neo\”].cluster rect,#publish-mermaid-1786595696282-1 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696282-1 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-1786595696282-1 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1786595696282-1 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696282-1 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-1786595696282-1 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696282-1 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-1786595696282-1 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696282-1 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696282-1 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

    环境准备流程

    操作系统检查

    硬件资源评估

    创建 dmdba 用户

    调整系统参数

    配置用户限制

    创建安装目录

    挂载安装介质

    1. 操作系统检查

    确认操作系统版本与内核信息:

    # 查看操作系统版本
    cat /etc/redhat-release
    # 查看内核版本
    uname -r
    # 查看 CPU 架构
    uname -m

    2. 硬件资源评估

    | 资源类型 | 最低要求 | 推荐配置 |

    |———|———|———|

    | CPU | 2 核 | 8 核及以上 |

    | 内存 | 2 GB | 16 GB 及以上 |

    | 磁盘空间 | 10 GB | 100 GB 及以上 |

    | 交换分区 | 与内存等大 | 内存的 1.5 倍 |

    3. 创建 dmdba 用户与用户组

    # 创建 dinstall 用户组
    groupadd -g 12349 dinstall
    # 创建 dmdba 用户并加入 dinstall 组
    useradd -u 12345 -g dinstall -m -d /home/dmdba -s /bin/bash dmdba
    # 设置用户密码
    passwd dmdba

    4. 调整系统内核参数

    编辑 /etc/sysctl.conf 文件,添加以下配置:

    vi /etc/sysctl.conf

    添加如下内容:

    fs.file-max = 6815744
    fs.aio-max-nr = 1048576
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default = 262144
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048576
    vm.swappiness = 10

    使配置生效:

    sysctl -p

    5. 配置用户资源限制

    编辑 /etc/security/limits.conf 文件:

    vi /etc/security/limits.conf

    添加以下内容:

    dmdba soft nofile 65536
    dmdba hard nofile 65536
    dmdba soft nproc 65536
    dmdba hard nproc 65536
    dmdba soft core unlimited
    dmdba hard core unlimited

    6. 创建安装目录并授权

    # 创建安装目录
    mkdir -p /dm/dmdbms
    # 创建数据目录
    mkdir -p /dm/dmdata
    # 创建归档目录
    mkdir -p /dm/dmarch
    # 创建备份目录
    mkdir -p /dm/dmbak
    # 授权
    chown -R dmdba:dinstall /dm
    chmod -R 775 /dm

    2.2 安装步骤详解

    1. 挂载安装镜像

    # 切换到 root 用户
    su – root
    # 创建挂载点
    mkdir -p /mnt/dm
    # 挂载 ISO 安装镜像
    mount -o loop dm8_install.iso /mnt/dm

    2. 执行安装程序

    # 切换到 dmdba 用户
    su – dmdba
    # 进入挂载目录
    cd /mnt/dm
    # 执行安装程序(命令行方式)
    ./DMInstall.bin -i

    安装过程中按照提示输入选项:

    是否输入 Key 文件路径? (Y/y:是 N/n:否)[Y/y]:n
    是否设置时区? (Y/y:是 N/n:否)[Y/y]:y
    设置时区[21]:21
    安装类型:
    1 典型安装
    2 服务器
    3 客户端
    4 自定义
    请选择安装类型的数字序号[1 典型安装]:1
    请选择安装目录[/home/dmdba/dmdbms]:/dm/dmdbms

    3. 执行 root 脚本

    安装完成后,根据提示以 root 用户执行脚本:

    su – root
    /dm/dmdbms/script/root/root_installer.sh

    安装目录结构如下:

    /dm/dmdbms/
    ├── bin/ # 可执行文件目录
    ├── data/ # 默认数据目录
    ├── doc/ # 文档目录
    ├── drivers/ # 驱动程序目录
    ├── include/ # 头文件目录
    ├── jar/ # Java 工具包目录
    ├── log/ # 日志目录
    ├── script/ # 脚本目录
    └── license/ # 许可证目录

    2.3 初始化数据库实例

    1. 使用 dminit 工具初始化实例

    # 切换到 dmdba 用户
    su – dmdba
    # 进入 bin 目录
    cd /dm/dmdbms/bin
    # 执行 dminit 初始化实例
    ./dminit PATH=/dm/dmdata DB_NAME=DAMENG INSTANCE_NAME=DMSVR PORT_NUM=5236 SYSDBA_PWD=Dameng@123 CHARSET=1 LENGTH_IN_CHAR=1 CASE_SENSITIVE=1

    关键参数说明:

    | 参数名 | 说明 | 示例值 |

    |——–|——|——–|

    | PATH | 数据文件存放路径 | /dm/dmdata |

    | DB_NAME | 数据库名称 | DAMENG |

    | INSTANCE_NAME | 实例名称 | DMSVR |

    | PORT_NUM | 端口号 | 5236 |

    | SYSDBA_PWD | 系统管理员密码 | Dameng@123 |

    | CHARSET | 字符集(1 表示 UTF-8) | 1 |

    | LENGTH_IN_CHAR | 是否以字符为单位计算长度 | 1 |

    | CASE_SENSITIVE | 大小写敏感(1 表示敏感) | 1 |

    2. 注册数据库服务

    # 以 root 用户执行
    su – root
    # 进入脚本目录
    cd /dm/dmdbms/script/root
    # 注册服务
    ./dm_service_installer.sh -t dmserver -p DMSVR -dm_ini /dm/dmdata/DAMENG/dm.ini

    3. 启动与验证

    # 启动数据库服务
    systemctl start DmServiceDMSVR
    # 查看服务状态
    systemctl status DmServiceDMSVR
    # 设置开机自启
    systemctl enable DmServiceDMSVR

    初始化实例的完整流程如下图所示:

    #publish-mermaid-1786595696351-2{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-1786595696351-2 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-1786595696351-2 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-1786595696351-2 .error-icon{fill:#552222;}#publish-mermaid-1786595696351-2 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-1786595696351-2 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-1786595696351-2 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-1786595696351-2 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-1786595696351-2 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-1786595696351-2 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-1786595696351-2 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-1786595696351-2 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-1786595696351-2 .marker.cross{stroke:#333333;}#publish-mermaid-1786595696351-2 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-1786595696351-2 p{margin:0;}#publish-mermaid-1786595696351-2 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-1786595696351-2 .cluster-label text{fill:#333;}#publish-mermaid-1786595696351-2 .cluster-label span{color:#333;}#publish-mermaid-1786595696351-2 .cluster-label span p{background-color:transparent;}#publish-mermaid-1786595696351-2 .label text,#publish-mermaid-1786595696351-2 span{fill:#333;color:#333;}#publish-mermaid-1786595696351-2 .node rect,#publish-mermaid-1786595696351-2 .node circle,#publish-mermaid-1786595696351-2 .node ellipse,#publish-mermaid-1786595696351-2 .node polygon,#publish-mermaid-1786595696351-2 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1786595696351-2 .rough-node .label text,#publish-mermaid-1786595696351-2 .node .label text,#publish-mermaid-1786595696351-2 .image-shape .label,#publish-mermaid-1786595696351-2 .icon-shape .label{text-anchor:middle;}#publish-mermaid-1786595696351-2 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-1786595696351-2 .rough-node .label,#publish-mermaid-1786595696351-2 .node .label,#publish-mermaid-1786595696351-2 .image-shape .label,#publish-mermaid-1786595696351-2 .icon-shape .label{text-align:center;}#publish-mermaid-1786595696351-2 .node.clickable{cursor:pointer;}#publish-mermaid-1786595696351-2 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-1786595696351-2 .arrowheadPath{fill:#333333;}#publish-mermaid-1786595696351-2 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-1786595696351-2 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-1786595696351-2 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1786595696351-2 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696351-2 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696351-2 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-1786595696351-2 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-1786595696351-2 .cluster text{fill:#333;}#publish-mermaid-1786595696351-2 .cluster span{color:#333;}#publish-mermaid-1786595696351-2 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-1786595696351-2 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-1786595696351-2 rect.text{fill:none;stroke-width:0;}#publish-mermaid-1786595696351-2 .icon-shape,#publish-mermaid-1786595696351-2 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1786595696351-2 .icon-shape p,#publish-mermaid-1786595696351-2 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-1786595696351-2 .icon-shape .label rect,#publish-mermaid-1786595696351-2 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696351-2 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-1786595696351-2 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-1786595696351-2 .node .neo-node{stroke:#9370DB;}#publish-mermaid-1786595696351-2 [data-look=\”neo\”].node rect,#publish-mermaid-1786595696351-2 [data-look=\”neo\”].cluster rect,#publish-mermaid-1786595696351-2 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696351-2 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-1786595696351-2 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1786595696351-2 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696351-2 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-1786595696351-2 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696351-2 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-1786595696351-2 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696351-2 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696351-2 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}是否

    开始初始化实例

    运行 dminit 工具

    设置数据库名称与路径

    设置端口与密码

    设置字符集与大小写敏感

    生成控制文件与数据文件

    注册系统服务

    启动数据库实例

    服务是否正常启动

    初始化完成

    检查日志排查问题

    三、DM 数据库日常运维与性能优化

    3.1 服务管理与连接操作

    1. 服务管理命令

    # 启动服务
    systemctl start DmServiceDMSVR
    # 停止服务
    systemctl stop DmServiceDMSVR
    # 重启服务
    systemctl restart DmServiceDMSVR
    # 查看服务状态
    systemctl status DmServiceDMSVR

    2. 使用 disql 工具连接数据库

    # 本地连接
    cd /dm/dmdbms/bin
    ./disql SYSDBA/Dameng@123@localhost:5236

    连接成功后,可以执行以下 SQL 验证:

    — 查看数据库版本
    SELECT * FROM v$version;
    — 查看数据库名称
    SELECT name FROM v$database;
    — 查看实例状态
    SELECT status$ FROM v$instance;

    3. 表空间与用户管理

    创建自定义表空间:

    — 创建表空间
    CREATE TABLESPACE TBS_APP DATAFILE '/dm/dmdata/DAMENG/TBS_APP01.DBF' SIZE 128 AUTOEXTEND ON NEXT 10 MAXSIZE 10240;
    — 创建用户
    CREATE USER APP_USER IDENTIFIED BY "App@123456" DEFAULT TABLESPACE TBS_APP;
    — 授予角色权限
    GRANT RESOURCE, PUBLIC TO APP_USER;

    3.2 常用 SQL 操作与对象管理

    1. 表的创建与管理

    — 切换到业务用户
    SET SCHEMA APP_USER;
    — 创建部门表
    CREATE TABLE dept (
    dept_id INT PRIMARY KEY,
    dept_name VARCHAR(50) NOT NULL,
    location VARCHAR(100),
    create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    );
    — 创建员工表
    CREATE TABLE emp (
    emp_id INT PRIMARY KEY,
    emp_name VARCHAR(50) NOT NULL,
    gender CHAR(1) CHECK (gender IN ('M','F')),
    salary DECIMAL(10,2) DEFAULT 0,
    dept_id INT,
    hire_date DATE DEFAULT CURRENT_DATE,
    CONSTRAINT fk_emp_dept FOREIGN KEY (dept_id) REFERENCES dept(dept_id)
    );
    — 创建索引
    CREATE INDEX idx_emp_name ON emp(emp_name);
    CREATE INDEX idx_emp_dept ON emp(dept_id);

    2. 数据增删改查

    — 插入部门数据
    INSERT INTO dept(dept_id, dept_name, location) VALUES(10, '研发部', '北京');
    INSERT INTO dept(dept_id, dept_name, location) VALUES(20, '市场部', '上海');
    INSERT INTO dept(dept_id, dept_name, location) VALUES(30, '财务部', '广州');
    — 插入员工数据
    INSERT INTO emp(emp_id, emp_name, gender, salary, dept_id) VALUES(1001, '张三', 'M', 15000.00, 10);
    INSERT INTO emp(emp_id, emp_name, gender, salary, dept_id) VALUES(1002, '李四', 'F', 12000.00, 20);
    INSERT INTO emp(emp_id, emp_name, gender, salary, dept_id) VALUES(1003, '王五', 'M', 18000.00, 10);
    — 提交事务
    COMMIT;
    — 查询各部门平均薪资
    SELECT d.dept_name, COUNT(e.emp_id) AS emp_count, AVG(e.salary) AS avg_salary
    FROM dept d
    LEFT JOIN emp e ON d.dept_id = e.dept_id
    GROUP BY d.dept_name
    ORDER BY avg_salary DESC;

    3. 存储过程与函数

    — 创建存储过程: 根据部门 ID 统计人数
    CREATE OR REPLACE PROCEDURE sp_dept_stat(
    p_dept_id IN INT,
    p_count OUT INT,
    p_total OUT DECIMAL
    )
    AS
    BEGIN
    SELECT COUNT(*), NVL(SUM(salary), 0)
    INTO p_count, p_total
    FROM emp
    WHERE dept_id = p_dept_id;
    PRINT '部门ID: ' || p_dept_id || ', 人数: ' || p_count || ', 薪资总计: ' || p_total;
    END;
    /
    — 调用存储过程
    DECLARE
    v_count INT;
    v_total DECIMAL;
    BEGIN
    sp_dept_stat(10, v_count, v_total);
    END;
    /

    3.3 性能优化与监控诊断

    1. 参数调优

    核心参数配置位于 dm.ini 文件中,以下为常用调优参数:

    | 参数名 | 说明 | 推荐值 |

    |——–|——|——–|

    | MEMORY_POOL | 共享内存池大小(MB) | 1000 |

    | BUFFER | 数据缓冲区大小(MB) | 物理内存的 60% |

    | MAX_BUFFER | 最大缓冲区大小(MB) | 物理内存的 70% |

    | SORT_BUF_SIZE | 排序缓存大小(MB) | 50 |

    | HJ_BUF_SIZE | HASH 连接缓存(MB) | 50 |

    | CACHE_POOL_SIZE | SQL 缓存池大小(MB) | 100 |

    | WORKER_THREADS | 工作线程数 | CPU 核数 |

    | IO_THR_GROUPS | IO 线程组数 | CPU 核数 |

    修改示例:

    # 编辑 dm.ini 配置文件
    vi /dm/dmdata/DAMENG/dm.ini
    MEMORY_POOL = 1000
    BUFFER = 8192
    MAX_BUFFER = 10240
    SORT_BUF_SIZE = 50
    HJ_BUF_SIZE = 50
    CACHE_POOL_SIZE = 100
    WORKER_THREADS = 8
    IO_THR_GROUPS = 8

    修改完成后重启数据库服务使配置生效:

    systemctl restart DmServiceDMSVR

    2. 执行计划分析

    使用 EXPLAIN 查看执行计划:

    — 查看查询执行计划
    EXPLAIN
    SELECT e.emp_name, d.dept_name, e.salary
    FROM emp e
    JOIN dept d ON e.dept_id = d.dept_id
    WHERE e.salary > 10000
    ORDER BY e.salary DESC;

    3. 性能监控视图

    DM 数据库提供丰富的动态性能视图,便于实时监控:

    — 查看当前活动会话
    SELECT sess_id, sql_text, state, create_time
    FROM v$sessions
    WHERE state = 'ACTIVE';
    — 查看等待事件
    SELECT name, class_id, waits, time_waited
    FROM v$waitclass
    ORDER BY time_waited DESC;
    — 查看 SQL 执行统计
    SELECT sql_text, exec_num, elapsed_time, logic_read
    FROM v$sqlstat
    ORDER BY elapsed_time DESC
    LIMIT 10;

    性能优化整体流程如下图所示:

    #publish-mermaid-1786595696437-3{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-1786595696437-3 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-1786595696437-3 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-1786595696437-3 .error-icon{fill:#552222;}#publish-mermaid-1786595696437-3 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-1786595696437-3 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-1786595696437-3 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-1786595696437-3 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-1786595696437-3 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-1786595696437-3 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-1786595696437-3 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-1786595696437-3 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-1786595696437-3 .marker.cross{stroke:#333333;}#publish-mermaid-1786595696437-3 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-1786595696437-3 p{margin:0;}#publish-mermaid-1786595696437-3 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-1786595696437-3 .cluster-label text{fill:#333;}#publish-mermaid-1786595696437-3 .cluster-label span{color:#333;}#publish-mermaid-1786595696437-3 .cluster-label span p{background-color:transparent;}#publish-mermaid-1786595696437-3 .label text,#publish-mermaid-1786595696437-3 span{fill:#333;color:#333;}#publish-mermaid-1786595696437-3 .node rect,#publish-mermaid-1786595696437-3 .node circle,#publish-mermaid-1786595696437-3 .node ellipse,#publish-mermaid-1786595696437-3 .node polygon,#publish-mermaid-1786595696437-3 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1786595696437-3 .rough-node .label text,#publish-mermaid-1786595696437-3 .node .label text,#publish-mermaid-1786595696437-3 .image-shape .label,#publish-mermaid-1786595696437-3 .icon-shape .label{text-anchor:middle;}#publish-mermaid-1786595696437-3 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-1786595696437-3 .rough-node .label,#publish-mermaid-1786595696437-3 .node .label,#publish-mermaid-1786595696437-3 .image-shape .label,#publish-mermaid-1786595696437-3 .icon-shape .label{text-align:center;}#publish-mermaid-1786595696437-3 .node.clickable{cursor:pointer;}#publish-mermaid-1786595696437-3 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-1786595696437-3 .arrowheadPath{fill:#333333;}#publish-mermaid-1786595696437-3 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-1786595696437-3 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-1786595696437-3 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1786595696437-3 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696437-3 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696437-3 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-1786595696437-3 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-1786595696437-3 .cluster text{fill:#333;}#publish-mermaid-1786595696437-3 .cluster span{color:#333;}#publish-mermaid-1786595696437-3 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-1786595696437-3 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-1786595696437-3 rect.text{fill:none;stroke-width:0;}#publish-mermaid-1786595696437-3 .icon-shape,#publish-mermaid-1786595696437-3 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1786595696437-3 .icon-shape p,#publish-mermaid-1786595696437-3 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-1786595696437-3 .icon-shape .label rect,#publish-mermaid-1786595696437-3 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1786595696437-3 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-1786595696437-3 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-1786595696437-3 .node .neo-node{stroke:#9370DB;}#publish-mermaid-1786595696437-3 [data-look=\”neo\”].node rect,#publish-mermaid-1786595696437-3 [data-look=\”neo\”].cluster rect,#publish-mermaid-1786595696437-3 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696437-3 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-1786595696437-3 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1786595696437-3 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696437-3 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-1786595696437-3 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696437-3 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-1786595696437-3 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696437-3 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1786595696437-3 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}CPU 瓶颈内存瓶颈I/O 瓶颈锁等待是否

    性能优化流程

    基线采集

    识别瓶颈

    瓶颈类型判断

    优化 SQL 与索引

    调整缓冲区参数

    优化存储与表空间

    分析并发与事务

    实施优化方案

    验证优化效果

    是否达标

    优化完成

    通过以上三个章节的系统讲解,我们从 DM 数据库的架构原理出发,完整梳理了安装部署、实例初始化、日常运维以及性能优化的全流程操作。DM 数据库作为国产数据库的代表产品,在兼容性、安全性和稳定性方面表现优异,是企业信创改造与技术国产化替代的优选方案。在实际项目中,建议结合业务场景合理配置参数,并建立完善的备份恢复与监控告警机制,确保数据库系统持续稳定运行。

    赞(0)
    未经允许不得转载:171主机测评 » DM 数据库安装配置与运维实战:构建企业级国产数据库核心能力
    分享到: 更多 (0)

    评论 抢沙发

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址