DM8 DSC备份还原

1、 检查磁盘空间

检查服务器磁盘空间使用情况,确认磁盘有充足的空间存放物理备份。

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 查看磁盘空间使用情况(备份在端点0,此处检查端点0) su - dmdba [dmdba@centos-04 ~]$ df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 46G 18G 29G 38% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 9.3M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 197M 149M 49M 76% /boot tmpfs 380M 12K 380M 1% /run/user/42 tmpfs 380M 0 380M 0% /run/user/0 |

2、 检查 dmap服务状态

检查数据库dmap服务运行状态,确认管道服务dmap已正常开启。

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1)确定dmap服务状态: [dmdba@centos-04 ~]$ ps -ef|grep dmap|grep -v grep dmdba 960 1 0 23:39 ? 00:00:01 /dm/dmdbms/dm8/dm8/bin/dmap 注意:未启动则执行步骤2命令手动开启 2)开启dmap服务: su - dmdba cd /dm/dmdbms/dm8/bin ./DmAPService start |

3、 检查 归档状态

检查数据库归档情况,确认数据库归档已正常开启。

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1)检查归档是否已开启: SQL> select * from vdm_ini where para_name = 'ARCH_INI'; 行号 PARA_NAME PARA_VALUE MIN_VALUE MAX_VALUE MPP_CHK SESS_VALUE FILE_VALUE DESCRIPTION PARA_TYPE ---------- --------- ---------- --------- --------- ------- ---------- ---------- ----------- --------- 1 ARCH_INI 1 0 1 N 1 1 dmarch.ini SYS 2)检查归档配置信息: SQL\> select \* from VDM_ARCH_INI; 行号 ARCH_NAME ARCH_TYPE ARCH_DEST ARCH_FILE_SIZE ARCH_SPACE_LIMIT ARCH_HANG_FLAG ---------- --------------- --------- -------------------------------------- -------------- ---------------- -------------- ARCH_TIMER_NAME ARCH_IS_VALID ARCH_WAIT_APPLY ARCH_INCOMING_PATH ARCH_CURR_DEST --------------- ------------- --------------- --------------------------------------- -------------------------------------- 1 ARCHIVE_LOCAL1 LOCAL /dm/dmarch/cbdsc/LOCAL_ARCH_cbdsc_DSC0 512 102400 1 NULL Y NULL NULL /dm/dmarch/cbdsc/LOCAL_ARCH_cbdsc_DSC0 2 ARCHIVE_REMOTE1 REMOTE CBDSC_DSC1 512 102400 1 NULL Y NULL /dm/dmarch/cbdsc/REMOTE_ARCH_cbdsc_DSC1 CBDSC_DSC1 3)检查归档日志文件: SQL>select * from V$ARCHIVED_LOG; |

4、做一次全备和增量备份

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1)模拟备份前写数据 #disql sysdba/dameng123 CREATE TABLE TAB_FOR_RECOVER(C1 INT,create_time datetime); BEGIN FOR I IN 1..100 LOOP INSERT INTO TAB_FOR_RECOVER VALUES(I,sysdate); COMMIT; END LOOP; END; / SQL> select count(*) from TAB_FOR_RECOVER; 行号 COUNT(*) ---------- -------------------- 1 100 2)做一次全备 BACKUP DATABASE TO WEEKLY_FULL_BAK BACKUPSET '/dm/dmback/db_fullbak_01' DEVICE TYPE DISK BACKUPINFO 'db_fullbak' MAXPIECESIZE 300 COMPRESSED LEVEL 1 PARALLEL 4; [dmdba@centos-04 cbdsc1_config]$ ls -rlt /dm/dmback/db_fullbak_01/ 总用量 260 drwxr-xr-x. 2 dmdba dinstall 61 7月 19 22:43 db_fullbak_01_0 drwxr-xr-x. 2 dmdba dinstall 61 7月 19 22:43 db_fullbak_01_2 drwxr-xr-x. 2 dmdba dinstall 61 7月 19 22:43 db_fullbak_01_1 -rw-r--r--. 1 dmdba dinstall 5632 7月 19 22:43 db_fullbak_01.bak -rw-r--r--. 1 dmdba dinstall 256000 7月 19 22:43 db_fullbak_01.meta 3)模拟写入增量数据做增量备份 端点0: #disql sysdba/dameng123 BEGIN FOR I IN 101..200 LOOP INSERT INTO TAB_FOR_RECOVER VALUES(I,sysdate); COMMIT; END LOOP; END; / SQL> alter system switch logfile; 操作已执行 SQL> select checkpoint(100); 行号 CHECKPOINT(100) ---------- --------------- 1 0 端点1: #disql sysdba/dameng123 BEGIN FOR I IN 201..300 LOOP INSERT INTO TAB_FOR_RECOVER VALUES(I,sysdate); COMMIT; END LOOP; END; / SQL> alter system switch logfile; 操作已执行 SQL> select checkpoint(100); 行号 CHECKPOINT(100) ---------- --------------- 1 0 |

