千家信息网

DM7 RAC数据库怎样恢复成单机数据库

发表于:2025-01-24 作者:千家信息网编辑
千家信息网最后更新 2025年01月24日,本篇文章为大家展示了DM7 RAC数据库怎样恢复成单机数据库,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。DM7 RAC数据库恢复成单机数据库1) 启动RMA
千家信息网最后更新 2025年01月24日DM7 RAC数据库怎样恢复成单机数据库

本篇文章为大家展示了DM7 RAC数据库怎样恢复成单机数据库,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

DM7 RAC数据库恢复成单机数据库
1) 启动RMAN备份数据库,保证服务器处于脱机状态。

RMAN> backup database '/dm7/data/rac0_config/dm.ini' full backupset '/dm7/backup/db_rac_full_bak_recover_dbmagic';backup database '/dm7/data/rac0_config/dm.ini' full backupset '/dm7/backup/db_rac_full_bak_recover_dbmagic';file dm.key not found, use default license!checking if the RAC database under system path [+DMDATA/data/rac] is running....EP [0] is checking....EP [1] is checking....EP[0] max_lsn: 76986EP[0] adjust cur_lsn from [76986] to [77001]BACKUP DATABASE [rac], execute......CMD CHECK LSN......BACKUP DATABASE [rac], collect dbf......CMD CHECK ......DBF BACKUP SUBS......total 1 packages processed...total 2 packages processed...total 3 packages processed...total 4 packages processed...total 5 packages processed...DBF BACKUP MAIN......BACKUPSET [/dm7/backup/db_rac_full_bak_recover_dbmagic] END, CODE [0]......META GENERATING......total 9 packages processed...total 9 packages processed!CMD END.CODE:[0]backup successfully!time used: 3887.714(ms)RMAN> show backupset '/dm7/backup/db_rac_full_bak_recover_dbmagic';show backupset '/dm7/backup/db_rac_full_bak_recover_dbmagic';system path:           +DMDATA/data/racdb magic:              -1632052820permanent magic:       450923536rac node:              2page check:            0rlog encrypt:          0external cipher[id/name]:  0/external hash[id/name]:  0/length in char:        0use new hash:          1page size:             8 KBextent size:           16case sensitive:        1log page size:         512 Bunicode_flag/charset:  0data version:          0x7000Asys version:           V7.1.6.46-Build(2018.02.08-89107)ENTenable policy:         0archive flag:          1blank_pad_mode:        0crc_check:             TRUEbackupset sig:         BAbackupset version:     4009database name:         racbackup name:           DB_FULL_rac_20200616_154323_000689backupset description:backupset ID :         1145407476parent backupset ID:     -1META file size :       74240compressed level:      0encrypt type:          0parallel num:          1backup range:          databasempp_timestamp:         1592293401ddl_clone:             FALSEmpp_flag:              FALSEbackup level:          offlinebackup type:           fullwithout log:           FALSESTART_LSN:             76987START_SEQ:             309END_LSN:               77001END_SEQ:               308base START_LSN:        -1base END_LSN:          -1base name:base backupset:backup time:           2020-06-16 15:43:25min trx start lsn:     76987min exec ver:          0x0701060Cpkg size:              0x02000000RAC EP:            0RAC status:          OKRAC begin lsn:       76987RAC begin seq:       309RAC end lsn:         77001RAC end seq:         308RAC base begin lsn:  -1RAC base begin seq:  -1RAC base end lsn:    -1RAC base end seq:    -1RAC EP:            1RAC status:          OKRAC begin lsn:       77002RAC begin seq:       308RAC end lsn:         77001RAC end seq:         307RAC base begin lsn:  -1RAC base begin seq:  -1RAC base end lsn:    -1RAC base end seq:    -1backupset directory: /dm7/backup/db_rac_full_bak_recover_dbmagicbackupset name:        db_rac_full_bak_recover_dbmagicbackup data file num:  5backup piece num:      1$file_seq |$size(KB) |$pos_desc                                               |$content_type0         |26103     |db_rac_full_bak_recover_dbmagic.bak                     |DATA$file_seq |$group_id |$group_name                      |$file_id  |$file_path                       |$mirror_path                     |$file_len1         |0         |SYSTEM                           |0         |+DMDATA/data/rac/system.dbf      |                                 |1342177282         |1         |ROLL                             |0         |+DMDATA/data/rac/roll.dbf        |                                 |1342177283         |4         |MAIN                             |0         |+DMDATA/data/rac/main.dbf        |                                 |1342177284         |5         |TS_FOR_DBF                       |0         |+DMDATA/data/rac/ts_for_dbf_01.dbf|                                 |1342177285         |5         |TS_FOR_DBF                       |1         |+DMDATA/data/rac/ts_for_dbf_02.dbf|                                 |134217728$file_seq |$file_path                       |$file_len           |$begin_lsn          |$begin_seqno        |$begin_rpag_off     |$end_lsn            |$end_seqno          |$create_time        |$close_timeshow backupsets successfully.time used: 10.655(ms)

