达梦数据库的Redo log跟Oracle有些不同,虽然名称上差不多,作用也类似,但是还是有差差别。
在达梦数据库中有日志包的概念,主从同步时是以日志包的形式来进行;其中达梦也有lsn,这跟检查点有关(oracle中为scn)。
SQL> select PARA_NAME,PARA_VALUE,FILE_VALUE,DESCRIPTION from v$dm_ini where PARA_NAME like '%CKPT%';
LINEID PARA_NAME PARA_VALUE FILE_VALUE DESCRIPTION
---------- ---------------- ---------- ---------- ------------------------------------------------------------------
1 CKPT_RLOG_SIZE 0 0 Checkpoint Rlog Size, 0: Ingore; else: Generate With Redo Log Size
2 CKPT_DIRTY_PAGES 0 0 Checkpoint Dirty Pages, 0: Ingore; else: Generate With Dirty Pages
3 CKPT_INTERVAL 180 180 Checkpoint Interval In Seconds
4 CKPT_FLUSH_RATE 50.000000 50.000000 Checkpoint Flush Rate(0.0-100.0)
5 CKPT_FLUSH_PAGES 1000 1000 Minimum number of flushed pages for checkpoints
6 CKPT_WAIT_PAGES 128 128 Maximum number of pages flushed for checkpoints
6 rows got
SQL> select CKPT_LSN,FILE_LSN,FLUSH_LSN,CUR_LSN,DB_MAGIC,FLUSH_PAGES from v$rlog;
CKPT_LSN FILE_LSN FLUSH_LSN CUR_LSN DB_MAGIC FLUSH_PAGES
-------------------- -------------------- -------------------- -------------------- -------------------- -----------
85678411 85678411 85678411 85678411 148545590 0
used time: 0.255(ms). Execute id is 23.
SQL> select checkpoint(100);
CHECKPOINT(100)
---------------
0
used time: 2.677(ms). Execute id is 24.
SQL> select CKPT_LSN,FILE_LSN,FLUSH_LSN,CUR_LSN,DB_MAGIC,FLUSH_PAGES from v$rlog;
CKPT_LSN FILE_LSN FLUSH_LSN CUR_LSN DB_MAGIC FLUSH_PAGES
-------------------- -------------------- -------------------- -------------------- -------------------- -----------
85678411 85678411 85678411 85678411 148545590 0
used time: 0.208(ms). Execute id is 25.
SQL> create table test0827_2 as select * from dba_objects;
executed successfully
used time: 45.855(ms). Execute id is 28.
SQL> select checkpoint(20);
CHECKPOINT(20)
--------------
0
used time: 8.479(ms). Execute id is 29.
SQL> select CKPT_LSN,FILE_LSN,FLUSH_LSN,CUR_LSN,DB_MAGIC,FLUSH_PAGES,CKPT_FILE,CKPT_OFFSET,TOTAL_SPACE,FREE_SPACE from v$rlog;
CKPT_LSN FILE_LSN FLUSH_LSN CUR_LSN DB_MAGIC FLUSH_PAGES CKPT_FILE CKPT_OFFSET TOTAL_SPACE FREE_SPACE
-------------------- -------------------- -------------------- -------------------- -------------------- ----------- ----------- -------------------- -------------------- --------------------
85679701 85679701 85679701 85679701 148545590 0 0 2351222272 9437171712 9437170688
used time: 1.472(ms). Execute id is 31.
SQL> select GROUP_ID,FILE_ID,PATH,MIN_EXEC_VER,MIN_DCT_VER from v$rlogfile;
GROUP_ID FILE_ID PATH MIN_EXEC_VER MIN_DCT_VER
----------- ----------- ------------------------------------------- ------------ -----------
2 0 /opt/dm/dmdbms/data/enmotech/enmotech01.log V8.1.1.1 4
2 1 /opt/dm/dmdbms/data/enmotech/enmotech02.log V8.1.1.1 4
2 2 /opt/dm/dmdbms/data/enmotech/enmotech03.log V8.1.1.1 4
used time: 2.537(ms). Execute id is 32.
如果redo 日志缓冲区没有实际数据,即使除非完全检查点,我们可以看到,实际上lsn也不会发生改变。
我这里测试环境中,当前正在写入的是enmotech01.log 这个redo文件,尝试把另外2个未写入的redolog 删掉试试。
SQL> host
[dmdba@mogdb ~]$ rm -rf /opt/dm/dmdbms/data/enmotech/enmotech02.log
[dmdba@mogdb ~]$ rm -rf /opt/dm/dmdbms/data/enmotech/enmotech03.log
[dmdba@mogdb ~]$ exit
exit
SQL> select file_id,path,rlog_size from v$rlogfile;
FILE_ID PATH RLOG_SIZE
----------- ------------------------------------------- --------------------
0 /opt/dm/dmdbms/data/enmotech/enmotech01.log 3145728000
1 /opt/dm/dmdbms/data/enmotech/enmotech02.log 3145728000
2 /opt/dm/dmdbms/data/enmotech/enmotech03.log 3145728000
3 /opt/dm/dmdbms/data/enmotech/enmotech04.log 33554432
4 /opt/dm/dmdbms/data/enmotech/enmotech05.log 33554432
used time: 2.176(ms). Execute id is 56.
SQL> shutdown immediate;
executed successfully
used time: 0.368(ms). Execute id is 0.
SQL> exit
[dmdba@mogdb ~]$ dmserver mount /opt/dm/dmdbms/data/enmotech/dm.ini
file dm.key not found, use default license!
version info: develop
Use normal os_malloc instead of HugeTLB
Use normal os_malloc instead of HugeTLB
DM Database Server x64 V8 1-1-126-20.09.04-126608-ENT startup...
Database mode = 0, oguid = 0
/opt/dm/dmdbms/data/enmotech/enmotech02.log not exist, can not startup
可以看到,当把其他redo log删掉之后,达梦数据库也无法启动了(数据库mount 也不能了),如下是后台日志的报错:
2021-08-26 22:57:52.650 [FATAL] database P0000029130 T0000000000000029130 /opt/dm/dmdbms/data/enmotech/enmotech02.log not exist,can not startup
2021-08-26 23:28:07.681 [INFO] database P0000031404 T0000000000000031404 version info: develop
2021-08-26 23:28:07.686 [INFO] database P0000031404 T0000000000000031404 Database's huge_with_delta is 1, and rlog_gen_for_huge is 0!
2021-08-26 23:28:07.687 [INFO] database P0000031404 T0000000000000031404 os_sema2_create_low, create and inc sema success, key:233665561, sem_id:32768, sem_value:1!
2021-08-26 23:28:07.692 [INFO] database P0000031404 T0000000000000031404 DM Database Server x64 V8 1-1-126-20.09.04-126608-ENT startup...
2021-08-26 23:28:07.789 [INFO] database P0000031404 T0000000000000031404 fil_sys_init
2021-08-26 23:28:07.945 [INFO] database P0000031404 T0000000000000031404 Database mode = 0, oguid = 0
2021-08-26 23:28:07.946 [WARNING] database P0000031404 T0000000000000031404 License will expire on 2021-09-09
2021-08-26 23:28:07.947 [INFO] database P0000031404 T0000000000000031404 Initialize temp tablespace, file path: /opt/dm/dmdbms/data/enmotech/TEMP.DBF, code: 0
2021-08-26 23:28:07.951 [INFO] database P0000031404 T0000000000000031404 rfil[/opt/dm/dmdbms/data/enmotech/enmotech01.log] ver: 7006, sta: 1, arch_lsn = 0, arch_seq = 0, clsn = 86572219, clsn_fil = 0, clsn_off = 2528041472, l_next_seq = 739031, g_next_seq = 739031, free = 2528041472
2021-08-26 23:28:07.952 [ERROR] database P0000031404 T0000000000000031404 os_file_open at (/data/sdb/wxy/trunk8_rel_2008_f/dta/fil.c: 3405) error! desc: Ȩ, path: /opt/dm/dmdbms/data/enmotech/enmotech02.log, code: 13
2021-08-26 23:28:07.952 [ERROR] database P0000031404 T0000000000000031404 arch file(/opt/dm/dmdbms/data/enmotech/enmotech02.log) fil id check fail(file: /data/sdb/wxy/trunk8_rel_2008_f/log/rfil.c, line: 1125)
2021-08-26 23:28:07.952 [ERROR] database P0000031404 T0000000000000031404 rfil grp init log file /opt/dm/dmdbms/data/enmotech/enmotech02.log error, code = -717
2021-08-26 23:28:07.952 [ERROR] database P0000031404 T0000000000000031404 rlog4_init_low->rfil_grp_alloc failed, alloc_only = 0!
针对这种场景下,如何进行恢复呢? 根据达梦的手册,可以通过dmmdf工具来协助完成恢复。
1、获取原来数据库的db_magic和pement_magic
[dmdba@mogdb enmotech]$ dmmdf type=1 file=SYSTEM.DBF
dmmdf V8
**********************************************************
1 db_magic=148545590
2 next_trxid=854460
3 pemnt_magic=272050232
**********************************************************
Please input which parameter you want to change(1-3), q to quit: q
[dmdba@mogdb enmotech]$
2、通过dbinit初始化一个跟原库一样的实例
[root@mogdb bin]# ./dminit PATH=/opt/dm/dmdbms/data DB_NAME=test INSTANCE_NAME=testdb LOG_SIZE=3000
initdb V8
db version: 0x7000b
file dm.key not found, use default license!
License will expire on 2021-09-09
log file path: /opt/dm/dmdbms/data/test/test01.log
log file path: /opt/dm/dmdbms/data/test/test02.log
write to dir [/opt/dm/dmdbms/data/test].
create dm database success. 2021-08-26 23:22:44
3、将新实例创建的redo 复制到老环境
[root@mogdb bin]# cp /opt/dm/dmdbms/data/test/test01.log /opt/dm/dmdbms/data/enmotech/enmotech02.log
[root@mogdb bin]# cp /opt/dm/dmdbms/data/test/test02.log /opt/dm/dmdbms/data/enmotech/enmotech03.log
4、通过dmmdf修改 被复制redo log的magic信息
[root@mogdb bin]# ./dmmdf type=2 file=/opt/dm/dmdbms/data/enmotech/enmotech02.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -289137915
4 sta = 1
5 n_magic = 7
6 db_magic = 419458908
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 4096
12 pemnt_magic = 27934022
13 fil_id = 0
15 next_seq = 2457
16 g_next_seq = 2457
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
You can only reset sta(4) or db_magic (6) or clsn (9) or clsn_fil(10) or clsn_off(11) or pemnt_magic(12) or fil_id(13) or g_next_seq(16) or p_db_magic(20) or n_apply_ep(21).
Please input the num which one you want to change, q to quit: 6
Input the new value: 148545590
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -14756753
4 sta = 1
5 n_magic = 7
6 db_magic = 148545590
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 4096
12 pemnt_magic = 27934022
13 fil_id = 0
15 next_seq = 2457
16 g_next_seq = 2457
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!
[root@mogdb bin]#
[root@mogdb bin]# ./dmmdf type=2 file=/opt/dm/dmdbms/data/enmotech/enmotech03.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -171697404
4 sta = 0
5 n_magic = 7
6 db_magic = 419458908
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 0
12 pemnt_magic = 27934022
13 fil_id = 1
15 next_seq = 0
16 g_next_seq = 0
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
You can only reset sta(4) or db_magic (6) or clsn (9) or clsn_fil(10) or clsn_off(11) or pemnt_magic(12) or fil_id(13) or g_next_seq(16) or p_db_magic(20) or n_apply_ep(21).
Please input the num which one you want to change, q to quit: 6
Input the new value: 148545590
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -467741586
4 sta = 0
5 n_magic = 7
6 db_magic = 148545590
7 len = 268435456
8 free = 4096
9 clsn = 0
10 clsn_fil = 0
11 clsn_off = 0
12 pemnt_magic = 27934022
13 fil_id = 1
15 next_seq = 0
16 g_next_seq = 0
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!
[root@mogdb bin]#
[dmdba@mogdb ~]$ dmserver mount /opt/dm/dmdbms/data/enmotech/dm.ini
file dm.key not found, use default license!
version info: develop
Use normal os_malloc instead of HugeTLB
Use normal os_malloc instead of HugeTLB
DM Database Server x64 V8 1-1-126-20.09.04-126608-ENT startup...
Database mode = 0, oguid = 0
License will expire on 2021-09-09
os_file_open at (/data/sdb/wxy/trunk8_rel_2008_f/dta/fil.c: 3405) error! desc: Ȩ, path: /opt/dm/dmdbms/data/enmotech/enmotech02.log, code: 13
rfil grp init log file /opt/dm/dmdbms/data/enmotech/enmotech02.log error, code = -717
[dmdba@mogdb ~]$
[root@mogdb bin]# ./dminit PATH=/opt/dm/dmdbms/data DB_NAME=test INSTANCE_NAME=testdb LOG_SIZE=3000
initdb V8
db version: 0x7000b
file dm.key not found, use default license!
License will expire on 2021-09-09
value of the log file size error.
the log file size is between 64 and 2048.
fail to init db.
[root@mogdb bin]#
发现大小不一致,还不行。通过dminit 去初始化发现logfile最大支持2G的size,可是我这里之前resize可以3g呢? 很奇怪了。。。
到这里我准备换个思路。直接将原库现存的一个redo log复制不就好了吗 ?
[dmdba@mogdb enmotech]$ rm -rf enmotech02.log [dmdba@mogdb enmotech]$ rm -rf enmotech03.log [dmdba@mogdb enmotech]$ cp enmotech01.log enmotech02.log [dmdba@mogdb enmotech]$ cp enmotech01.log enmotech03.log [dmdba@mogdb enmotech]$
由于是同一个库,因此magic号就不在需要修改了:
[root@mogdb bin]# ./dmmdf type=2 file=/opt/dm/dmdbms/data/enmotech/enmotech02.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -280049311
4 sta = 1
5 n_magic = 7
6 db_magic = 148545590
7 len = 3145728000
8 free = 2528041472
9 clsn = 86572219
10 clsn_fil = 0
11 clsn_off = 2528041472
12 pemnt_magic = 272050232
13 fil_id = 0
15 next_seq = 739031
16 g_next_seq = 739031
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
You can only reset sta(4) or db_magic (6) or clsn (9) or clsn_fil(10) or clsn_off(11) or pemnt_magic(12) or fil_id(13) or g_next_seq(16) or p_db_magic(20) or n_apply_ep(21).
Please input the num which one you want to change, q to quit: 13
Input the new value: 1
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -280049312
4 sta = 1
5 n_magic = 7
6 db_magic = 148545590
7 len = 3145728000
8 free = 2528041472
9 clsn = 86572219
10 clsn_fil = 0
11 clsn_off = 2528041472
12 pemnt_magic = 272050232
13 fil_id = 1
15 next_seq = 739031
16 g_next_seq = 739031
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!
[root@mogdb bin]# ./dmmdf type=2 file=/opt/dm/dmdbms/data/enmotech/enmotech02.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -280049312
4 sta = 1
5 n_magic = 7
6 db_magic = 148545590
7 len = 3145728000
8 free = 2528041472
9 clsn = 86572219
10 clsn_fil = 0
11 clsn_off = 2528041472
12 pemnt_magic = 272050232
13 fil_id = 1
15 next_seq = 739031
16 g_next_seq = 739031
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
You can only reset sta(4) or db_magic (6) or clsn (9) or clsn_fil(10) or clsn_off(11) or pemnt_magic(12) or fil_id(13) or g_next_seq(16) or p_db_magic(20) or n_apply_ep(21).
Please input the num which one you want to change, q to quit: 16
Input the new value: 730000
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -282358176
4 sta = 1
5 n_magic = 7
6 db_magic = 148545590
7 len = 3145728000
8 free = 2528041472
9 clsn = 86572219
10 clsn_fil = 0
11 clsn_off = 2528041472
12 pemnt_magic = 272050232
13 fil_id = 1
15 next_seq = 739031
16 g_next_seq = 730000
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!
[root@mogdb bin]#
[root@mogdb bin]#
[root@mogdb bin]# ./dmmdf type=2 file=/opt/dm/dmdbms/data/enmotech/enmotech03.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -280049311
4 sta = 1
5 n_magic = 7
6 db_magic = 148545590
7 len = 3145728000
8 free = 2528041472
9 clsn = 86572219
10 clsn_fil = 0
11 clsn_off = 2528041472
12 pemnt_magic = 272050232
13 fil_id = 0
15 next_seq = 739031
16 g_next_seq = 739031
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
You can only reset sta(4) or db_magic (6) or clsn (9) or clsn_fil(10) or clsn_off(11) or pemnt_magic(12) or fil_id(13) or g_next_seq(16) or p_db_magic(20) or n_apply_ep(21).
Please input the num which one you want to change, q to quit: 13
Input the new value: 2
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -280049309
4 sta = 1
5 n_magic = 7
6 db_magic = 148545590
7 len = 3145728000
8 free = 2528041472
9 clsn = 86572219
10 clsn_fil = 0
11 clsn_off = 2528041472
12 pemnt_magic = 272050232
13 fil_id = 2
15 next_seq = 739031
16 g_next_seq = 739031
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!
[root@mogdb bin]# ./dmmdf type=2 file=/opt/dm/dmdbms/data/enmotech/enmotech03.log
dmmdf V8
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -280049309
4 sta = 1
5 n_magic = 7
6 db_magic = 148545590
7 len = 3145728000
8 free = 2528041472
9 clsn = 86572219
10 clsn_fil = 0
11 clsn_off = 2528041472
12 pemnt_magic = 272050232
13 fil_id = 2
15 next_seq = 739031
16 g_next_seq = 739031
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
You can only reset sta(4) or db_magic (6) or clsn (9) or clsn_fil(10) or clsn_off(11) or pemnt_magic(12) or fil_id(13) or g_next_seq(16) or p_db_magic(20) or n_apply_ep(21).
Please input the num which one you want to change, q to quit: 16
Input the new value: 735000
**********************************************************
1 sig = DMRLOG
2 ver = 7006
3 chksum = -281082269
4 sta = 1
5 n_magic = 7
6 db_magic = 148545590
7 len = 3145728000
8 free = 2528041472
9 clsn = 86572219
10 clsn_fil = 0
11 clsn_off = 2528041472
12 pemnt_magic = 272050232
13 fil_id = 2
15 next_seq = 739031
16 g_next_seq = 735000
17 arch_lsn = 0
18 arch_seq = 0
19 dbversion = 0x7000b
20 min_exec_version = V8.1.1.1
21 min_dct_version = 4
22 p_db_magic = 0
23 n_apply_ep = 0
24 apply_info_lsn = 0
pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
25 recv_p_db_magic = 0
26 recv_n_apply_ep = 0
recv_pkg_seq_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
recv_apply_lsn_arr: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
**********************************************************
Do you want to quit and save the change to file (y/n): y
Save to file success!
根据redo log切换重用的规律,修改fil_id和g_next_seq 即可。 下面来试试看能否mount 数据库。
[dmdba@mogdb ~]$ dmserver mount /opt/dm/dmdbms/data/enmotech/dm.ini file dm.key not found, use default license! version info: develop Use normal os_malloc instead of HugeTLB Use normal os_malloc instead of HugeTLB DM Database Server x64 V8 1-1-126-20.09.04-126608-ENT startup... Database mode = 0, oguid = 0 License will expire on 2021-09-09 file lsn: 86572219 ndct db load finished ndct fill fast pool finished nsvr_startup end. aud sys init success. aud rt sys init success. systables desc init success. ndct_db_load_info success. SYSTEM IS READY.
可以看到已经成功mount 数据库实例来,此时后台日志显示也是正常:
2021-08-26 23:45:43.314 [ERROR] database P0000032604 T0000000000000032604 fail to load libgssapi_krb5.so, /opt/dmdbms/bin/libgssapi_krb5.so: Ŀ¼
2021-08-26 23:45:43.315 [INFO] database P0000032604 T0000000000000032604 nsvr_startup end.
2021-08-26 23:45:43.416 [INFO] database P0000032604 T0000000000000032604 aud sys init success.
2021-08-26 23:45:43.416 [INFO] database P0000032604 T0000000000000032604 aud rt sys init success.
2021-08-26 23:45:43.416 [INFO] database P0000032604 T0000000000000032604 systables desc init success.
2021-08-26 23:45:43.417 [INFO] database P0000032604 T0000000000000032604 ndct_db_load_info success.
2021-08-26 23:45:43.418 [INFO] database P0000032604 T0000000000000032604 backup control file /opt/dm/dmdbms/data/enmotech/dm.ctl to file /opt/dm/dmdbms/data/enmotech/dm_20210826234543_418409.ctl
2021-08-26 23:45:43.423 [INFO] database P0000032604 T0000000000000032604 backup control file /opt/dm/dmdbms/data/enmotech/dm.ctl to file /opt/dm/dmdbms/data/enmotech/ctl_bak/dm_20210826234543_422211.ctl succeed
2021-08-26 23:45:43.423 [INFO] database P0000032604 T0000000000000032604 local instance name is DMDB, mode is NORMAL, status is MOUNT.
2021-08-26 23:45:43.423 [INFO] database P0000032604 T0000000000000032604 SYSTEM IS READY.
2021-08-26 23:45:43.423 [INFO] database P0000032604 T0000000000000032604 set g_dw_stat from UNDEFINED to NONE success, g_dw_recover_stop is 0
最后让我们一起来见证奇迹吧,open 数据库:
[dmdba@mogdb enmotech]$ disql sysdba/roger007
Server[LOCALHOST:5236]:mode is normal, state is mount
login used time : 3.280(ms)
disql V8
SQL> desc v$instances
[-510]:Error in line: 119
System in mount status.
used time: 2.401(ms). Execute id is 0.
SQL> alter database open;
executed successfully
used time: 00:00:01.773. Execute id is 0.
SQL> select name,INSTANCE_NAME,START_TIME,STATUS$ from v$instance;
LINEID NAME INSTANCE_NAME START_TIME STATUS$
---------- ---- ------------- ---------------------------------------------------------------------------------------------------- -------
1 DMDB DMDB 2021-08-26 23:45:42 OPEN
used time: 1.083(ms). Execute id is 5.
自此,完成了人生的第一次达梦数据库的异常恢复。
最后修改时间:2021-08-30 09:12:35
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。