5、 检查备份文件 和归档 有效性

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1)检查备份文件 [dmdba@centos-04 ~]$ cd /dm/dmback/db_fullbak_01 [dmdba@centos-04 db_fullbak_01]$ ls -rlt 总用量 260 drwxr-xr-x. 2 dmdba dinstall 61 7月 19 22:43 db_fullbak_01_0 drwxr-xr-x. 2 dmdba dinstall 61 7月 19 22:43 db_fullbak_01_2 drwxr-xr-x. 2 dmdba dinstall 61 7月 19 22:43 db_fullbak_01_1 -rw-r--r--. 1 dmdba dinstall 5632 7月 19 22:43 db_fullbak_01.bak -rw-r--r--. 1 dmdba dinstall 256000 7月 19 22:43 db_fullbak_01.meta 2)检查备份文件有效性情况: su - dmdba cd /dm/dmdbms/dm8/bin/ ./dmrman dcr_ini=/dm/dmdbms/dm8/dsc_config/cbdsc_DSC0/dmdcr0.ini #校验全备 RMAN> check backupset '/dm/dmback/db_fullbak_01'; check backupset '/dm/dmback/db_fullbak_01'; CMD END.CODE:[0] check backupset successfully. #表示备份校验成功 time used: 295.941(ms) #校验增备 RMAN> check backupset '/dm/dmback/db_increment_bak_02'; check backupset '/dm/dmback/db_increment_bak_02'; CMD END.CODE:[0] check backupset successfully. #表示备份校验成功 time used: 125.937(ms) 3)校验归档有效性 [dmdba@centos-04 0719_arch]$ dmrachk ARCH_PATH=/dm/dmarch/0719_arch rachk V8 the database pmnt_magic: 1661664700 the database db_magic: 429043589 /*******************************************************************/ ... 归档文件/dm/dmarch/0719_arch/ARCH_REMOTE1_0x1992AF85[1]_2023-07-19_23-54-25.log明细. version : 0x7006 status : INACTIVE enc_flag : FALSE n_rpkgs : 4 pmnt_magic : 1661664700 db_magic : 429043589 src_db_magic : 429043589 arch_lsn : 149651 arch_seq : 2848 clsn : 154729 next_seq : 2851 g_next_seq : 2851 file len : 521728 file free : 521728 dsc seqno : 1 dsc node : 2 create time : 2023-07-19 23:50:26.638211 close time : 2023-07-19 23:54:56.021349 /*******************************************************************/ 概要(节点[1]): 总计: 11 个文件 正确: 11 个文件 错误: 0 个文件 重复: 0 个文件 the rachk tool running cost 122.962 ms #检查未出现错误或归档不连续问题 |

6、 关闭数据库

|----------------------------------------------------------------------------------------------------------------------------------|
| su - dmdba cd /dm/dmdbms/dm8/bin #登录监视器关闭数据库服务 [dmdba@centos-04 bin]$ dmcssm ep stop GRP_DSC #检查数据库服务状态 ps --ef|grep dmserver |

