OS:Centos 7
DB:DM8
1.全备数据库和归档日志
disql sysdba/dameng123
SQL>backup database full backupset '/dmdbms/bak/fullbak_20240319';
SQL>backup archivelog all delete input to "archbak_20240319" backupset '/dmdbms/bak/archbak_20240319';
fullbak_20240319和archbak_20240319目录是系统自动创建的
2.停掉当前的数据库
[root@host01 ~]# systemctl stop DmServiceDMSERVER.service
3.进入到数据目录,模拟删除数据目录
[dmdba@host01 data]$ rm -rf DAMENG/
4.重新初始化一个实例
初始化一个实例,实例名与之前一致
/dmdbms/product/bin/dminit path=/dmdbms/data charset=1 case_sensitive=0 length_in_char=0 db_name=DAMENG instance_name=DAMENG SYSDBA_PWD="dameng100" SYSAUDITOR_PWD="dameng100"
系统会自动数据目录
[dmdba@host01 DAMENG]$ pwd
/dmdbms/data/DAMENG
/dmdbms/product/bin/dminit path=/dmdbms/data charset=1 case_sensitive=0 length_in_char=0 db_name=DAMENG01 instance_name=DAMENG01 SYSDBA_PWD="dameng100" SYSAUDITOR_PWD="dameng100"
这里的db_name和instance_name可以与之前备份的数据库不一致,比如取名为DAMENG01也是可以的.
只保留如下这些目录和文件,其他文件可以删除掉,也可以保留
[dmdba@host01 DAMENG]$ ls -al total 75860 drwxr-xr-x 4 dmdba dinstall 78 Mar 19 15:57 . drwxr-xr-x 4 dmdba dinstall 40 Mar 19 15:52 .. drwxr-xr-x 2 dmdba dinstall 6 Mar 19 15:56 bak drwxr-xr-x 2 dmdba dinstall 6 Mar 19 15:56 ctl_bak -rw-r--r-- 1 dmdba dinstall 6656 Mar 19 15:55 dm.ctl -rw-r--r-- 1 dmdba dinstall 75709 Mar 19 15:55 dm.ini -rw-r--r-- 1 dmdba dinstall 77594624 Mar 19 15:57 SYSTEM.DBF
必须有SYSTEM.DBF,否则恢复的还原的时候报错误
RMAN> restore database '/dmdbms/data/DAMENG/dm.ini' from backupset '/dmdbms/bak/fullbak_20240319'; restore database '/dmdbms/data/DAMENG/dm.ini' from backupset '/dmdbms/bak/fullbak_20240319'; /dmdbms/data/DAMENG/SYSTEM.DBF not exist
5.恢复(2选1)
5.1单独使用全备进行还原
[dmdba@localhost ~]$ dmrman RMAN>restore database '/dmdbms/data/DAMENG/dm.ini' from backupset '/dmdbms/bak/fullbak_20240319'; ##还原备份集 RMAN>recover database '/dmdbms/data/DAMENG/dm.ini' from backupset '/dmdbms/bak/fullbak_20240319'; ##使用备份集恢复 RMAN>recover database '/dmdbms/data/DAMENG/dm.ini' update db_magic;
5.2 使用归档日志和全备进行还原
[dmdba@localhost ~]$ dmrman RMAN>restore archive log from backupset '/dmdbms/bak/archbak_20240319' TO ARCHIVEDIR'/dmdbms/arch' overwrite 2; 1表示认为归档文件完好,不再还原该归档文件,添加一条日志记录; 2表示存在同名归档立即报错返回,终止还原; 3表示强制删除归档,重新还原同名归档. 说明:执行该语句后,归档日志会还原到目录:/dmdbms/arch 继续使用全备恢复 RMAN>restore database '/dmdbms/data/DAMENG/dm.ini' from backupset '/dmdbms/bak/fullbak_20240319'; ##还原备份集 RMAN>recover database '/dmdbms/data/DAMENG/dm.ini' with archivedir '/dmdbms/arch'; ##通过归档日志完全恢复 RMAN>recover database '/dmdbms/data/DAMENG/dm.ini' update db_magic;
6.启动
[root@host01 ~]# systemctl start DmServiceDMSERVER.service 然后登陆 disql hxl/dameng123 disql sysdba/dameng123 这里的密码是备份数据库的密码,而不是初始化时候设置的密码 注意恢复出来的新实例是非归档模式的 SQL> select name,arch_mode from v$database; LINEID name arch_mode ---------- ------ --------- 1 DAMENG N used time: 1.277(ms). Execute id is 502. SQL>
标签:dmdba,dm,机器,同一,data,备份,dmdbms,20240319,DAMENG From: https://www.cnblogs.com/hxlasky/p/18083563