达梦数据库学习笔记之 — current redo误删除恢复
本站文章除注明转载外,均为本站原创: 转载自love wife love life —Roger的Oracle/MySQL/PostgreSQL数据恢复博客
本文链接地址: 达梦数据库学习笔记之 — current redo误删除恢复
前一篇文章测试了非current redo的情况,这里继续测试达梦数据库current redo如果被误删除如何启动数据库。
首先创建测试表,并删除current redo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
SQL> create table test_recovery as select * from dba_objects where rownum < 10; executed successfully used time: 25.033(ms). Execute id is 4. SQL> select count(1) from test_recovery; LINEID COUNT(1) ---------- -------------------- 1 9 used time: 0.553(ms). Execute id is 5. SQL> select owner,object_name,object_id from test_recovery; LINEID OWNER OBJECT_NAME OBJECT_ID ---------- ------------ -------------- --------- 1 BENCHMARKSQL BENCHMARKSQL 150995945 2 CTISYS CTISYS 150994948 3 SYS SYS 150994944 4 SYSAUDITOR SYSAUDITOR 150994946 5 SYSDBA SYSDBA 150994945 6 SYSSSO SYSSSO 150994947 7 BENCHMARKSQL BMSQL_CONFIG 1421 8 BENCHMARKSQL BMSQL_CUSTOMER 1423 9 BENCHMARKSQL BMSQL_DISTRICT 1422 9 rows got used time: 0.462(ms). Execute id is 6. SQL> delete from test_recovery where OBJECT_ID in(1421,1422,1423); affect rows 3 used time: 1.203(ms). Execute id is 7. 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; LINEID CKPT_LSN FILE_LSN FLUSH_LSN CUR_LSN DB_MAGIC FLUSH_PAGES CKPT_FILE CKPT_OFFSET TOTAL_SPACE FREE_SPACE ---------- -------------------- -------------------- -------------------- -------------------- -------------------- ----------- ----------- -------------------- -------------------- -------------------- 1 86572726 86573150 86573150 86573150 148545590 0 0 2528081920 9504272384 9504219648 used time: 0.741(ms). Execute id is 8. SQL> select file_id,path,rlog_size from v$rlogfile; LINEID FILE_ID PATH RLOG_SIZE ---------- ----------- ------------------------------------------- -------------------- 1 0 /opt/dm/dmdbms/data/enmotech/enmotech01.log 3145728000 2 1 /opt/dm/dmdbms/data/enmotech/enmotech02.log 3145728000 3 2 /opt/dm/dmdbms/data/enmotech/enmotech03.log 3145728000 4 3 /opt/dm/dmdbms/data/enmotech/enmotech04.log 33554432 5 4 /opt/dm/dmdbms/data/enmotech/enmotech05.log 33554432 used time: 1.081(ms). Execute id is 9. SQL> host rm -rf /opt/dm/dmdbms/data/enmotech/enmotech01.log SQL> shutdown abort; executed successfully used time: 0.479(ms). Execute id is 0. SQL> |
此时尝试去启动数据库,肯定是会报错的;如下所示:
1 2 3 4 5 6 7 8 9 10 |
[dmdba@mogdb ~]$ DmServicedmdb start Starting DmServicedmdb: [ FAILED ] 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/enmotech01.log not exist, can not startup [dmdba@mogdb ~]$ |
这里我们利用其他2个日志来构造修改被删除的enmotech01.log。
[dmdba@mogdb ~]$ cp /opt/dm/dmdbms/data/enmotech/enmotech02.log /opt/dm/dmdbms/data/enmotech/enmotech01.log
[dmdba@mogdb ~]$
使用工具修复redo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
[root@mogdb bin]# ./dmmdf type=2 file=/opt/dm/dmdbms/data/enmotech/enmotech01.log dmmdf V8 ********************************************************** 1 sig = DMRLOG 2 ver = 7006 3 chksum = -2123134874 4 sta = 0 5 n_magic = 7 6 db_magic = 148545590 7 len = 3145728000 8 free = 2528041472 9 clsn = 0 10 clsn_fil = 0 11 clsn_off = 0 12 pemnt_magic = 272050232 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: 13 Input the new value: 0 ********************************************************** 1 sig = DMRLOG 2 ver = 7006 3 chksum = -2123134873 4 sta = 0 5 n_magic = 7 6 db_magic = 148545590 7 len = 3145728000 8 free = 2528041472 9 clsn = 0 10 clsn_fil = 0 11 clsn_off = 0 12 pemnt_magic = 272050232 13 fil_id = 0 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! |
再次启动发现仍然报错:
1 2 3 4 5 6 7 8 9 10 11 |
[dmdba@mogdb ~]$ DmServicedmdb start Starting DmServicedmdb: [ FAILED ] 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-10 EP[0]'s cur_lsn[0] [dmdba@mogdb ~]$ |
检查日志发现相关信息是不对的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
2021-08-27 01:38:28.254 [WARNING] database P0000039507 T0000000000000039507 License will expire on 2021-09-10 2021-08-27 01:38:28.256 [INFO] database P0000039507 T0000000000000039507 Initialize temp tablespace, file path: /opt/dm/dmdbms/data/enmotech/TEMP.DBF, code: 0 2021-08-27 01:38:28.262 [INFO] database P0000039507 T0000000000000039507 rfil[/opt/dm/dmdbms/data/enmotech/enmotech01.log] ver: 7006, sta: 0, arch_lsn = 0, arch_seq = 0, clsn = 0, clsn_fil = 0, clsn_off = 0, l_next_seq = 0, g_next_seq = 0, free = 2528041472 2021-08-27 01:38:28.263 [INFO] database P0000039507 T0000000000000039507 rlog4_apply_info_set, p_db_magic:[0x0](old value:0x0), n_apply_ep: 0(old n_ep=0), apply_info_lsn: 0(old 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] 2021-08-27 01:38:28.263 [INFO] database P0000039507 T0000000000000039507 hlog_sys_destroy, n_logs[1], adjust_sta[0] 2021-08-27 01:38:28.264 [INFO] database P0000039507 T0000000000000039507 rfil[/opt/dm/dmdbms/data/enmotech/enmotech01.log] ver: 7006, sta: 0, arch_lsn = 0, arch_seq = 0, clsn = 0, clsn_fil = 0, clsn_off = 0, l_next_seq = 0, g_next_seq = 0, free = 2528041472 2021-08-27 01:38:28.265 [INFO] database P0000039507 T0000000000000039507 rlog4_apply_info_set, p_db_magic:[0x0](old value:0x0), n_apply_ep: 0(old n_ep=0), apply_info_lsn: 0(old 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] 2021-08-27 01:38:28.270 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:0, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.273 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:1, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.277 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:2, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.280 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:3, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.284 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:4, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.288 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:5, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.291 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:6, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.295 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:7, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.298 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:8, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.306 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:9, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.311 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:10, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.314 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:11, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.317 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:12, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.321 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:13, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.325 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:14, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.330 [INFO] database P0000039507 T0000000000000039507 plog_redo_init, rlog is null, dsc_seqno:15, set plog_redo->redo_lsn from 0 to 0 2021-08-27 01:38:28.381 [INFO] database P0000039507 T0000000000000039507 main rfil[/opt/dm/dmdbms/data/enmotech/enmotech01.log]'s sta is active 2021-08-27 01:38:28.381 [ERROR] database P0000039507 T0000000000000039507 Read rfil['/opt/dm/dmdbms/data/enmotech/enmotech01.log'] from offset[0] failed, code[-723] 2021-08-27 01:38:28.381 [INFO] database P0000039507 T0000000000000039507 rfil[/opt/dm/dmdbms/data/enmotech/enmotech01.log], first local_rpkg_seqno = 0, global_rpkg_seqno = 0, first_startup = 0 2021-08-27 01:38:28.381 [INFO] database P0000039507 T0000000000000039507 EP[0]'s cur_lsn[0] 2021-08-27 01:38:28.381 [FATAL] database P0000039507 T0000000000000039507 redo_pwr_collect error, code = -723 2021-08-27 01:38:28.382 [INFO] database P0000039507 T0000000000000039507 hlog_sys_destroy, n_logs[1], adjust_sta[0] |
进一步检查之前的日志,寻找lsn等信息:
1 2 3 4 5 |
2021-08-27 01:28:46.940 [INFO] database P0000032604 T0000000000000032607 shutdown redo log subsystem... 2021-08-27 01:28:46.940 [INFO] database P0000032604 T0000000000000032607 rfil_close_low set main rfil[/opt/dm/dmdbms/data/enmotech/enmotech01.log]'s sta to inactive, l_next_seq = 739034, g_next_seq = 739034, clsn = 86572726, handle = 7, free=2528081920, len=3145728000 2021-08-27 01:28:46.942 [INFO] database P0000032604 T0000000000000032607 os_sema2_free, sema_id:32768, sema_value:1! 2021-08-27 01:28:46.953 [INFO] database P0000032604 T0000000000000032607 shutdown MAL subsystem... 2021-08-27 01:28:47.004 [FATAL] database P0000032604 T0000000000000032604 sigterm_handler receive signal 2 |
再次进行修改:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
[root@mogdb bin]# ./dmmdf type=2 file=/opt/dm/dmdbms/data/enmotech/enmotech01.log dmmdf V8 ********************************************************** 1 sig = DMRLOG 2 ver = 7006 3 chksum = -2123134873 4 sta = 0 5 n_magic = 7 6 db_magic = 148545590 7 len = 3145728000 8 free = 2528041472 9 clsn = 0 10 clsn_fil = 0 11 clsn_off = 0 12 pemnt_magic = 272050232 13 fil_id = 0 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: 16 Input the new value: 739034 ********************************************************** 1 sig = DMRLOG 2 ver = 7006 3 chksum = -1976216985 4 sta = 0 5 n_magic = 7 6 db_magic = 148545590 7 len = 3145728000 8 free = 2528041472 9 clsn = 0 10 clsn_fil = 0 11 clsn_off = 0 12 pemnt_magic = 272050232 13 fil_id = 0 15 next_seq = 0 16 g_next_seq = 739034 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/enmotech01.log dmmdf V8 ********************************************************** 1 sig = DMRLOG 2 ver = 7006 3 chksum = -1976216985 4 sta = 0 5 n_magic = 7 6 db_magic = 148545590 7 len = 3145728000 8 free = 2528041472 9 clsn = 0 10 clsn_fil = 0 11 clsn_off = 0 12 pemnt_magic = 272050232 13 fil_id = 0 15 next_seq = 0 16 g_next_seq = 739034 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: 9 Input the new value: 86572726 ERROR, rlog is active, dmserver should shutdown normal. [root@mogdb bin]# |
看上去修改不对,提示这个redo log状态是inactive。那么首先修改成active,试试看;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
[root@mogdb bin]# ./dmmdf type=2 file=/opt/dm/dmdbms/data/enmotech/enmotech01.log dmmdf V8 ********************************************************** 1 sig = DMRLOG 2 ver = 7006 3 chksum = -1976216985 4 sta = 0 5 n_magic = 7 6 db_magic = 148545590 7 len = 3145728000 8 free = 2528041472 9 clsn = 0 10 clsn_fil = 0 11 clsn_off = 0 12 pemnt_magic = 272050232 13 fil_id = 0 15 next_seq = 0 16 g_next_seq = 739034 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: 4 Input the new value: 1 ********************************************************** 1 sig = DMRLOG 2 ver = 7006 3 chksum = -1976216986 4 sta = 1 5 n_magic = 7 6 db_magic = 148545590 7 len = 3145728000 8 free = 2528041472 9 clsn = 0 10 clsn_fil = 0 11 clsn_off = 0 12 pemnt_magic = 272050232 13 fil_id = 0 15 next_seq = 0 16 g_next_seq = 739034 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/enmotech01.log dmmdf V8 ********************************************************** 1 sig = DMRLOG 2 ver = 7006 3 chksum = -1976216986 4 sta = 1 5 n_magic = 7 6 db_magic = 148545590 7 len = 3145728000 8 free = 2528041472 9 clsn = 0 10 clsn_fil = 0 11 clsn_off = 0 12 pemnt_magic = 272050232 13 fil_id = 0 15 next_seq = 0 16 g_next_seq = 739034 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: 9 Input the new value: 86572726 ********************************************************** 1 sig = DMRLOG 2 ver = 7006 3 chksum = -1893880624 4 sta = 1 5 n_magic = 7 6 db_magic = 148545590 7 len = 3145728000 8 free = 2528041472 9 clsn = 86572726 10 clsn_fil = 0 11 clsn_off = 0 12 pemnt_magic = 272050232 13 fil_id = 0 15 next_seq = 0 16 g_next_seq = 739034 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]# |
Ok!自此修改完毕,接下来我们尝试启动达梦数据库看看效果。
1 2 3 4 |
[dmdba@mogdb ~]$ DmServicedmdb start Starting DmServicedmdb: [ OK ] [dmdba@mogdb ~]$ [dmdba@mogdb ~]$ |
最后我们验证一下数据库:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
[dmdba@mogdb enmotech]$ disql sysdba/roger007 Server[LOCALHOST:5236]:mode is normal, state is open login used time : 3.007(ms) disql V8 SQL> select file_id,path,rlog_size from v$rlogfile; LINEID FILE_ID PATH RLOG_SIZE ---------- ----------- ------------------------------------------- -------------------- 1 0 /opt/dm/dmdbms/data/enmotech/enmotech01.log 3145728000 2 1 /opt/dm/dmdbms/data/enmotech/enmotech02.log 3145728000 3 2 /opt/dm/dmdbms/data/enmotech/enmotech03.log 3145728000 4 3 /opt/dm/dmdbms/data/enmotech/enmotech04.log 33554432 5 4 /opt/dm/dmdbms/data/enmotech/enmotech05.log 33554432 used time: 3.137(ms). Execute id is 4. SQL> select owner,object_name,object_id from test_recovery; LINEID OWNER OBJECT_NAME OBJECT_ID ---------- ------------ -------------- --------- 1 BENCHMARKSQL BENCHMARKSQL 150995945 2 CTISYS CTISYS 150994948 3 SYS SYS 150994944 4 SYSAUDITOR SYSAUDITOR 150994946 5 SYSDBA SYSDBA 150994945 6 SYSSSO SYSSSO 150994947 7 BENCHMARKSQL BMSQL_CONFIG 1421 8 BENCHMARKSQL BMSQL_CUSTOMER 1423 9 BENCHMARKSQL BMSQL_DISTRICT 1422 9 rows got used time: 5.998(ms). Execute id is 5. SQL> |
可以发现数据库正常,数据也是正常的。不过通过综合分析,发现达梦数据库似乎在事务一致性方面校验并不是十分的严格。
后面我进行了类似多次测试,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
SQL> select owner,object_name,object_id from test_recovery; LINEID OWNER OBJECT_NAME OBJECT_ID ---------- ------------ ------------ --------- 1 BENCHMARKSQL BENCHMARKSQL 150995945 2 CTISYS CTISYS 150994948 3 SYS SYS 150994944 4 SYSAUDITOR SYSAUDITOR 150994946 5 SYSDBA SYSDBA 150994945 6 SYSSSO SYSSSO 150994947 6 rows got used time: 7.054(ms). Execute id is 5. SQL> SQL> SQL> SQL> delete from test_recovery where OBJECT_ID=150995945 2 ; affect rows 1 used time: 7.161(ms). Execute id is 6. SQL> select checkpoint(100); LINEID CHECKPOINT(100) ---------- --------------- 1 0 used time: 3.501(ms). Execute id is 7. SQL> / LINEID CHECKPOINT(100) ---------- --------------- 1 0 used time: 3.287(ms). Execute id is 8. SQL> / LINEID CHECKPOINT(100) ---------- --------------- 1 0 used time: 103.138(ms). Execute id is 9. 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; LINEID CKPT_LSN FILE_LSN FLUSH_LSN CUR_LSN DB_MAGIC FLUSH_PAGES CKPT_FILE CKPT_OFFSET TOTAL_SPACE FREE_SPACE ---------- -------------------- -------------------- -------------------- -------------------- -------------------- ----------- ----------- -------------------- -------------------- -------------------- 1 86573321 86573321 86573321 86573321 148545590 0 0 35328 9504272384 9504272384 used time: 1.557(ms). Execute id is 10. SQL> select file_id,path,rlog_size from v$rlogfile; LINEID FILE_ID PATH RLOG_SIZE ---------- ----------- ------------------------------------------- -------------------- 1 0 /opt/dm/dmdbms/data/enmotech/enmotech01.log 3145728000 2 1 /opt/dm/dmdbms/data/enmotech/enmotech02.log 3145728000 3 2 /opt/dm/dmdbms/data/enmotech/enmotech03.log 3145728000 4 3 /opt/dm/dmdbms/data/enmotech/enmotech04.log 33554432 5 4 /opt/dm/dmdbms/data/enmotech/enmotech05.log 33554432 used time: 1.226(ms). Execute id is 11. SQL> host rm -rf /opt/dm/dmdbms/data/enmotech/enmotech01.log SQL> shutdown abort; executed successfully used time: 3.585(ms). Execute id is 0. SQL> |
修改redo的步骤类似,这里省略。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[dmdba@mogdb ~]$ DmServicedmdb start Starting DmServicedmdb: [ OK ] [dmdba@mogdb ~]$ SQL> select instance_name,status$ from v$instance; LINEID INSTANCE_NAME STATUS$ ---------- ------------- ------- 1 DMDB OPEN used time: 3.383(ms). Execute id is 4. SQL> select owner,object_name,object_id from test_recovery; LINEID OWNER OBJECT_NAME OBJECT_ID ---------- ------------ ------------ --------- 1 BENCHMARKSQL BENCHMARKSQL 150995945 2 CTISYS CTISYS 150994948 3 SYS SYS 150994944 4 SYSAUDITOR SYSAUDITOR 150994946 5 SYSDBA SYSDBA 150994945 6 SYSSSO SYSSSO 150994947 6 rows got used time: 4.907(ms). Execute id is 5. SQL> |
数据仍然正常,此时日志中有事务回滚方面的信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
2021-08-27 02:04:22.577 [INFO] database P0000041271 T0000000000000041271 total 1 active crash trx, pseg_crash_trx_rollbacksys_only(0) begin ... 2021-08-27 02:04:22.577 [INFO] database P0000041271 T0000000000000041271 rollback trx[860480], locks[2], first_fpa(1, 0, 40159), last_fpa(1, 0, 40159), n_pages(1) 2021-08-27 02:04:22.577 [INFO] database P0000041271 T0000000000000041271 trx: 860480 rollbacking... 2021-08-27 02:04:22.578 [INFO] database P0000041271 T0000000000000041271 total 1 page rollbacked, rollback percent: 100% 2021-08-27 02:04:22.578 [INFO] database P0000041271 T0000000000000041271 total 1 trx rollbacked, rollback percent: 100% 2021-08-27 02:04:22.578 [INFO] database P0000041271 T0000000000000041271 table: TEST_RECOVERY, schema id: 150994945, table id: 1454 rollback in trx 2021-08-27 02:04:22.578 [INFO] database P0000041271 T0000000000000041271 trx: 860480 rollback 1 upages, 2 urecs end 2021-08-27 02:04:22.578 [INFO] database P0000041271 T0000000000000041271 pseg_crash_trx_rollback end, total 1 active crash trx, include 0 empty_trxs, 0 empty_pages which only need to delete mgr recs. 2021-08-27 02:04:22.578 [INFO] database P0000041271 T0000000000000041271 pseg_crash_trx_rollback end 2021-08-27 02:04:22.578 [INFO] database P0000041271 T0000000000000041271 pseg_crash_trx_rollback all active trx used 1(ms), mgr_state:1! 2021-08-27 02:04:22.578 [INFO] database P0000041271 T0000000000000041271 pseg_sys_recv used 7ms! 2021-08-27 02:04:22.581 [INFO] database P0000041271 T0000000000000041271 pseg recv finished 2021-08-27 02:04:22.582 [INFO] database P0000041271 T0000000000000041271 nsvr_startup end. 2021-08-27 02:04:22.683 [INFO] database P0000041271 T0000000000000041271 aud sys init success. 2021-08-27 02:04:22.683 [INFO] database P0000041271 T0000000000000041271 aud rt sys init success. 2021-08-27 02:04:22.683 [INFO] database P0000041271 T0000000000000041271 systables desc init success. 2021-08-27 02:04:22.683 [INFO] database P0000041271 T0000000000000041271 ndct_db_load_info success. 2021-08-27 02:04:22.683 [INFO] database P0000041271 T0000000000000041271 nsvr_process_before_open begin. 2021-08-27 02:04:22.683 [INFO] database P0000041271 T0000000000000041271 Update DM8_DCT_VERSION from 20 to 20, rebuild dynamic tables begin... 2021-08-27 02:04:22.683 [INFO] database P0000041271 T0000000000000041271 Update DM8_DCT_VERSION from 20 to 20, rebuild dynamic tables end. 2021-08-27 02:04:22.739 [INFO] database P0000041271 T0000000000000041271 nsvr_process_before_open success. 2021-08-27 02:04:22.739 [INFO] database P0000041271 T0000000000000041295 total 0 active crash trx, pseg_crash_trx_rollbacksys_only(0) begin ... 2021-08-27 02:04:22.739 [INFO] database P0000041271 T0000000000000041295 pseg_crash_trx_rollback end, total 0 active crash trx, include 0 empty_trxs, 0 empty_pages which only need to delete mgr recs. 2021-08-27 02:04:22.739 [INFO] database P0000041271 T0000000000000041295 pseg_crash_trx_rollback end 2021-08-27 02:04:22.743 [INFO] database P0000041271 T0000000000000041271 backup control file /opt/dm/dmdbms/data/enmotech/dm.ctl to file /opt/dm/dmdbms/data/enmotech/dm_20210827020422_743043.ctl 2021-08-27 02:04:22.744 [INFO] database P0000041271 T0000000000000041271 backup control file /opt/dm/dmdbms/data/enmotech/dm.ctl to file /opt/dm/dmdbms/data/enmotech/ctl_bak/dm_20210827020422_743940.ctl succeed 2021-08-27 02:04:22.744 [INFO] database P0000041271 T0000000000000041271 local instance name is DMDB, mode is NORMAL, status is OPEN. |
这里让我有点看不懂了。难道事务恢复不需要Redo?我只需要Redo的几个关键信息就可以欺骗达梦数据库?
Leave a Reply
You must be logged in to post a comment.