暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

达梦数据库模拟redo异常强制拉库

惜分飞 2026-06-29
83

“对于达梦数据库的异常恢复,通过模拟事务不提交,并删除掉redo来模仿达梦数据库故障,然后通过达梦官方方式提供方式进行强制拉库的测试”

模拟达梦事务并不提交直接abort掉库
    [dmdba@xifenfei ~]$ disql SYSDBA/Oracle123@localhost:5236
    Server[localhost:5236]:mode is normal, state is open
    login used time : 5.575(ms)
    disql V8
    SQL> 
    SQL> create table t1 as select * from dba_objects;
    executed successfully
    used time85.929(ms). Execute id is 601.
    SQL> select count(1from t1;
    LINEID COUNT(1
    ---------- --------------------
    1 1067
    used time2.106(ms). Execute id is 602.
    SQL> delete from t1;
    affect rows 1067
    used time3.726(ms). Execute id is 603.
    SQL> shutdown abort;
    executed successfully
    used time1.324(ms). Execute id is 0.
    删除掉redo文件
      [dmdba@xifenfei ~]$ cd /dmdb/data/DAMENG/
      [dmdba@xifenfei DAMENG]$ rm -rf DAMENG0
      DAMENG01.log DAMENG02.log 
      [dmdba@xifenfei DAMENG]$ rm -rf DAMENG0*.log
      尝试启动达梦数据库
        [dmdba@xifenfei bin]$ ./dmserver /dmdb/data/DAMENG/dm.ini 
        file dm.key not found, use default license!
        version info: develop
        csek2_vm_t = 9456
        nsql_vm_t = 336
        prjt2_vm_t = 176
        ltid_vm_t = 272
        nins2_vm_t = 1144
        nset2_vm_t = 272
        ndlck_vm_t = 192
        ndel2_vm_t = 760
        slct2_vm_t = 352
        nli2_vm_t = 200
        aagr2_vm_t = 312
        pscn_vm_t = 416
        dist_vm_t = 1000
        DM Database Server 64 V8 03134284458-20251113-301923-20178 startup...
        Normal of FAST
        Normal of DEFAULT
        Normal of RECYCLE
        Normal of KEEP
        Normal of ROLL
        Database mode = 0, oguid = 0
        /dmdb/data/DAMENG/DAMENG01.log not exist, can not startup
        重命名现在的库文件,然后参考当时的创建库的init.log 进行重新初始化一个新库
          [dmdba@xifenfei data]$ cat DAMENG_BAK/dminit_DAMENG_20260315093214.log 
          start init database: V8, 2026-03-15 09:32:14
          init params:
           db path: /dmdb/data/DAMENG
           db name: DAMENG
           auto overwrite: 0
           page size: 8192
           extent size: 16
           char_fix_storage: 0
           sql_log_forbid: 0
           secur_flag: 2
           enable mac: 0
           page checksum policy: 1
           time zone: +08:00
           string case sensitive: 1
           charset: 0
           page check mode: 3
           page check algorithm id: 0
           priv flag: 0
           env label: 0
           rlog enc flag: 0
           use new hash: 1
           blank pad mode: 0
           sec priv mode: 0
           huge with delta: 1
           rlog gen for huge: 1
           pseg_mgr_flag: 0
           auto_adj_para: 0
          [dmdba@xifenfei data]$ dminit PATH=/dmdb/data/DAMENG PAGE_SIZE=8 EXTENT_SIZE=16 
          > LOG_SIZE=256 PORT_NUM=5236 CASE_SENSITIVE=Y CHARSET=0 DB_NAME=DAMENG INSTANCE_NAME=DMSERVER
          > SYSDBA_PWD=Oracle123 SYSAUDITOR_PWD=Oracle123 RLOG_POSTFIX_NAME=log
          initdb V8
          db version: 0x7000d
          file dm.key not found, use default license!
          License will expire on 2026-11-13
          Normal of FAST
          Normal of DEFAULT
          Normal of RECYCLE
          Normal of KEEP
          Normal of ROLL
           log file path: /dmdb/data/DAMENG/DAMENG/DAMENG01.log
           log file path: /dmdb/data/DAMENG/DAMENG/DAMENG02.log
          write to dir [/dmdb/data/DAMENG/DAMENG].
          create dm database success. 2026-06-27 23:40:17
          正常启动这个新库并干净关闭
            [dmdba@xifenfei bin]$ disql SYSDBA/Oracle123@localhost:5236
            Server[localhost:5236]:mode is normal, state is open
            login used time : 5.523(ms)
            disql V8
            SQL> shutdown normal
            2 ;
            executed successfully
            used time1.417(ms). Execute id is 0.
            SQL> 
            直接拷贝redo文件替换尝试启动
              [dmdba@xifenfei bin]$ ./dmserver /dmdb/data/DAMENG/dm.ini 
              file dm.key not found, use default license!
              version info: develop
              csek2_vm_t = 9456
              nsql_vm_t = 336
              prjt2_vm_t = 176
              ltid_vm_t = 272
              nins2_vm_t = 1144
              nset2_vm_t = 272
              ndlck_vm_t = 192
              ndel2_vm_t = 760
              slct2_vm_t = 352
              nli2_vm_t = 200
              aagr2_vm_t = 312
              pscn_vm_t = 416
              dist_vm_t = 1000
              DM Database Server 64 V8 03134284458-20251113-301923-20178 startup...
              Normal of FAST
              Normal of DEFAULT
              Normal of RECYCLE
              Normal of KEEP
              Normal of ROLL
              Database mode = 0, oguid = 0
              License will expire on 2026-11-13
              rfil grp log file error in (db_magic, permanent_magic), 
               log file /dmdb/data/DAMENG/DAMENG01.log is (475644558854749702), 
               dbfile is(926375671763199417).
              Floating point exception
              [dmdba@xifenfei bin]$ 
              提示db_magic和permanent_magic不匹配,使用dmmdf修改新库redo文件
                [dmdba@xifenfei DAMENG]$ dmmdf type=1 FILE=SYSTEM.DBF
                dmmdf V8
                **********************************************************
                1 db_magic=92637567
                2 next_trxid=38064
                3 pemnt_magic=1763199417
                4 enable_page_check=3
                **********************************************************
                Please input which parameter you want to change(1-4), q to quit: Q
                然后在使用dmmdf type=2 修改redo文件的db_magic和pemnt_magic修改之后,设置PSEG_RECV = 0,RLOG_CHECK_SPACE = 2尝试启动库
                  [dmdba@xifenfei bin]$ ./dmserver /dmdb/data/DAMENG/dm.ini
                  file dm.key not found, use default license!
                  version info: develop
                  csek2_vm_t = 9456
                  nsql_vm_t = 336
                  prjt2_vm_t = 176
                  ltid_vm_t = 272
                  nins2_vm_t = 1144
                  nset2_vm_t = 272
                  ndlck_vm_t = 192
                  ndel2_vm_t = 760
                  slct2_vm_t = 352
                  nli2_vm_t = 200
                  aagr2_vm_t = 312
                  pscn_vm_t = 416
                  dist_vm_t = 1000
                  DM Database Server 64 V8 03134284458-20251113-301923-20178 startup...
                  Normal of FAST
                  Normal of DEFAULT
                  Normal of RECYCLE
                  Normal of KEEP
                  Normal of ROLL
                  Database mode = 0, oguid = 0
                  License will expire on 2026-11-13
                  file lsn: 49136
                  ndct db load finished, code:100
                  ndct fill fast pool finished
                  pseg_set_gtv_trxid_low next_trxid in mem:[40065]
                  pseg recv finished
                  nsvr_startup end.
                  uthr_pipe_create, create pipe[read:10write:11]
                  uthr_pipe_create, create pipe[read:12write:13]
                  uthr_pipe_create, create pipe[read:14write:15]
                  uthr_pipe_create, create pipe[read:16write:17]
                  uthr_pipe_create, create pipe[read:18write:19]
                  uthr_pipe_create, create pipe[read:20write:21]
                  uthr_pipe_create, create pipe[read:22write:23]
                  uthr_pipe_create, create pipe[read:24write:25]
                  uthr_pipe_create, create pipe[read:26write:27]
                  uthr_pipe_create, create pipe[read:28write:29]
                  uthr_pipe_create, create pipe[read:30write:31]
                  uthr_pipe_create, create pipe[read:32write:33]
                  uthr_pipe_create, create pipe[read:34write:35]
                  uthr_pipe_create, create pipe[read:36write:37]
                  uthr_pipe_create, create pipe[read:38write:39]
                  uthr_pipe_create, create pipe[read:40write:41]
                  aud sys init success.
                  aud rt sys init success.
                  systables desc init success.
                  ndct_db_load_info finished, code:100.
                  nsvr_process_before_open begin.
                  nsvr_process_before_open success.
                  SYSTEM IS READY.
                  查询拉起来库中的数据
                    [dmdba@xifenfei DAMENG]$ disql SYSDBA/Oracle123@localhost:5236
                    Server[localhost:5236]:mode is normal, state is open
                    login used time : 6.192(ms)
                    disql V8
                    SQL> select count(1from t1;
                    LINEID COUNT(1
                    ---------- --------------------
                    1 1067
                    used time8.976(ms). Execute id is 601.
                    SQL> 

                    文章转载自惜分飞,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                    评论