达梦数据库学习笔记之 — DM数据库第一次异常恢复(redo log误删除)
本站文章除注明转载外,均为本站原创: 转载自love wife love life —Roger的Oracle/MySQL/PostgreSQL数据恢复博客
达梦数据库的Redo log跟Oracle有些不同,虽然名称上差不多,作用也类似,但是还是有差差别。
在达梦数据库中有日志包的概念,主从同步时是以日志包的形式来进行;其中达梦也有lsn,这跟检查点有关(oracle中为scn)。
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 |
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 删掉试试。
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 |
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 也不能了),如下是后台日志的报错:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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
1 2 3 4 5 6 7 8 9 |
[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初始化一个跟原库一样的实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@mogdb bin]# ./dminit PATH=/opt/dm/dmdbms/data DB_NAME=test INSTANCE_NAME=testdb 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 复制到老环境
1 2 |
[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信息
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
[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复制不就好了吗 ?
1 2 3 4 5 |
[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号就不在需要修改了:
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
[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 数据库。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[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 数据库实例来,此时后台日志显示也是正常:
1 2 3 4 5 6 7 8 9 10 11 |
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 数据库:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[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. |
自此,完成了人生的第一次达梦数据库的异常恢复。
最后简单总结一下:
1、redo日志不存在或者损坏,实例是无法mount的,这跟Oracle不同,mount的时候只是加载控制文件。
2、dmmdf工具可以用来修改一些文件,比如redo log,但是有些信息是无法修改的。
3、达梦数据库没有增量检查点的说法,不过默认180s 会触发一次,同时会控制每次flush page的数量等等;关于检查点方面的参数调整;
还需要结合实际业务进行压测调整。
Leave a Reply
You must be logged in to post a comment.