7、 还原 备份

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| su - dmdba cd /dm/dmdbms/dm8/bin ./dmrman dcr_ini=/dm/dmdbms/dm8/dsc_config/cbdsc_DSC0/dmdcr0.ini #直接restore增量备份会自动去找全备还原 RMAN> restore database '/dm/dmdbms/dm8/dsc_config/cbdsc_DSC0/dm.ini' from backupset '/dm/dmback/db_increment_bak_02' TASK THREAD 2; restore database '/dm/dmdbms/dm8/dsc_config/cbdsc_DSC0/dm.ini' from backupset '/dm/dmback/db_increment_bak_02' TASK THREAD 2; file dm.key not found, use default license! Read ini warning, default backup path [/dm/dmback/cbdsc_DSC0] does not exist. checking if the DSC database under system path [+DMDATA/data/cbdsc_DSC] is running with vote disk.... EP [0] is checking.... EP [1] is checking.... RESTORE DATABASE CHECK...... RESTORE DATABASE,dbf collect...... RESTORE DATABASE,dbf refresh ...... RESTORE BACKUPSET [/dm/dmback/db_fullbak_01/db_fullbak_01_0] START...... total 1 packages processed... RESTORE BACKUPSET [/dm/dmback/db_fullbak_01/db_fullbak_01_2] START...... total 1 packages processed... RESTORE BACKUPSET [/dm/dmback/db_fullbak_01/db_fullbak_01_1] START...... total 1 packages processed... total 11 packages processed... RESTORE BACKUPSET [/dm/dmback/db_increment_bak_02] START...... total 19 packages processed... total 20 packages processed... RESTORE DATABASE,UPDATE ctl file...... RESTORE DATABASE,REBUILD key file...... RESTORE DATABASE,CHECK db info...... RESTORE DATABASE,UPDATE db info...... total 20 packages processed... total 20 packages processed! CMD END.CODE:[0] restore successfully. time used: 00:00:08.764 将端点0和端点1增量备份之后的归档都拷贝端点0的/dm/dmarch/0719_arch目录 #应用增量备份之后的归档日志 [dmdba@centos-04 0719_arch]$ RMAN> recover database '/dm/dmdbms/dm8/dsc_config/cbdsc_DSC0/dm.ini' with archivedir '/dm/dmarch/0719_arch'; recover database '/dm/dmdbms/dm8/dsc_config/cbdsc_DSC0/dm.ini' with archivedir '/dm/dmarch/0719_arch'; file dm.key not found, use default license! Read ini warning, default backup path [/dm/dmback/cbdsc_DSC0] does not exist. checking if the DSC database under system path [+DMDATA/data/cbdsc_DSC] is running with vote disk.... EP [0] is checking.... EP [1] is checking.... Database mode = 0, oguid = 0 EP[0]'s cur_lsn[147407] EP[1]'s cur_lsn[147407] EP[0] adjust cur_lsn from [147407] to [147407] EP:1 total 1 pkgs applied, percent: 11% EP:1 total 2 pkgs applied, percent: 22% EP:0 total 22 pkgs applied, percent: 10% EP:0 total 44 pkgs applied, percent: 20% EP:0 total 66 pkgs applied, percent: 30% EP:0 total 88 pkgs applied, percent: 40% EP:0 total 110 pkgs applied, percent: 50% EP:1 total 3 pkgs applied, percent: 33% EP:1 total 4 pkgs applied, percent: 44% EP:1 total 5 pkgs applied, percent: 55% EP:0 total 132 pkgs applied, percent: 60% EP:0 total 154 pkgs applied, percent: 70% EP:0 total 176 pkgs applied, percent: 80% EP:0 total 198 pkgs applied, percent: 90% EP:0 total 218 pkgs applied, percent: 100% EP:1 total 6 pkgs applied, percent: 66% EP:1 total 7 pkgs applied, percent: 77% EP:1 total 8 pkgs applied, percent: 88% EP:1 total 9 pkgs applied, percent: 100% Recover from archive log finished, time used:6.845s. EP(0) slot ctl page(1, 0, 16) trxid[35534], pseg_state[0] EP(1) slot ctl page(1, 0, 17) trxid[35111], pseg_state[0] EP[0]'s apply_lsn[154729] >= end_lsn[147408] EP[1]'s apply_lsn[154729] >= end_lsn[147407] recover successfully! time used: 00:00:13.314 #更新db_magic RMAN> recover database '/dm/dmdbms/dm8/dsc_config/cbdsc_DSC0/dm.ini' update db_magic; recover database '/dm/dmdbms/dm8/dsc_config/cbdsc_DSC0/dm.ini' update db_magic; Read ini warning, default backup path [/dm/dmback/cbdsc_DSC0] does not exist. checking if the DSC database under system path [+DMDATA/data/cbdsc_DSC] is running with vote disk.... EP [0] is checking.... EP [1] is checking.... Database mode = 0, oguid = 0 EP[0]'s cur_lsn[154729] EP[1]'s cur_lsn[154729] EP[0] adjust cur_lsn from [154729] to [154729] EP[0]'s apply_lsn[154729] >= end_lsn[147408] EP[1]'s apply_lsn[154729] >= end_lsn[147407] EP(0) slot ctl page(1, 0, 16) trxid[35534], pseg_state[0] EP(1) slot ctl page(1, 0, 17) trxid[35111], pseg_state[0] recover successfully! time used: 00:00:07.153 |

