欢迎光临
我们一直在努力

DM 启动和关闭数据库:掌握达梦数据库核心运维操作

一、DM 启动和关闭数据库:掌握达梦数据库核心运维操作

1.1 DM 数据库状态概述:理解核心运维基础

DM 数据库在启动和关闭过程中会经历多种状态。了解这些状态对于 DBA 进行有效运维至关重要。主要状态包括:

  • 配置状态 (CONFIG): 读取配置文件 dm.ini,分配内存池。
  • 活动状态 (ACTIVE): 数据库正常提供服务的状态。
  • 挂起状态 (SUSPEND): 数据库暂停写操作,但读操作可以继续。
  • 关闭状态 (SHUTDOWN): 数据库停止运行,释放所有资源。
  • 1.2 DM 数据库启动流程:掌握初始化步骤

    DM 数据库的启动过程是一个严谨的初始化流程,主要包含以下几个步骤:

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

    开始启动

    读取 dm.ini 配置文件

    分配共享内存与信号量

    启动后台工作线程

    加载并回滚重做日志

    打开数据文件与控制文件

    数据库进入 ACTIVE 状态

    1.3 DM 数据库关闭流程:保障数据一致性

    关闭数据库同样需要遵循特定流程,以保证数据的一致性和完整性。其基本流程如下:

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

    发出关闭指令

    数据库进入 SHUTDOWN 状态

    停止接收新的连接请求

    等待当前活动事务完成

    将缓冲区脏数据写入磁盘

    关闭所有后台线程

    释放共享内存与信号量

    二、DM 数据库的启动操作:多种方式详解

    2.1 使用 DM 服务管理器启动:图形化操作指南

    在 Windows 环境下,可以通过 DM 服务管理器以图形化方式启动数据库:

  • 打开 "DM 服务管理器" 工具。
  • 在服务列表中找到 "DamengService" 或对应的数据库实例服务。
  • 右键点击该服务,选择 "启动" 选项。
  • 等待状态变为 "已启动",即表示数据库成功开启。
  • 2.2 使用命令行工具 dmserver 启动:高效运维实践

    在 Linux 环境下,DBA 通常使用命令行启动数据库。这是最基础的启动方式:

  • 切换至 dmdba 用户: su – dmdba
  • 进入 DM 安装目录的 bin 文件夹: cd /opt/dmdbms/bin
  • 执行启动命令并指定 dm.ini 路径: ./dmserver /opt/dmdbms/data/DAMENG/dm.ini
  • 如果需要在后台运行,可以结合 nohup 命令: nohup ./dmserver /opt/dmdbms/data/DAMENG/dm.ini &
  • 2.3 使用 DM 控制台工具启动:交互式管理方法

    DM 控制台 (dmconsole) 提供了交互式的管理界面:

  • 启动 dmconsole 工具: ./dmconsole
  • 在控制台中输入连接命令: conn SYSDBA/SYSDBA
  • 执行启动命令: startup
  • 观察控制台输出,确认数据库状态变更为 ACTIVE。
  • 三、DM 数据库的关闭操作:安全与强制策略

    3.1 使用 DM 服务管理器关闭:直观停止服务

    通过图形化界面关闭数据库非常直观:

  • 打开 "DM 服务管理器"。
  • 找到正在运行的 DM 数据库服务。
  • 右键点击服务,选择 "停止"。
  • 确认服务状态变为 "已停止"。
  • 3.2 使用命令行 disql 关闭:推荐的安全关闭方式

    通过 disql 工具连接数据库并发送关闭指令是最推荐的安全关闭方式:

  • 使用 disql 连接数据库: ./disql SYSDBA/SYSDBA@localhost:5236
  • 执行关闭命令。DM 支持多种关闭模式,常用的是正常关闭: shutdown;
  • 如果需要立即关闭,可以使用: shutdown abort;
  • 等待命令执行完毕,客户端自动断开连接,数据库进程退出。
  • 3.3 强制关闭数据库的注意事项:规避极端风险

    在某些极端情况下 (如系统无响应),可能需要通过系统命令强制关闭数据库:

  • 查找 dmserver 进程: ps -ef | grep dmserver
  • 使用 kill 命令终止进程: kill -9 <pid>
  • 强制关闭注意事项:
    • 此操作可能导致未提交事务丢失或数据文件损坏。
    • 重启时数据库需要进行实例恢复,耗时较长。
    • 仅在正常 shutdown 命令无效时作为最后手段使用。
    赞(0)
    未经允许不得转载:171主机测评 » DM 启动和关闭数据库:掌握达梦数据库核心运维操作
    分享到: 更多 (0)

    评论 抢沙发

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