2) 准备目标库,可以使用备份库,也可以重新生成库。这里是在别一台服务器上创建新库,重新生成库操作如下:

[dmdba@dmks ~]$ dminit path=/dm_home/dmdbms/data db_name=dameng_for_recover auto_overwrite=1 port_num=5336initdb V7.1.6.46-Build(2018.02.08-89107)ENTdb version: 0x7000afile dm.key not found, use default license!License will expire in 14 day(s) on 2020-06-30 log file path: /dm_home/dmdbms/data/dameng_for_recover/dameng_for_recover01.log log file path: /dm_home/dmdbms/data/dameng_for_recover/dameng_for_recover02.logwrite to dir [/dm_home/dmdbms/data/dameng_for_recover].create dm database success. 2020-06-16 16:03:18[root@dmks root]# ./dm_service_installer.sh  -i /dm_home/dmdbms/data/dameng_for_recover/dm.ini -p dmrc -t dmserverMove the service script file(/dm_home/dmdbms/bin/DmServicedmrc to /etc/rc.d/init.d/DmServicedmrc)Finished to create the service (DmServicedmrc)[root@dmks root]# service DmServicedmrc startStarting DmServicedmrc: [ OK ][dmdba@dmks ~]$ disql SYSDBA/SYSDBA@localhost:5336Server[localhost:5336]:mode is normal, state is openlogin used time: 10.727(ms)disql V7.1.6.46-Build(2018.02.08-89107)ENTConnected to: DM 7.1.6.46SQL> select permanent_magic;LINEID     PERMANENT_MAGIC---------- ---------------1          -1238913195used time: 0.793(ms). Execute id is 809.SQL> select db_magic from v$rlog;LINEID     DB_MAGIC---------- -----------1          1319824724used time: 0.984(ms). Execute id is 810.

3)将备份集和归档日志文件复制到目标库所在主机上

[dmdba@dmrac1 backup]$ scp -r db_rac_full_bak_recover_dbmagic dmdba@10.10.10.187:/dm_home/dmdbms/backup/
The authenticity of host '10.10.10.187 (10.10.10.187)' can't be established.
RSA key fingerprint is 34:9a:d7:67:6d:be:20:45:21:ce:96:82:23:e5:e9:11.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.10.187' (RSA) to the list of known hosts.
dmdba@10.10.10.187's password:
db_rac_full_bak_recover_dbmagic.meta 100% 73KB 72.5KB/s 00:00
db_rac_full_bak_recover_dbmagic.bak 100% 25MB 25.5MB/s 00:00

[dmdba@dmrac1 data]$ scp -r local_arch dmdba@10.10.10.187:/dm_home/dmdbms/backup/
dmdba@10.10.10.187's password:
ARCHIVE_LOCAL1_20200528171255857_0.log 100% 157KB 156.5KB/s 00:00
[dmdba@dmrac1 data]$ scp -r rac0_arch dmdba@10.10.10.187:/dm_home/dmdbms/backup/
dmdba@10.10.10.187's password:
ARCHIVE_LOCAL1_20200615164953273_0.log 100% 160KB 160.0KB/s 00:00
ARCHIVE_LOCAL1_20200615165648166_0.log 100% 157KB 157.0KB/s 00:00
ARCHIVE_LOCAL1_20200528202150715_0.log 100% 277KB 277.0KB/s 00:00
ARCHIVE_LOCAL1_20200608151836879_0.log 100% 158KB 157.5KB/s 00:00
ARCHIVE_LOCAL1_20200609150852829_0.log 100% 157KB 157.0KB/s 00:00
ARCHIVE_LOCAL1_20200608152638617_0.log 100% 159KB 158.5KB/s 00:00
ARCHIVE_LOCAL1_20200609170732487_0.log 100% 161KB 160.5KB/s 00:00
ARCHIVE_LOCAL1_20200615172117341_0.log 100% 159KB 158.5KB/s 00:00
ARCHIVE_LOCAL1_20200615171042444_0.log 100% 159KB 159.0KB/s 00:00
ARCHIVE_LOCAL1_20200605154214367_0.log 100% 157KB 157.0KB/s 00:00
[dmdba@dmrac1 data]$ scp -r rac1_arch dmdba@10.10.10.187:/dm_home/dmdbms/backup/
dmdba@10.10.10.187's password:
ARCH_REMOTE1_20200608152641970_1.log 100% 158KB 158.0KB/s 00:00
ARCH_REMOTE1_20200609170737070_1.log 100% 159KB 159.0KB/s 00:00
ARCH_REMOTE1_20200609150857056_1.log 100% 158KB 158.0KB/s 00:00
ARCH_REMOTE1_20200615172121038_1.log 100% 158KB 158.0KB/s 00:00
ARCH_REMOTE1_20200608151838201_1.log 100% 5632 5.5KB/s 00:00
ARCH_REMOTE1_20200528202146001_1.log 100% 158KB 158.0KB/s 00:00
ARCH_REMOTE1_20200615164957743_1.log 100% 158KB 158.0KB/s 00:00
ARCH_REMOTE1_20200605154211189_1.log 100% 159KB 159.0KB/s 00:00
ARCH_REMOTE1_20200615165652504_1.log 100% 158KB 158.0KB/s 00:00
ARCH_REMOTE1_20200615171046600_1.log 100% 158KB 158.0KB/s 00:00
[dmdba@dmrac1 data]$