8、 启动数据库

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| su - dmdba cd /dm/dmdbms/dm8/bin #进入监视器启动数据库服务 ./dmcssm ep startup GRP_DSC #查看集群和数据库相关状态 show [monitor] 2023-07-20 00:17:31: Wait CSS Control Node choosed succeed. monitor current time:2023-07-20 00:17:31, n_group:3 =================== group[name = GRP_CSS, seq = 0, type = CSS, Control Node = 0] ======================================== [CSS0] global info: [ASM0] auto restart = TRUE [cbdsc_DSC0] auto restart = FALSE [CSS1] global info: [ASM1] auto restart = TRUE [cbdsc_DSC1] auto restart = FALSE ep: css_time inst_name seqno port mode inst_status vtd_status is_ok active guid ts 2023-07-20 00:17:30 CSS0 0 1286 Control Node OPEN WORKING OK TRUE 923599632 923601713 2023-07-20 00:17:30 CSS1 1 1286 Normal Node OPEN WORKING OK TRUE 923601282 923603361 =================== group[name = GRP_ASM, seq = 1, type = ASM, Control Node = 0] ======================================== n_ok_ep = 2 ok_ep_arr(index, seqno): (0, 0) (1, 1) sta = OPEN, sub_sta = STARTUP break ep = NULL recover ep = NULL crash process over flag is TRUE ep: css_time inst_name seqno port mode inst_status vtd_status is_ok active guid ts 2023-07-20 00:17:30 ASM0 0 1276 Control Node OPEN WORKING OK TRUE 923630562 923632562 2023-07-20 00:17:30 ASM1 1 1277 Normal Node OPEN WORKING OK TRUE 923631817 923633813 =================== group[name = GRP_DSC, seq = 2, type = DB, Control Node = 0] ======================================== n_ok_ep = 2 ok_ep_arr(index, seqno): (0, 0) (1, 1) sta = OPEN, sub_sta = STARTUP break ep = NULL recover ep = NULL crash process over flag is TRUE ep: css_time inst_name seqno port mode inst_status vtd_status is_ok active guid ts 2023-07-20 00:17:30 cbdsc_DSC0 0 1236 Control Node OPEN WORKING OK TRUE 406094557 406096517 2023-07-20 00:17:30 cbdsc_DSC1 1 1236 Normal Node OPEN WORKING OK TRUE 406095657 406097612 ================================================================================================================== #检查数据库服务状态: ps --ef|grep dmserver #登录数据库验证连接正常: SQL> select status$ from vinstance; 行号 STATUS ---------- ------- 1 OPEN |

达梦在线服务平台:https://eco.dameng.com

相关推荐
it界的哈士奇11 天前
麒麟系统+达梦数据库+MybatisPlus+Redis+SpringBoot
数据库·spring boot·redis·达梦·mybatisplus
卡西里弗斯奥22 天前
【JAVA】IntelliJ IDEA 如何创建一个 Java 项目
java·达梦
guochanof2 个月前
达梦数据库使用笔记,备份还原,迁移
数据库·达梦·达梦数据库·达梦迁移·达梦备份
卡西里弗斯奥2 个月前
【达梦数据库】两台或多台服务器之间免密登录设置-【dmdba用户】
ssh·github·达梦
gc_22992 个月前
SqlSugar查询达梦数据库时搜索不到列值为NULL的记录
达梦·sqlsugar
敲代码不忘补水2 个月前
Docker 安装达梦 DM8 数据库实战指南
数据库·docker·容器·达梦·dm8
smile_life_2 个月前
麒麟桌面版v10 SP1以docker方式安装达梦数据库
数据库·docker·达梦·麒麟
卡西里弗斯奥3 个月前
【达梦数据库】存储过程统计模式下表信息-SQL改写
数据库·sql·oracle·达梦
谢小涛3 个月前
Apache James配置连接达梦数据库
达梦·mail·邮件·james·邮局
文牧之4 个月前
达梦数据库的系统视图v$object_usage
运维·数据库·达梦