达梦数据库学习笔记之–物理文件结构
本站文章除注明转载外,均为本站原创: 转载自love wife love life —Roger的Oracle/MySQL/PostgreSQL数据恢复博客
本文链接地址: 达梦数据库学习笔记之–物理文件结构
这里达梦数据库学习系列的第三篇文章,今天重点了解一下达梦数据库的物理文件结构。
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 |
[dmdba@mogdb data]$ tree ./enmotech/ ./enmotech/ ├── bak ├── ctl_bak │ ├── dm_20210526024742_318210.ctl │ ├── dm_20210526024742_323043.ctl │ ├── dm_20210526024742_324152.ctl │ ├── dm_20210624184634_902109.ctl │ ├── dm_20210714192406_585108.ctl │ ├── dm_20210729003202_244924.ctl │ ├── dm_20210730072401_783694.ctl │ ├── dm_20210821022652_517401.ctl │ ├── dm_20210824060216_278179.ctl │ ├── dm_20210824061504_600325.ctl │ └── dm_20210825004716_595562.ctl ├── dm.ctl ├── dm.ini ├── dminit20210526020626.log ├── dm_service.prikey ├── enmotech01.dbf ├── enmotech01.log ├── enmotech02.log ├── enmotech03.log ├── HMAIN ├── MAIN.DBF ├── rep_conflict.log ├── ROLL.DBF ├── sqllog.ini ├── SYSTEM.DBF ├── TEMP.DBF └── trace 4 directories, 25 files |
从数据库目录来看,其中包含了几类主要的问题:控制文件、system文件、回滚段文件、temp文件、HMAIN文件以及redo日志文件、参数文件dm.ini。
参数文件之前已经讲过,这里不再描述。首先来看下控制文件。
1、控制文件
1 2 3 4 5 |
[dmdba@mogdb enmotech]$ cat dm.ini |grep CTL_ CTL_PATH = /opt/dm/dmdbms/data/enmotech/dm.ctl #ctl file path CTL_BAK_PATH = /opt/dm/dmdbms/data/enmotech/ctl_bak #dm.ctl backup path CTL_BAK_NUM = 10 #backup number of dm.ctl, allowed to keep one more backup file besides specified number. [dmdba@mogdb enmotech]$ |
通过上面几个参数来进行定义控制文件的路径和备份路径;以及控制文件保留的数量(这一点比较灵活,比Oracle好,Oracle如果默认不配置策略,会永久保留)。
当数据库中文件数量发生变化时,比如新增文件或者删除文件时,控制文件会自动进行备份。接下来我们strings来看看控制文件有什么内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[dmdba@mogdb enmotech]$ strings dm.ctl enmotech SYSTEM /opt/dm/dmdbms/data/enmotech/SYSTEM.DBF ROLL /opt/dm/dmdbms/data/enmotech/ROLL.DBF RLOG /opt/dm/dmdbms/data/enmotech/enmotech01.log /opt/dm/dmdbms/data/enmotech/enmotech02.log /opt/dm/dmdbms/data/enmotech/enmotech03.log MAIN /opt/dm/dmdbms/data/enmotech/MAIN.DBF ENMOTECH NORMAL /opt/dm/dmdbms/data/enmotech/enmotech01.dbf HMAIN" /opt/dm/dmdbms/data/enmotech/HMAIN [dmdba@mogdb enmotech]$ |
数据库在启动之前,首先需要加载控制文件,那么控制文件中到底有哪些内容呢?如果控制文件损坏或者不存在,我们来看看启动数据库是什么现象?
1 2 3 4 5 6 7 8 9 10 |
[dmdba@mogdb enmotech]$ DmServicedmdb stop Stopping DmServicedmdb: [ OK ] [dmdba@mogdb enmotech]$ mv dm.ctl dm.ctl0825 [dmdba@mogdb enmotech]$ [dmdba@mogdb enmotech]$ DmServicedmdb start Starting DmServicedmdb: [ FAILED ] file dm.key not found, use default license! Read ini error, name:CTL_PATH, value:/opt/dm/dmdbms/data/enmotech/dm.ctl dmserver startup failed, code = -803 [Invalid ini config value] nsvr_ini_file_read failed, [code: -803] |
如果是控制文件损坏呢?假设文件是存在的。 我这里将数据库名称enmotech修改成enmottch。看看能否启动数据库?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[dmdba@mogdb enmotech]$ vi dm.ctl [dmdba@mogdb enmotech]$ strings dm.ctl enmottch SYSTEM /opt/dm/dmdbms/data/enmotech/SYSTEM.DBF ROLL /opt/dm/dmdbms/data/enmotech/ROLL.DBF RLOG /opt/dm/dmdbms/data/enmotech/enmotech01.log /opt/dm/dmdbms/data/enmotech/enmotech02.log /opt/dm/dmdbms/data/enmotech/enmotech03.log MAIN /opt/dm/dmdbms/data/enmotech/MAIN.DBF ENMOTECH NORMAL /opt/dm/dmdbms/data/enmotech/enmotech01.dbf HMAIN" /opt/dm/dmdbms/data/enmotech/HMAIN [dmdba@mogdb enmotech]$ DmServicedmdb start Starting DmServicedmdb: [ OK ] [dmdba@mogdb enmotech]$ |
居然能够顺利启动数据库?这是神马情况??? 继续看看数据库日志呢。
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 |
2021-08-25 04:21:40.032 [INFO] database P0000014223 T0000000000000014223 Database's huge_with_delta is 1, and rlog_gen_for_huge is 0! 2021-08-25 04:21:40.034 [INFO] database P0000014223 T0000000000000014223 os_sema2_create_low, create and inc sema success, key:233665561, sem_id:32768, sem_value:1! 2021-08-25 04:21:40.043 [INFO] database P0000014223 T0000000000000014223 DM Database Server x64 V8 1-1-126-20.09.04-126608-ENT startup... 2021-08-25 04:21:40.137 [INFO] database P0000014223 T0000000000000014223 fil_sys_init 2021-08-25 04:21:40.291 [INFO] database P0000014223 T0000000000000014223 Database mode = 0, oguid = 0 2021-08-25 04:21:40.295 [WARNING] database P0000014223 T0000000000000014223 License will expire on 2021-09-08 2021-08-25 04:21:40.298 [INFO] database P0000014223 T0000000000000014223 Initialize temp tablespace, file path: /opt/dm/dmdbms/data/enmotech/TEMP.DBF, code: 0 2021-08-25 04:21:40.308 [INFO] database P0000014223 T0000000000000014223 rfil[/opt/dm/dmdbms/data/enmotech/enmotech01.log] ver: 7006, sta: 1, arch_lsn = 0, arch_seq = 0, clsn = 45150283, clsn_fil = 0, clsn_off = 2704790016, l_next_seq = 714276, g_next_seq = 714276, free = 2704790016 2021-08-25 04:21:40.308 [INFO] database P0000014223 T0000000000000014223 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-25 04:21:40.309 [INFO] database P0000014223 T0000000000000014223 hlog_sys_destroy, n_logs[1], adjust_sta[0] 2021-08-25 04:21:40.310 [INFO] database P0000014223 T0000000000000014223 rfil[/opt/dm/dmdbms/data/enmotech/enmotech01.log] ver: 7006, sta: 1, arch_lsn = 0, arch_seq = 0, clsn = 45150283, clsn_fil = 0, clsn_off = 2704790016, l_next_seq = 714276, g_next_seq = 714276, free = 2704790016 2021-08-25 04:21:40.311 [INFO] database P0000014223 T0000000000000014223 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-25 04:21:40.316 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:0, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.320 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:1, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.324 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:2, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.330 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:3, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.333 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:4, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.337 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:5, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.340 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:6, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.343 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:7, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.350 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:8, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.354 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:9, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.358 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:10, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.362 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:11, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.365 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:12, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.368 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:13, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.371 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:14, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.374 [INFO] database P0000014223 T0000000000000014223 plog_redo_init, rlog is null, dsc_seqno:15, set plog_redo->redo_lsn from 0 to 0 2021-08-25 04:21:40.426 [INFO] database P0000014223 T0000000000000014223 hlog_sys_destroy, n_logs[1], adjust_sta[0] 2021-08-25 04:21:40.427 [INFO] database P0000014223 T0000000000000014223 file lsn: 45150283 2021-08-25 04:21:40.427 [INFO] database P0000014223 T0000000000000014223 rlog4_apply_info_clear, arr_clear:0, file_path:/opt/dm/dmdbms/data/enmotech/enmotech01.log 2021-08-25 04:21:40.428 [INFO] database P0000014223 T0000000000000014223 rlog4_apply_info_clear reset p_db_magic[0], n_apply_ep[0], 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-25 04:21:40.428 [INFO] database P0000014223 T0000000000000014223 rlog4_apply_info_clear reset ckpt_p_db_magic[0], ckpt_n_apply_ep[0], ckpt_apply_info_lsn[0], ckpt_pkg_seq_arr:[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ckpt_apply_lsn_arr:[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]! 2021-08-25 04:21:40.429 [INFO] database P0000014223 T0000000000000014223 ndct db load finished 2021-08-25 04:21:40.430 [INFO] database P0000014223 T0000000000000014223 hpc_dw_apply_info_check_make, p_db_magic(0), n_apply_ep(0), apply_pkg_seq([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]), db_magic(148545590), n_ep(1), apply_info_lsn(45150283), pkg_seq_arr([714275, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), file_lsn([45150283, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) 2021-08-25 04:21:40.430 [INFO] database P0000014223 T0000000000000014223 ohis_ctl_add success, ctl info: rguid:DMDB_11, sys_mode:NORMAL, p_iname:DMDB, c_iname:DMDB, p_db_magic:148545590, c_db_magic:148545590, n_ep:1, pkg_seqno:[714275], lsn_arr:[45150283] 2021-08-25 04:21:40.431 [INFO] database P0000014223 T0000000000000014223 rlog4_apply_info_clear, arr_clear:0, file_path:/opt/dm/dmdbms/data/enmotech/enmotech01.log 2021-08-25 04:21:40.431 [INFO] database P0000014223 T0000000000000014223 rlog4_apply_info_clear reset p_db_magic[0], n_apply_ep[0], 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-25 04:21:40.431 [INFO] database P0000014223 T0000000000000014223 rlog4_apply_info_clear reset ckpt_p_db_magic[0], ckpt_n_apply_ep[0], ckpt_apply_info_lsn[0], ckpt_pkg_seq_arr:[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ckpt_apply_lsn_arr:[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]! 2021-08-25 04:21:40.520 [INFO] database P0000014223 T0000000000000014223 ndct fill fast pool finished 2021-08-25 04:21:40.528 [ERROR] database P0000014223 T0000000000000014223 fail to load libgssapi_krb5.so, /opt/dmdbms/bin/libgssapi_krb5.so: Ŀ¼ 2021-08-25 04:21:40.528 [INFO] database P0000014223 T0000000000000014223 iid_set_new_next_trxid_if_necessary, next_trxid: 833957 2021-08-25 04:21:40.528 [INFO] database P0000014223 T0000000000000014223 iid page's trxid[833957] 2021-08-25 04:21:40.529 [INFO] database P0000014223 T0000000000000014223 pseg_sys_recv begin... 2021-08-25 04:21:40.529 [INFO] database P0000014223 T0000000000000014223 EP[0] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.529 [INFO] database P0000014223 T0000000000000014223 EP[1] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.529 [INFO] database P0000014223 T0000000000000014223 EP[2] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.529 [INFO] database P0000014223 T0000000000000014223 EP[3] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.529 [INFO] database P0000014223 T0000000000000014223 EP[4] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.529 [INFO] database P0000014223 T0000000000000014223 EP[5] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.529 [INFO] database P0000014223 T0000000000000014223 EP[6] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.529 [INFO] database P0000014223 T0000000000000014223 EP[7] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.530 [INFO] database P0000014223 T0000000000000014223 EP[8] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.530 [INFO] database P0000014223 T0000000000000014223 EP[9] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.530 [INFO] database P0000014223 T0000000000000014223 EP[10] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.530 [INFO] database P0000014223 T0000000000000014223 EP[11] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.530 [INFO] database P0000014223 T0000000000000014223 EP[12] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.530 [INFO] database P0000014223 T0000000000000014223 EP[13] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.530 [INFO] database P0000014223 T0000000000000014223 EP[14] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.530 [INFO] database P0000014223 T0000000000000014223 EP[15] pseg_state is 0, set pseg state to 2 2021-08-25 04:21:40.531 [INFO] database P0000014223 T0000000000000014223 pseg_collect_mgr_items, total collect 0 active_trxs, 0 cmt_trxs, 0 pre_cmt_trxs, 0 active_pages, 0 cmt_pages, 0 pre_cmt_pages, 0 mgr pages, 0 mgr recs! 2021-08-25 04:21:40.531 [INFO] database P0000014223 T0000000000000014223 pseg collect items time used 2(ms), mgr_state:1! 2021-08-25 04:21:40.531 [INFO] database P0000014223 T0000000000000014223 total 0 active crash trx, pseg_crash_trx_rollbacksys_only(0) begin ... 2021-08-25 04:21:40.531 [INFO] database P0000014223 T0000000000000014223 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-25 04:21:40.531 [INFO] database P0000014223 T0000000000000014223 pseg_crash_trx_rollback end 2021-08-25 04:21:40.531 [INFO] database P0000014223 T0000000000000014223 pseg_crash_trx_rollback all active trx used 0(ms), mgr_state:1! 2021-08-25 04:21:40.531 [INFO] database P0000014223 T0000000000000014223 pseg_sys_recv used 3ms! 2021-08-25 04:21:40.532 [INFO] database P0000014223 T0000000000000014223 pseg recv finished 2021-08-25 04:21:40.533 [INFO] database P0000014223 T0000000000000014223 nsvr_startup end. 2021-08-25 04:21:40.636 [INFO] database P0000014223 T0000000000000014223 aud sys init success. 2021-08-25 04:21:40.638 [INFO] database P0000014223 T0000000000000014223 aud rt sys init success. 2021-08-25 04:21:40.638 [INFO] database P0000014223 T0000000000000014223 systables desc init success. 2021-08-25 04:21:40.639 [INFO] database P0000014223 T0000000000000014223 ndct_db_load_info success. 2021-08-25 04:21:40.639 [INFO] database P0000014223 T0000000000000014223 nsvr_process_before_open begin. 2021-08-25 04:21:40.639 [INFO] database P0000014223 T0000000000000014223 Update DM8_DCT_VERSION from 20 to 20, rebuild dynamic tables begin... 2021-08-25 04:21:40.639 [INFO] database P0000014223 T0000000000000014223 Update DM8_DCT_VERSION from 20 to 20, rebuild dynamic tables end. 2021-08-25 04:21:40.694 [INFO] database P0000014223 T0000000000000014223 nsvr_process_before_open success. 2021-08-25 04:21:40.695 [INFO] database P0000014223 T0000000000000014245 total 0 active crash trx, pseg_crash_trx_rollbacksys_only(0) begin ... 2021-08-25 04:21:40.695 [INFO] database P0000014223 T0000000000000014245 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-25 04:21:40.695 [INFO] database P0000014223 T0000000000000014245 pseg_crash_trx_rollback end 2021-08-25 04:21:40.696 [INFO] database P0000014223 T0000000000000014223 backup control file /opt/dm/dmdbms/data/enmotech/dm.ctl to file /opt/dm/dmdbms/data/enmotech/dm_20210825042140_695822.ctl 2021-08-25 04:21:40.700 [INFO] database P0000014223 T0000000000000014223 backup control file /opt/dm/dmdbms/data/enmotech/dm.ctl to file /opt/dm/dmdbms/data/enmotech/ctl_bak/dm_20210825042140_699716.ctl succeed 2021-08-25 04:21:40.700 [INFO] database P0000014223 T0000000000000014223 local instance name is DMDB, mode is NORMAL, status is OPEN. 2021-08-25 04:21:40.700 [INFO] database P0000014223 T0000000000000014223 SYSTEM IS READY. 2021-08-25 04:21:40.700 [INFO] database P0000014223 T0000000000000014223 set g_dw_stat from UNDEFINED to NONE success, g_dw_recover_stop is 0 |
奇怪了。登陆数据库查一下看看情况。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SQL> select name,status$,TOTAL_SIZE,LAST_STARTUP_TIME from v$database; LINEID NAME STATUS$ TOTAL_SIZE LAST_STARTUP_TIME ---------- -------- ----------- -------------------- ---------------------------------------------------------------------------------------------------- 1 enmottch 4 656896 2021-08-25 04:21:40 used time: 4.755(ms). Execute id is 4. [dmdba@mogdb enmotech]$ strings SYSTEM.DBF|grep enmotech [dmdba@mogdb enmotech]$ strings SYSTEM.DBF|grep ENMOTECH [dmdba@mogdb enmotech]$ strings SYSTEM.DBF|grep ENMOTT [dmdba@mogdb enmotech]$ strings SYSTEM.DBF|grep enmott [dmdba@mogdb enmotech]$ |
可以看到数据库名称被修改了。似乎看上去类似Oracle的instance name,而非db name。 可见达梦数据库的数据库文件结构中并不会存数据库name;否则肯定是无法打开的。
这看上去似乎比Oracle controlfile 简单的多,在进行恢复时,处理起来就更简单了。。
查看文档发现dm提供了一个文件格式转换工具dmctlcvt,可以将控制文件转换成txt(或者反向转换),如下:
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 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
[dmdba@mogdb enmotech]$ dmctlcvt c2t dm.ctl dm_ctl.txt DMCTLCVT V8 convert ctl to txt success! [dmdba@mogdb enmotech]$ cat dm_ctl.txt ############################################################################## ## please do not adjust parameter order, ensure the ctl have no difference ### ########################################################################## # database name dbname=enmottch # server mode svr_mode=0 #OGUID oguid=0 # db server version version=117507966 # database version db_version=458763 # pseg version pseg_version=458762 #SGUID sguid=513858328 #NEXT_TS_ID next_ts_id=6 #RAC_NODES rac_nodes=1 #NEXT_HTS_ID next_htsid=129 #TIME_FLAG time_flag=170 #MDIR_FLAG mdir_flag=31 #STARTUP_CNT startup_cnt=11 #LAST_STARTUP_TIME last_startup_time=DATETIME '2021-8-25 4:21:40' #DM7_DCT_VERSION dm7_dct_version=8 #DM8_DCT_VERSION dm8_dct_version=20 #=============================================== #=============================================== # table space name ts_name=SYSTEM # table space ID ts_id=0 # table space status ts_state=0 # table space cache ts_cache= # DSC node number ts_nth=0 # table space create time ts_create_time=DATETIME '2021-5-26 2:6:28' # table space modify time ts_modify_time=DATETIME '2021-5-26 2:6:28' # table space encrypt flag ts_encrypt_flag=0 # table space copy num ts_copy_num=0 # table space region size flag ts_size_flag=0 #----------------------------------------------- # file path fil_path=/opt/dm/dmdbms/data/enmotech/SYSTEM.DBF # mirror path mirror_path= # file id fil_id=0 # whether the file is auto extend autoextend=1 # file create time fil_create_time=DATETIME '2021-5-26 2:6:28' # file modify time fil_modify_time=DATETIME '2021-5-26 2:6:28' # the max size of file fil_max_size=0 # next size of file fil_next_size=0 #=============================================== # table space name ts_name=ROLL # table space ID ts_id=1 # table space status ts_state=0 # table space cache ts_cache= # DSC node number ts_nth=0 # table space create time ts_create_time=DATETIME '2021-5-26 2:6:28' # table space modify time ts_modify_time=DATETIME '2021-5-26 2:6:28' # table space encrypt flag ts_encrypt_flag=0 # table space copy num ts_copy_num=0 # table space region size flag ts_size_flag=0 #----------------------------------------------- # file path fil_path=/opt/dm/dmdbms/data/enmotech/ROLL.DBF # mirror path mirror_path= # file id fil_id=0 # whether the file is auto extend autoextend=1 # file create time fil_create_time=DATETIME '2021-5-26 2:6:28' # file modify time fil_modify_time=DATETIME '2021-5-26 2:6:28' # the max size of file fil_max_size=0 # next size of file fil_next_size=0 #=============================================== # table space name ts_name=RLOG # table space ID ts_id=2 # table space status ts_state=0 # table space cache ts_cache= # DSC node number ts_nth=0 # table space create time ts_create_time=DATETIME '2021-5-26 2:6:28' # table space modify time ts_modify_time=DATETIME '2021-5-26 2:21:22' # table space encrypt flag ts_encrypt_flag=0 # table space copy num ts_copy_num=0 # table space region size flag ts_size_flag=0 #----------------------------------------------- # file path fil_path=/opt/dm/dmdbms/data/enmotech/enmotech01.log # mirror path mirror_path= # file id fil_id=0 # whether the file is auto extend autoextend=1 # file create time fil_create_time=DATETIME '2021-5-26 2:6:28' # file modify time fil_modify_time=DATETIME '2021-5-26 2:6:28' # the max size of file fil_max_size=0 # next size of file fil_next_size=0 # file path fil_path=/opt/dm/dmdbms/data/enmotech/enmotech02.log # mirror path mirror_path= # file id fil_id=1 # whether the file is auto extend autoextend=1 # file create time fil_create_time=DATETIME '2021-5-26 2:6:28' # file modify time fil_modify_time=DATETIME '2021-5-26 2:6:28' # the max size of file fil_max_size=0 # next size of file fil_next_size=0 # file path fil_path=/opt/dm/dmdbms/data/enmotech/enmotech03.log # mirror path mirror_path= # file id fil_id=2 # whether the file is auto extend autoextend=1 # file create time fil_create_time=DATETIME '2021-5-26 2:21:22' # file modify time fil_modify_time=DATETIME '2021-5-26 2:21:22' # the max size of file fil_max_size=0 # next size of file fil_next_size=0 #=============================================== # table space name ts_name=MAIN # table space ID ts_id=4 # table space status ts_state=0 # table space cache ts_cache= # DSC node number ts_nth=0 # table space create time ts_create_time=DATETIME '2021-5-26 2:6:28' # table space modify time ts_modify_time=DATETIME '2021-5-26 2:6:28' # table space encrypt flag ts_encrypt_flag=0 # table space copy num ts_copy_num=0 # table space region size flag ts_size_flag=0 #----------------------------------------------- # file path fil_path=/opt/dm/dmdbms/data/enmotech/MAIN.DBF # mirror path mirror_path= # file id fil_id=0 # whether the file is auto extend autoextend=1 # file create time fil_create_time=DATETIME '2021-5-26 2:6:28' # file modify time fil_modify_time=DATETIME '2021-5-26 2:6:28' # the max size of file fil_max_size=0 # next size of file fil_next_size=0 #=============================================== # table space name ts_name=ENMOTECH # table space ID ts_id=5 # table space status ts_state=0 # table space cache ts_cache=NORMAL # DSC node number ts_nth=0 # table space create time ts_create_time=DATETIME '2021-5-26 2:47:42' # table space modify time ts_modify_time=DATETIME '2021-8-25 5:53:30' # table space encrypt flag ts_encrypt_flag=0 # table space copy num ts_copy_num=0 # table space region size flag ts_size_flag=0 #----------------------------------------------- # file path fil_path=/opt/dm/dmdbms/data/enmotech/enmotech01.dbf # mirror path mirror_path= # file id fil_id=0 # whether the file is auto extend autoextend=1 # file create time fil_create_time=DATETIME '2021-5-26 2:47:42' # file modify time fil_modify_time=DATETIME '2021-5-26 2:47:42' # the max size of file fil_max_size=0 # next size of file fil_next_size=0 # file path fil_path=/opt/dm/dmdbms/data/enmotech/enmotech02.dbf # mirror path mirror_path= # file id fil_id=1 # whether the file is auto extend autoextend=1 # file create time fil_create_time=DATETIME '2021-8-25 5:53:30' # file modify time fil_modify_time=DATETIME '2021-8-25 5:53:30' # the max size of file fil_max_size=0 # next size of file fil_next_size=0 #=============================================== # HUGE table space name htsname=HMAIN # HUGE table space id htsid=128 #HUGE table space share flag htsflag=0 # HUGE table space copy num hts_copy_num=0 # HUGE table space region size flag hts_size_flag=0 # HUGE table space create time hts_create_time=DATETIME '2021-5-26 2:6:28' # HUGE table space modify time hts_modify_time=DATETIME '2021-5-26 2:6:28' # HUGE table space path htspath=/opt/dm/dmdbms/data/enmotech/HMAIN #=============================================== |
到这里我们就豁然开朗了,如果控制文件损坏,我们可以构造上述类似的txt文件即可,然后通过该工具进行反向转换成ctl文件即可。
实际上我们看到达梦数据库的控制文件内容极其简单,存放的内容很少。
1 2 3 |
[dmdba@mogdb enmotech]$ dmctlcvt t2c dm_ctl.txt dm_ctl_0825.ctl DMCTLCVT V8 convert txt to ctl success! |
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 |
SQL> select name,status$,TOTAL_SIZE,LAST_STARTUP_TIME from v$database; LINEID NAME STATUS$ TOTAL_SIZE LAST_STARTUP_TIME ---------- -------- ----------- -------------------- ---------------------------------------------------------------------------------------------------- 1 enmotech 4 656896 2021-08-25 00:47:16 used time: 1.359(ms). Execute id is 66. SQL> select ID,name,TYPE$,MAX_SIZE,TOTAL_SIZE,FILE_NUM,ENCRYPT_NAME from v$tablespace; LINEID ID NAME TYPE$ MAX_SIZE TOTAL_SIZE FILE_NUM ENCRYPT_NAME ---------- ----------- -------- ----------- -------------------- -------------------- ----------- ------------ 1 0 SYSTEM 1 0 2944 1 NULL 2 1 ROLL 1 0 59264 1 NULL 3 3 TEMP 2 2621440 131072 1 NULL 4 4 MAIN 1 0 18816 1 NULL 5 5 ENMOTECH 1 0 504064 1 NULL used time: 1.039(ms). Execute id is 71. SQL> select GROUP_ID,path,STATUS$,RW_STATUS,TOTAL_SIZE,FREE_SIZE,PAGE_SIZE,MAX_SIZE from v$datafile; LINEID GROUP_ID PATH STATUS$ RW_STATUS TOTAL_SIZE FREE_SIZE PAGE_SIZE MAX_SIZE ---------- ----------- ------------------------------------------- ----------- ----------- -------------------- -------------------- ----------- ----------- 1 0 /opt/dm/dmdbms/data/enmotech/SYSTEM.DBF 1 2 2944 2211 8192 16777215 2 1 /opt/dm/dmdbms/data/enmotech/ROLL.DBF 1 2 59264 58979 8192 16777215 3 3 /opt/dm/dmdbms/data/enmotech/TEMP.DBF 1 2 131072 131064 8192 16777215 4 4 /opt/dm/dmdbms/data/enmotech/MAIN.DBF 1 2 18816 1262 8192 16777215 5 5 /opt/dm/dmdbms/data/enmotech/enmotech01.dbf 1 2 504064 5624 8192 16777215 used time: 6.185(ms). Execute id is 111. SQL> SELECT ts.NAME, df.PATH FROM V$TABLESPACE AS ts, V$DATAFILE AS df WHERE ts.ID = df.GROUP_ID; LINEID NAME PATH ---------- -------- ------------------------------------------- 1 SYSTEM /opt/dm/dmdbms/data/enmotech/SYSTEM.DBF 2 ENMOTECH /opt/dm/dmdbms/data/enmotech/enmotech01.dbf 3 MAIN /opt/dm/dmdbms/data/enmotech/MAIN.DBF 4 TEMP /opt/dm/dmdbms/data/enmotech/TEMP.DBF 5 ROLL /opt/dm/dmdbms/data/enmotech/ROLL.DBF |
这里v$datafile.max_size单位时M,即对于默认值pagesize=8k的情况,dm数据库中单个数据文件最大为16777215M,即15TB。 这跟Oracle的机制完全不同,在Oracle数据库中
对于small tablespace而言,8k的blocksize,单个数据文件最大是32GB;如果是bigfile,8k的情况下可以达到32TB。
从这里来看,似乎DM数据库的文件存储类似Oracle Bigfile。 达梦数据库中还有一种叫HUGE表空间,及支持存列table,后面再进行测试。
3、对象分配和组成
在物理层面来看,一个表空间中可以存着多个用户,多个对象,这是逻辑层面。 在物理分配方面,当创建一个Table时,需要在datafile中分配空间,
分配的单位是簇,即簇是达梦的最小分配单元,默认值为16. 类似Oracle的extent。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
SQL> create table test0825_2 tablespace enmotech as select * from test0825; executed successfully used time: 00:00:02.084. Execute id is 114. SQL> select OWNER,SEGMENT_NAME,SEGMENT_TYPE,HEADER_FILE,HEADER_BLOCK,BYTES,BLOCKS,INITIAL_EXTENT,EXTENTS,TABLESPACE_NAME 2 from dba_segments where segment_name='TEST0825_2'; LINEID OWNER SEGMENT_NAME SEGMENT_TYPE HEADER_FILE HEADER_BLOCK BYTES BLOCKS INITIAL_EXTENT EXTENTS TABLESPACE_NAME ---------- ------ ------------ ------------ ----------- ------------ -------------------- -------------------- -------------------- -------------------- --------------- 1 SYSDBA TEST0825_2 TABLE 0 502864 143917056 17568 131072 1098 ENMOTECH used time: 205.897(ms). Execute id is 117. SQL> |
这里可以看到,我们刚刚新建的表test0825_2的初始分配簇大小为131072;其中131072/8192=16,说明默认一个簇大小就是16个page。一共分配了1098个簇。通过计算131072*1098刚好等于143917056,即表的大小。
继续看看相关跟Oracle的兼容性视图,能否有一些发现:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
SQL> alter table test0825_2 logging; executed successfully used time: 4.615(ms). Execute id is 207. SQL> select owner,table_name,tablespace_name,PCT_FREE,PCT_USED,PCT_INCREASE,LOGGING,SAMPLE_SIZE,LAST_ANALYZED,PARTITIONED,FREELISTS 2 ,COMPRESSION,SEGMENT_CREATED from dba_tables where table_name='TEST0825_2'; OWNER TABLE_NAME TABLESPACE_NAME PCT_FREE PCT_USED PCT_INCREASE LOGGING SAMPLE_SIZE LAST_ANALYZED PARTITIONED FREELISTS ------ ---------- --------------- -------- -------- ------------ ------- ----------- ---------------------------------------------------------------------------------------------------- ----------- --------- COMPRESSION SEGMENT_CREATED ----------- --------------- SYSDBA TEST0825_2 ENMOTECH NULL NULL NULL NULL NULL NULL NO NULL DISABLED NULL |
从上述结果来看,有点像为了兼容而兼容,看上去dba_Tables视图跟Oracle的dba_Tables 定义一样了;然而很多数据都没有的,毕竟结构不同。这里看居然有统计信息?
查看文档发现也有dbms_stats兼容包,用来收集统计信息看看:
1 2 3 4 5 6 7 8 9 10 11 12 |
SQL> DBMS_STATS.GATHER_TABLE_STATS('SYSDBA','TEST0825_2',null,100,TRUE,'FOR ALL COLUMNS SIZE AUTO'); DMSQL executed successfully used time: 00:00:03.224. Execute id is 218. SQL> select owner,table_name,NUM_ROWS,BLOCKS,EMPTY_BLOCKS,AVG_SPACE,CHAIN_CNT,AVG_ROW_LEN,SAMPLE_SIZE,LAST_ANALYZED,USER_STATS 2 from dba_tables where table_name='TEST0825_2'; OWNER TABLE_NAME NUM_ROWS BLOCKS EMPTY_BLOCKS AVG_SPACE CHAIN_CNT AVG_ROW_LEN SAMPLE_SIZE LAST_ANALYZED USER_STATS ------ ---------- -------- ------ ------------ --------- --------- ----------- ----------- ---------------------------------------------------------------------------------------------------- ---------- SYSDBA TEST0825_2 1494016 NULL NULL NULL NULL NULL 1494016 NULL NO used time: 18.752(ms). Execute id is 219. SQL> |
发现sample_size 确实更新了,不过last_analyzed居然还是为null。 看来这里兼容性做的还是有一些问题。 从这个统计信息收集来看,似乎有些问题。
4、关于ROWID
在Oracle数据库中我们都知道有一个有趣的结构,即ROWID,是由文件号,block,data object id和row number组成;rowid的结构也决定了Oracle
的一系列限制。那么在DM数据库中是否也存在ROWID呢 ?
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 |
SQL> select a.owner,a.object_name,a.rowid from test0825_2 a where rownum < 5; OWNER OBJECT_NAME ROWID ------------ ------------ -------------------- BENCHMARKSQL BENCHMARKSQL 1 CTISYS CTISYS 2 SYS SYS 3 SYSAUDITOR SYSAUDITOR 4 used time: 2.034(ms). Execute id is 223. SQL> select group_id,id,path,TOTAL_SIZE,FREE_SIZE from v$datafile; GROUP_ID ID PATH TOTAL_SIZE FREE_SIZE ----------- ----------- ------------------------------------------- -------------------- -------------------- 0 0 /opt/dm/dmdbms/data/enmotech/SYSTEM.DBF 2944 2195 1 0 /opt/dm/dmdbms/data/enmotech/ROLL.DBF 59264 58979 3 0 /opt/dm/dmdbms/data/enmotech/TEMP.DBF 131072 131058 4 0 /opt/dm/dmdbms/data/enmotech/MAIN.DBF 18816 1262 5 0 /opt/dm/dmdbms/data/enmotech/enmotech01.dbf 521728 5746 used time: 8.346(ms). Execute id is 227. SQL> select ID,name,MAX_SIZE,TOTAL_SIZE,FILE_NUM,COPY_NUM from v$tablespace; ID NAME MAX_SIZE TOTAL_SIZE FILE_NUM COPY_NUM ----------- -------- -------------------- -------------------- ----------- ----------- 0 SYSTEM 0 2944 1 NULL 1 ROLL 0 59264 1 NULL 3 TEMP 2621440 131072 1 NULL 4 MAIN 0 18816 1 NULL 5 ENMOTECH 0 521728 1 NULL used time: 1.498(ms). Execute id is 229. SQL> select owner,segment_name,TABLESPACE_NAME,HEADER_FILE,HEADER_BLOCK,RELATIVE_FNO 2 from dba_segments where segment_name='TEST0825_2'; OWNER SEGMENT_NAME TABLESPACE_NAME HEADER_FILE HEADER_BLOCK RELATIVE_FNO ------ ------------ --------------- ----------- ------------ ------------ SYSDBA TEST0825_2 ENMOTECH 0 502864 0 used time: 232.907(ms). Execute id is 230. SQL> alter tablespace enmotech add datafile '/opt/dm/dmdbms/data/enmotech/enmotech02.dbf' size 100; executed successfully used time: 17.012(ms). Execute id is 231. SQL> select group_id,id,path,TOTAL_SIZE,FREE_SIZE from v$datafile; GROUP_ID ID PATH TOTAL_SIZE FREE_SIZE ----------- ----------- ------------------------------------------- -------------------- -------------------- 0 0 /opt/dm/dmdbms/data/enmotech/SYSTEM.DBF 2944 2195 1 0 /opt/dm/dmdbms/data/enmotech/ROLL.DBF 59264 58979 3 0 /opt/dm/dmdbms/data/enmotech/TEMP.DBF 131072 131058 4 0 /opt/dm/dmdbms/data/enmotech/MAIN.DBF 18816 1262 5 0 /opt/dm/dmdbms/data/enmotech/enmotech01.dbf 521728 5746 5 1 /opt/dm/dmdbms/data/enmotech/enmotech02.dbf 12800 12799 6 rows got |
我们可以看到,达梦数据库中的ROWID并非真正的rowid;而且我们也可以看到,似乎所有数据文件的文件号初始值均为0;随着文件的增加,文件号开始递增。
5、关于数据文件的检测
达梦数据库提供了dmdbchk检测工具,可以检测数据库文件的完整性,类似Oracle dbv工具;不过dmdbchk 只能在数据库停止的情况下进行使用。
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 |
[dmdba@mogdb bin]$ dmdbchk --help [2021-08-25 06:29:52] dmdbchk V8 Invalid input --help Format: ./dmdbchk KEYWORD=value Example: ./dmdbchk path=/opt/dmdbms/bin/dm.ini Keyword Explanation -------------------------------------------------------------------------------- PATH the absolute path of dm.ini or in the current directory DCR_INI the path of dmdcr.ini HELP print help information START_INDEXID min indexid to check END_INDEXID max indexid to check CHECK_SEMA check os semaphore(1) or delete unused os semaphore(2), only for linux CHECK_SHM check os shared memory(1) or delete unused os shared memory(2), only for linux [dmdba@mogdb bin]$ dmdbchk path=/opt/dm/dmdbms/data/enmotech/dm.ini [2021-08-25 06:27:40] dmdbchk V8 [2021-08-25 06:27:40] file dm.key not found, use default license! Can not open ini file dmdcr.ini! ndct db load finished [2021-08-25 06:27:40] DM DB CHECK START...... [2021-08-25 06:27:40] --------check dbf file size start--------- [2021-08-25 06:27:40] FILE=(ts_id=0, fil_id=0, path=/opt/dm/dmdbms/data/enmotech/SYSTEM.DBF) [2021-08-25 06:27:40] FILE=(ts_id=1, fil_id=0, path=/opt/dm/dmdbms/data/enmotech/ROLL.DBF) [2021-08-25 06:27:40] FILE=(ts_id=4, fil_id=0, path=/opt/dm/dmdbms/data/enmotech/MAIN.DBF) [2021-08-25 06:27:40] FILE=(ts_id=5, fil_id=0, path=/opt/dm/dmdbms/data/enmotech/enmotech01.dbf) [2021-08-25 06:27:40] FILE=(ts_id=5, fil_id=1, path=/opt/dm/dmdbms/data/enmotech/enmotech02.dbf) [2021-08-25 06:27:40] --------check dbf file size end----------- [2021-08-25 06:27:40] --------check indexes start--------------- [2021-08-25 06:27:40] INDEX=(id=33554433, name=SYSINDEXCOLUMNS, table_name=SYSCOLUMNS) [2021-08-25 06:27:40] INDEX=(id=33554434, name=SYSINDEXINDEXES, table_name=SYSINDEXES) [2021-08-25 06:27:40] INDEX=(id=33554440, name=SYSINDEXTUSERS, table_name=SYSUSER$) [2021-08-25 06:27:40] INDEX=(id=33554442, name=SYSINDEXSYSGRANTS, table_name=SYSGRANTS) [2021-08-25 06:27:40] INDEX=(id=33554452, name=SYSINDEXCONSTRAINTS, table_name=SYSCONS) [2021-08-25 06:27:40] INDEX=(id=33554458, name=SYSINDEXSYSAUDIT, table_name=SYSAUDIT) [2021-08-25 06:27:40] INDEX=(id=33554459, name=SYSINDEXSYSAUDITSQLSEQ, table_name=SYSAUDITSQLSEQ) [2021-08-25 06:27:40] INDEX=(id=33554464, name=SYSINDEXCONTEXTINDEXES, table_name=SYSCONTEXTINDEXES) [2021-08-25 06:27:40] INDEX=(id=33554468, name=SYSINDEXSTATS, table_name=SYSSTATS) [2021-08-25 06:27:40] INDEX=(id=33554489, name=SYSINDEXSPWDCHGS, table_name=SYSPWDCHGS) [2021-08-25 06:27:40] INDEX=(id=33554498, name=SYSINDEXSYSAUDITRULES, table_name=SYSAUDITRULES) [2021-08-25 06:27:40] INDEX=(id=33554510, name=SYSINDEXCONTEXTLIBS, table_name=SYSCONTEXTLIBS) [2021-08-25 06:27:40] INDEX=(id=33554539, name=SYSINDEXCLASSES, table_name=SYSCLASSES) [2021-08-25 06:27:40] INDEX=(id=33554540, name=SYSINDEXSYSOBJECTS, table_name=SYSOBJECTS) [2021-08-25 06:27:40] INDEX=(id=33554541, name=SYSINDEXSYSDUAL, table_name=SYSDUAL) [2021-08-25 06:27:40] INDEX=(id=33554543, name=SYSINDEXSYSTEXTS, table_name=SYSTEXTS) [2021-08-25 06:27:40] INDEX=(id=33554544, name=SYSINDEXSYSTYPEINFOS, table_name=SYSTYPEINFOS) [2021-08-25 06:27:40] INDEX=(id=33554546, name=SYSINDEXSYSACCHISTORIES, table_name=SYSACCHISTORIES) [2021-08-25 06:27:40] INDEX=(id=33554548, name=SYSINDEXSYSHPARTTABLEINFO, table_name=SYSHPARTTABLEINFO) [2021-08-25 06:27:40] INDEX=(id=33554549, name=SYSINDEXMACPLYS, table_name=SYSMACPLYS) [2021-08-25 06:27:40] INDEX=(id=33554550, name=SYSINDEXMACLVLS, table_name=SYSMACLVLS) [2021-08-25 06:27:40] INDEX=(id=33554551, name=SYSINDEXMACCOMPS, table_name=SYSMACCOMPS) [2021-08-25 06:27:40] INDEX=(id=33554552, name=SYSINDEXMACGRPS, table_name=SYSMACGRPS) [2021-08-25 06:27:40] INDEX=(id=33554553, name=SYSINDEXMACLABELS, table_name=SYSMACLABELS) [2021-08-25 06:27:40] INDEX=(id=33554554, name=SYSINDEXMACTABPLY, table_name=SYSMACTABPLY) [2021-08-25 06:27:40] INDEX=(id=33554555, name=SYSINDEXMACUSRPLY, table_name=SYSMACUSRPLY) [2021-08-25 06:27:40] INDEX=(id=33554556, name=SYSINDEXSYSOBJINFOS, table_name=SYSOBJINFOS) [2021-08-25 06:27:40] INDEX=(id=33554559, name=SYSINDEXCOLCYT, table_name=SYSCOLCYT) [2021-08-25 06:27:40] INDEX=(id=33554560, name=SYSINDEXMACOBJ, table_name=SYSMACOBJ) [2021-08-25 06:27:40] INDEX=(id=33554561, name=SYSINDEXSYSRESOURCES, table_name=SYSRESOURCES) [2021-08-25 06:27:40] INDEX=(id=33554562, name=SYSINDEXTABLECOMMENTS, table_name=SYSTABLECOMMENTS) [2021-08-25 06:27:40] INDEX=(id=33554563, name=SYSINDEXCOLUMNCOMMENTS, table_name=SYSCOLUMNCOMMENTS) [2021-08-25 06:27:40] INDEX=(id=33554564, name=SYSINDEXSYSREWRITE, table_name=SYS_REWRITE_EQUIVALENCES) [2021-08-25 06:27:40] INDEX=(id=33554565, name=SYSINDEXSYSDISTABLEINFO, table_name=SYSDISTABLEINFO) [2021-08-25 06:27:40] INDEX=(id=33554566, name=RINDEXSYSCONS, table_name=SYSCONS) [2021-08-25 06:27:40] INDEX=(id=33554567, name=FINDEXSYSCONS, table_name=SYSCONS) [2021-08-25 06:27:40] INDEX=(id=33554568, name=SYSINDEXCOLINFOS, table_name=SYSCOLINFOS) [2021-08-25 06:27:40] INDEX=(id=33554569, name=SYSINDEXSYSDEPENDENCIES, table_name=SYSDEPENDENCIES) [2021-08-25 06:27:40] INDEX=(id=33554570, name=RINDSYSDEPENDENCIES, table_name=SYSDEPENDENCIES) [2021-08-25 06:27:40] INDEX=(id=33554571, name=SYSINDEXFREQROOTS, table_name=SYSFREQROOTS) [2021-08-25 06:27:40] INDEX=(id=33554572, name=SYSINDEXTABLECOMMENTSKEYS, table_name=SYSTABLECOMMENTS) [2021-08-25 06:27:40] INDEX=(id=33554573, name=SYSINDEXCOLUMNCOMMENTSKEYS, table_name=SYSCOLUMNCOMMENTS) [2021-08-25 06:27:40] INDEX=(id=33554574, name=SYSINDEXSYSUSERINI$, table_name=SYSUSERINI$) [2021-08-25 06:27:40] INDEX=(id=33554575, name=SYSINDEXSYSINJECTHINT, table_name=SYSINJECTHINT) [2021-08-25 06:27:40] INDEX=(id=33554576, name=SYSINDEXIDSYSOBJECTS, table_name=SYSOBJECTS) [2021-08-25 06:27:40] INDEX=(id=33554577, name=SYSINDEXSYSDUAL2, table_name=SYSDUAL2) [2021-08-25 06:27:40] INDEX=(id=33554578, name=SYSINDEXMSTATS, table_name=SYSMSTATS) [2021-08-25 06:27:40] INDEX=(id=33554579, name=SYSINDEXOPENHISTORY, table_name=SYSOPENHISTORY) [2021-08-25 06:27:40] INDEX=(id=33554580, name=SYSINDEXSYSSTATPREFS, table_name=SYSSTATPREFS) [2021-08-25 06:27:40] INDEX=(id=33554581, name=SYSINDEXSYSSTATTABLEIDU, table_name=SYSSTATTABLEIDU) [2021-08-25 06:27:40] INDEX=(id=33555432, name=INDEX33555432, table_name=SYSMACPLYS) [2021-08-25 06:27:40] INDEX=(id=33555433, name=SYSINDEXPIDIDSYSOBJECTS, table_name=SYSOBJECTS) [2021-08-25 06:27:40] INDEX=(id=33555434, name=SECOND_INDXE_SYS_REWRITE_EQUIVALENCES_X7Q1, table_name=SYS_REWRITE_EQUIVALENCES) [2021-08-25 06:27:40] INDEX=(id=33555435, name=INDEX33555435, table_name=SYSAUDITSQLSEQ) [2021-08-25 06:27:40] INDEX=(id=33555438, name=SYSINDEXPARTTIDSYSHPARTTABLEINFO, table_name=SYSHPARTTABLEINFO) [2021-08-25 06:27:40] INDEX=(id=33555441, name=INDEX33555441, table_name=POLICY_GROUPS) [2021-08-25 06:27:40] INDEX=(id=33555442, name=INDEX33555442, table_name=POLICIES) [2021-08-25 06:27:40] INDEX=(id=33555443, name=INDEX33555443, table_name=POLICY_CONTEXTS) [2021-08-25 06:27:40] INDEX=(id=33555444, name=INDEX33555444, table_name=DBMS_LOCK_ALLOCATED) [2021-08-25 06:27:40] INDEX=(id=33555445, name=INDEX33555445, table_name=DBMS_ALERT_INFO) [2021-08-25 06:27:40] INDEX=(id=33555446, name=INDEX33555446, table_name=AQ$_QUEUE_TABLES) [2021-08-25 06:27:40] INDEX=(id=33555447, name=INDEX33555447, table_name=AQ$_QUEUES) [2021-08-25 06:27:40] INDEX=(id=33555448, name=INDEX33555448, table_name=AQ$_QUEUES) [2021-08-25 06:27:40] INDEX=(id=33555449, name=INDEX33555449, table_name=AQ$_QUEUES) [2021-08-25 06:27:40] INDEX=(id=33555451, name=INDEX33555451, table_name=REG$) [2021-08-25 06:27:40] INDEX=(id=33555452, name=INDEX33555452, table_name=BMSQL_CONFIG) [2021-08-25 06:27:40] INDEX=(id=33555453, name=INDEX33555453, table_name=BMSQL_CONFIG) [2021-08-25 06:27:40] INDEX=(id=33555454, name=INDEX33555454, table_name=BMSQL_WAREHOUSE) [2021-08-25 06:27:40] INDEX=(id=33555455, name=INDEX33555455, table_name=BMSQL_DISTRICT) [2021-08-25 06:27:40] INDEX=(id=33555456, name=INDEX33555456, table_name=BMSQL_CUSTOMER) [2021-08-25 06:27:53] INDEX=(id=33555457, name=INDEX33555457, table_name=BMSQL_HISTORY) [2021-08-25 06:27:55] INDEX=(id=33555458, name=INDEX33555458, table_name=BMSQL_NEW_ORDER) [2021-08-25 06:27:55] INDEX=(id=33555459, name=INDEX33555459, table_name=BMSQL_OORDER) [2021-08-25 06:27:57] INDEX=(id=33555460, name=INDEX33555460, table_name=BMSQL_ORDER_LINE) [2021-08-25 06:28:14] INDEX=(id=33555461, name=INDEX33555461, table_name=BMSQL_ITEM) [2021-08-25 06:28:14] INDEX=(id=33555462, name=INDEX33555462, table_name=BMSQL_STOCK) [2021-08-25 06:28:28] INDEX=(id=33555463, name=INDEX33555463, table_name=TEST) [2021-08-25 06:28:29] INDEX=(id=33555464, name=INDEX33555464, table_name=BMSQL_WAREHOUSE) [2021-08-25 06:28:29] INDEX=(id=33555465, name=INDEX33555465, table_name=BMSQL_DISTRICT) [2021-08-25 06:28:29] INDEX=(id=33555466, name=INDEX33555466, table_name=BMSQL_CUSTOMER) [2021-08-25 06:28:29] INDEX=(id=33555467, name=BMSQL_CUSTOMER_IDX1, table_name=BMSQL_CUSTOMER) [2021-08-25 06:28:29] INDEX=(id=33555468, name=INDEX33555468, table_name=BMSQL_OORDER) [2021-08-25 06:28:30] INDEX=(id=33555469, name=BMSQL_OORDER_IDX1, table_name=BMSQL_OORDER) [2021-08-25 06:28:30] INDEX=(id=33555470, name=INDEX33555470, table_name=BMSQL_NEW_ORDER) [2021-08-25 06:28:30] INDEX=(id=33555471, name=INDEX33555471, table_name=BMSQL_ORDER_LINE) [2021-08-25 06:28:39] INDEX=(id=33555472, name=INDEX33555472, table_name=BMSQL_STOCK) [2021-08-25 06:28:40] INDEX=(id=33555473, name=INDEX33555473, table_name=BMSQL_ITEM) [2021-08-25 06:28:40] INDEX=(id=33555484, name=INDEX33555484, table_name=DEPT) [2021-08-25 06:28:40] INDEX=(id=33555485, name=INDEX33555485, table_name=DEPT) [2021-08-25 06:28:40] INDEX=(id=33555486, name=INDEX33555486, table_name=DEPT) [2021-08-25 06:28:40] INDEX=(id=33555487, name=INDEX33555487, table_name=EMP) [2021-08-25 06:28:40] INDEX=(id=33555488, name=INDEX33555488, table_name=EMP) [2021-08-25 06:28:40] INDEX=(id=33555490, name=INDEX33555490, table_name=TAB_HASH) [2021-08-25 06:28:40] INDEX=(id=33555491, name=INDEX33555491_33555490, table_name=TAB_HASH_P1) [2021-08-25 06:28:40] INDEX=(id=33555492, name=INDEX33555492_33555490, table_name=TAB_HASH_P2) [2021-08-25 06:28:40] INDEX=(id=33555493, name=INDEX33555493_33555490, table_name=TAB_HASH_P3) [2021-08-25 06:28:40] INDEX=(id=33555494, name=INDEX33555494, table_name=TAB_LIST) [2021-08-25 06:28:40] INDEX=(id=33555495, name=INDEX33555495_33555494, table_name=TAB_LIST_EUROPE) [2021-08-25 06:28:40] INDEX=(id=33555496, name=INDEX33555496_33555494, table_name=TAB_LIST_ASIA) [2021-08-25 06:28:40] INDEX=(id=33555497, name=INDEX33555497_33555494, table_name=TAB_LIST_AMERICAS) [2021-08-25 06:28:40] INDEX=(id=33555498, name=INDEX33555498, table_name=TAB_PART) [2021-08-25 06:28:40] INDEX=(id=33555499, name=INDEX33555499_33555498, table_name=TAB_PART_P_20210401) [2021-08-25 06:28:40] INDEX=(id=33555500, name=INDEX33555500_33555498, table_name=TAB_PART_P_20210402) [2021-08-25 06:28:40] INDEX=(id=33555501, name=INDEX33555501_33555498, table_name=TAB_PART_P_MAX) [2021-08-25 06:28:40] INDEX=(id=33555502, name=INDEX33555502, table_name=T1) [2021-08-25 06:28:40] INDEX=(id=33555503, name=INDEX33555503, table_name=T2) [2021-08-25 06:28:40] INDEX=(id=33555506, name=INDEX33555506, table_name=TEST0825) [2021-08-25 06:28:40] INDEX=(id=33555507, name=INDEX33555507, table_name=TEST0825_2) [2021-08-25 06:28:40] --------check indexes end----------------- [2021-08-25 06:28:40] --------check iid start------------------- [2021-08-25 06:28:40] check cons id ... [2021-08-25 06:28:40] check index id ... [2021-08-25 06:28:40] check table id ... [2021-08-25 06:28:40] check proc id ... [2021-08-25 06:28:40] check schema id ... [2021-08-25 06:28:40] check synonym id ... [2021-08-25 06:28:40] check user id ... [2021-08-25 06:28:40] --------check iid end--------------------- [2021-08-25 06:28:40] DM DB CHECK END...... [2021-08-25 06:28:40] error count is 0 |
我们可以看到,该工具主要是检测数据文件,不包括temp文件和redo文件以及控制文件。
最后通过od -x来看看达梦的数据库文件头的情况:
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 |
[dmdba@mogdb enmotech]$ od -x -N 128 enmotech02.dbf 0000000 0005 0001 0000 0000 ffff ffff ffff ffff 0000020 ffff ffff 0013 0000 0000 0000 8a65 02b1 0000040 0000 0000 0000 0000 0000 0000 0000 0000 * 0000200 [dmdba@mogdb enmotech]$ od -x -N 128 enmotech01.dbf 0000000 0005 0000 0000 0000 ffff ffff ffff ffff 0000020 ffff ffff 0013 0000 0000 0000 8a65 02b1 0000040 0000 0000 0000 0000 0000 0000 0001 0000 0000060 0000 0009 0000 0024 0000 0009 0000 0024 0000100 0001 0000 0000 0008 0000 0024 0000 0008 0000120 0000 0024 0001 0000 0001 0000 0000 00b4 0000140 0001 0000 0000 00b4 0100 0000 0000 0000 0000160 0000 0094 0001 0000 0000 0094 0000 0000 0000200 [dmdba@mogdb enmotech]$ od -x -N 128 enmotech02.dbf 0000000 0005 0001 0000 0000 ffff ffff ffff ffff 0000020 ffff ffff 0013 0000 0000 0000 8a65 02b1 0000040 0000 0000 0000 0000 0000 0000 0000 0000 * 0000200 [dmdba@mogdb enmotech]$ od -x -N 128 SYSTEM.DBF 0000000 0000 0000 0000 0000 ffff ffff ffff ffff 0000020 ffff ffff 0013 0000 0000 0000 883e 02b1 0000040 0000 0000 0000 0000 0000 0000 0001 0000 0000060 0000 000a 0000 0024 0000 000a 0000 0024 0000100 0002 0000 0000 0008 0000 0024 0000 0009 0000120 0000 0024 0000 0000 ffff ffff ffff ffff 0000140 ffff ffff ffff ffff 0001 0000 0000 0000 0000160 0000 0094 0000 0000 0000 0094 0120 0000 0000200 |
不难看出前面2个偏移量是表空间编号.
最后简单总结一下:
1、达梦的物理文件结构也分为system、user表空间,回滚段表空间(类似Undo)以及temp表空间;也存在redo log和控制文件;
2、达梦的控制文件中的数据库名称并非类似Oracle一样的db name,和instance name类似;
3、达梦数据库的数据文件头部中并不会存放数据库名称。
4、一个表空间可以存放多个数据文件;每个表空间的文件号从0开始进行递增。
5、单个数据文件最大为15tb(默认pagesize 8k的情况下),类似Oracle bigfile。
6、从官方手册来看,达梦数据库也是有类似Oracle ASM的功能,即DMASM,后面再进行测试研究。
猜想一下,由于上述这些文件结构的特点,dm数据库的异常恢复,我认为应该是较为简单的。
Leave a Reply
You must be logged in to post a comment.