4)检验备份

RMAN> check backupset '/dm_home/dmdbms/backup/db_rac_full_bak_recover_dbmagic';check backupset '/dm_home/dmdbms/backup/db_rac_full_bak_recover_dbmagic';CMD END.CODE:[0]check backupset successfully.time used: 5.877(ms)

5)还原数据库

RMAN> restore database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' from backupset '/dm_home/dmdbms/backup/db_rac_full_bak_recover_dbmagic';restore database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' from backupset '/dm_home/dmdbms/backup/db_rac_full_bak_recover_dbmagic';file dm.key not found, use default license!checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[4].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[3].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[2].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[1].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[0].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running, write dmrman info.RESTORE DATABASE  CHECK......RESTORE DATABASE , dbf collect......RESTORE DATABASE , dbf refresh ......RESTORE BACKUPSET [/dm_home/dmdbms/backup/db_rac_full_bak_recover_dbmagic] START......total 5 packages processed...RESTORE DATABASE , UPDATE ctl file......RESTORE DATABASE , REBUILD key file......RESTORE DATABASE , CHECK db info......RESTORE DATABASE , UPDATE db info......total 7 packages processed!CMD END.CODE:[0]restore successfully.time used: 16226.253(ms)

6)恢复数据库

RMAN> recover database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini'  update db_magic ;recover database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' update db_magic;checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[4].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[3].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[2].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[1].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[0].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running, write dmrman info.EP[0] max_lsn: 76986[-8308]:forbid updating database magic, need redo log

这里使用update db_magic选项出错了,提示需要重做日志文件。下面去掉update db_magic选项,因为每次还原恢复时也是一定会更新db_magic值。

RMAN> recover database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' with archivedir '/dm_home/dmdbms/backup/rac0_arch','/dm_home/dmdbms/backup/rac1_arch';recover database '/dm_home/dmdbms/data/dameng_for_recover/dm.ini' with archivedir '/dm_home/dmdbms/backup/rac0_arch' , '/dm_home/dmdbms/backup/rac1_arch';checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[4].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[3].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[2].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[1].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running...[0].checking if the database under system path [/dm_home/dmdbms/data/dameng_for_recover] is running, write dmrman info.EP[0] max_lsn: 76986min_ckpt_lsn =The RAC recover total redo 0 ptxEP(0) slot ctl page(1, 0, 16) trxid = 9986EP(1) slot ctl page(1, 0, 17) trxid = 8457EP[0] Recover LSN from 76987 to 77001.EP[1] Recover LSN from 77002 to 77001.Recover from archive log finished, time used:0.006s.recover successfully!time used: 7027.075(ms)

7)检查数据,查询表t1的数据可以验证数据恢复成功

[dmdba@dmks ~]$ disql SYSDBA/SYSDBA@localhost:5336Server[localhost:5336]:mode is normal, state is openlogin used time: 10.727(ms)disql V7.1.6.46-Build(2018.02.08-89107)ENTConnected to: DM 7.1.6.46SQL> desc t1;LINEID     NAME TYPE$       NULLABLE---------- ---- ----------- --------1          ID   INTEGER     Y2          NAME VARCHAR(20) Yused time: 20.311(ms). Execute id is 3.SQL> select * from t1;LINEID     ID          NAME---------- ----------- ----1          1           jy2          2           hyused time: 1.138(ms). Execute id is 4.

8)检查db_magic,还原恢复后db_magic从-1632052820变成了1009602608,

SQL> select permanent_magic;LINEID     PERMANENT_MAGIC---------- ---------------1          450923536used time: 1.042(ms). Execute id is 5.SQL> select db_magic from v$rlog;LINEID     DB_MAGIC---------- -----------1          1009602608used time: 1.332(ms). Execute id is 6.

上述内容就是DM7 RAC数据库怎样恢复成单机数据库,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。

0