宜昌 醫(yī)院 網(wǎng)站建設(shè)seo排名優(yōu)化推廣教程
環(huán)境描述:
1.因為主庫存儲空間不足,于是將備份放在dg備庫上做。
2.主庫因為磁盤空間問題,數(shù)據(jù)文件有兩個目錄。
3.dg備庫因為主庫兩個數(shù)據(jù)文件目錄里面有兩個同名數(shù)據(jù)文件,所有dg備庫也有兩個數(shù)據(jù)文件目錄。
4.主庫與備庫與測試庫均為Windows系統(tǒng)11.2.0.4
恢復(fù)步驟
1.打開測試庫到nomount
2.設(shè)置控制文件和歸檔日志路徑
3.恢復(fù)控制文件
restore primary controlfile from ’d:\bak\FULL_SQ1RBKLE_1_1_20230505.BAK';
5.配置db_file_name_convert和log_file_name_convert參數(shù)
alter system set db_file_name_convert='X:\ORADATA\ORCL\','D:\ORADATA\ORCL1\','W:\ORADATA\ORCL\','D:\ORADATA\ORCL2\' scope=spfile;
alter system set log_file_name_convert='X:\ORADATA\ORCL\','D:\ORADATA\ORCL1\' scope=spfile;
--因為我這里恢復(fù)的是primary控制文件,所以我這路的convert里配置的是主庫和新測試庫的文件路徑轉(zhuǎn)換,和dg備庫數(shù)據(jù)文件路徑并沒有關(guān)系。
6.打開測試庫到mount
7.注冊備份集
8.check備份集并刪除過期備份集
9.開始恢復(fù)數(shù)據(jù)庫
一開始我以為配置了convert參數(shù)后,可以直接恢復(fù),恢復(fù)的時候會自動轉(zhuǎn)換文件路徑的,于是我直接用下面腳本restore
run{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch4 device type disk;
restore database;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
恢復(fù)過程出現(xiàn)報錯:
這里恢復(fù)過程中出現(xiàn)的E盤數(shù)據(jù)文件路徑是dg備庫的數(shù)據(jù)文件路徑,這個就很奇怪,查看控制文件中的數(shù)據(jù)文件路徑:
這幾個數(shù)據(jù)文件好像是dg做完之后,在主庫添加的數(shù)據(jù)文件,不知道為什么這里恢復(fù)的時候沒有轉(zhuǎn)換過來。
這里我們嘗試用rename的方式在控制文件中重命名數(shù)據(jù)文件路徑,但是提示文件不存在不能rename。
于是嘗試在restore的時候set newname,腳本如下:
run{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
allocate channel ch3 device type disk;
allocate channel ch4 device type disk;
set newname for datafile 148 to 'D:\ORADATA\ORCL2\ZLWSDATANEW01.DBF';set newname for datafile 149 to 'D:\ORADATA\ORCL2\ZLWSDATANEW02.DBF';set newname for datafile 150 to 'D:\ORADATA\ORCL2\ZL9LISDATANEW02.DBF';set newname for datafile 151 to 'D:\ORADATA\ORCL2\ZL9INDEXCISNEW02.DB';set newname for datafile 152 to 'D:\ORADATA\ORCL2\ZLWSDATANEW03.DBF';set newname for datafile 153 to 'D:\ORADATA\ORCL2\JSGJLDYBNEW02.DBF';set newname for datafile 154 to 'D:\ORADATA\ORCL2\ZL9INDEXCISNEW03.DBF';
restore database;
switch datafile all;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
--單獨將這幾個數(shù)據(jù)文件set newname是可行的,可以正常restore。
10.恢復(fù)歸檔
11.不完全恢復(fù)
12.open resetlogs