溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

異地rman恢復(fù)數(shù)據(jù)庫

發(fā)布時(shí)間:2020-06-29 18:53:31 來源:網(wǎng)絡(luò) 閱讀:350 作者:老妖兒 欄目:關(guān)系型數(shù)據(jù)庫

Source db端:

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

ORACLE_SID=ygdg

數(shù)據(jù)文件位置:/u01/app/oracle/oradata/ygdg

Target db端:

ORACLE_BASE=/u01/app/oracle

ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

ORACLE_SID=ygdg

數(shù)據(jù)文件位置:/u01/app/oracle/oradata/ygdg

【1.原庫rman備份】

[oracle@oraclelinux rman]$ cat rman_for_dg.sh

export ORACLE_SID=ygdg

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

rman target=/ log='/u01/ygtest/fullbackup.log'<<EOF

crosscheck archivelog all;

run

{

allocate channel t1 type disk;

allocate channel t2 type disk;

allocate channel t3 type disk;

allocate channel t4 type disk;

backup as compressed backupset database format '/u01/ygtest/DB%d%s%p%t.bak' TAG='WHOLE BACKUP' section size 30G

plus archivelog format '/u01/ygtest/ARC%d%s%p%t.bak' TAG='ARC BACKUP' delete input;

backup current controlfile format '/u01/ygtest/CTL%d%s%p%t.bak' TAG='CTL BACKUP';

release channel t1;

release channel t2;

release channel t3;

release channel t4;

}

crosscheck backup;

delete noprompt obsolete recovery window of 3 days;

EOF

【2.原庫查看DBID】

export ORACLE_SID=ygdg

rman target=/

連接上之后就可以看得到DBID,記下來

【3.原庫生成pfile】

create pfile='/u01/pfileygdg.ora' from spfile;

【4.備份文件傳至目標(biāo)庫】

scp /u01/ygtest/*.bak oracle@10.1.1.11:/u01/ygtest 記得確定目錄權(quán)限和所屬者

【5.原庫目標(biāo)庫結(jié)合修改pfile,并將修改后的參數(shù)文件傳到目標(biāo)端】

建議將原庫生成的pfile和目標(biāo)庫的spfile都下載到本地,根據(jù)“參數(shù)位置看pfile,其他看spfile”的原則進(jìn)行修改

【6.目標(biāo)數(shù)據(jù)庫創(chuàng)建spfile,并使用spfile啟動(dòng)數(shù)據(jù)庫到nomount狀態(tài)】

如果上面參數(shù)修改沒問題,正常應(yīng)該是下面這樣:

SQL> startup pfile='/software/pfileygdg.ora';

SQL> create spfile from pfile='/software/pfileygdg.ora';

SQL> shutdown immediate;

SQL> startup nomount;

但是有些參數(shù)沒注意修改,就會(huì)出現(xiàn)ORA-,不用擔(dān)心,看到什么錯(cuò)改什么就行,如下:

SQL> startup pfile='/software/pfileygdg.ora';

ORACLE 例程已經(jīng)啟動(dòng)。

Total System Global Area 221331456 bytes

Fixed Size 2251856 bytes

Variable Size 163578800 bytes

Database Buffers 50331648 bytes

Redo Buffers 5169152 bytes

ORA-00201: control file version 11.2.0.4.0 incompatible with ORACLE version 11.2.0.0.0

ORA-00202: control file: '/u01/app/oracle/oradata/ygdg/control01.ctl'

分析:查看參數(shù)文件中compatible值為11.2.0.0.0,與控制文件中的值沖突;

解決:

SQL> create spfile from pfile='/software/pfileygdg.ora';

文件已創(chuàng)建。

SQL> shutdown immediate;

ORA-01507: ??????

ORACLE 例程已經(jīng)關(guān)閉。

解決:修改spfile文件compatible參數(shù)后,使用spfile啟動(dòng)

SQL> startup nomount;

ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initygdg.ora'

解決此問題的方法就是到cd /u01/app/oracle/admin/ygdg/pfile/目錄下,將init.ora.25201817331

復(fù)制到dbs目錄下:

cp init.ora.25201817331 /u01/app/oracle/product/11.2.0/db_1/dbs/initygdg.ora

SQL> startup nomount;

ORACLE 例程已經(jīng)啟動(dòng)。

Total System Global Area 830930944 bytes

Fixed Size 2257800 bytes

Variable Size 536874104 bytes

Database Buffers 285212672 bytes

Redo Buffers 6586368 bytes

SQL> exit

從 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options 斷開

【7.還原控制文件】

[oracle@localhost database]$ rman target=/

恢復(fù)管理器: Release 11.2.0.4.0 - Production on 星期一 3月 5 19:20:26 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

已連接到目標(biāo)數(shù)據(jù)庫: YGDG (未裝載)

RMAN> set dbid=2428115541

RMAN> restore controlfile from '/software/ygtest/CTL_YGDG_55_1_969977274.bak';

RMAN> alter database mount;

【8.指定備份文件所在目錄】

RMAN> catalog start with '/software/ygtest';

【9.還原與恢復(fù)數(shù)據(jù)庫】

RMAN> run{

set newname for datafile 1 to "/u01/app/oracle/oradata/ygdg/system01.dbf";

set newname for datafile 2 to "/u01/app/oracle/oradata/ygdg/sysaux01.dbf";

set newname for datafile 3 to "/u01/app/oracle/oradata/ygdg/undotbs01.dbf";

set newname for datafile 4 to "/u01/app/oracle/oradata/ygdg/users01.dbf";

set newname for datafile 5 to "/u01/app/oracle/oradata/ygdg/test01.dbf";

set newname for tempfile 1 to "/u01/app/oracle/oradata/ygdg/temp01.dbf";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/ygdg/redo01a.log'' to ''/u01/app/oracle/oradata/ygdg/redo01a.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/ygdg/redo02a.log'' to ''/u01/app/oracle/oradata/ygdg/redo02a.log'' ";

}

RMAN> run{

restore database;

SWITCH DATAFILE ALL;

recover database;

} # update control file with new filenames

注:1.原庫執(zhí)行

SQL> select 'set newname for datafile ' || a.FILE# || ' to "' || a.NAME || '";'

from v$datafile a union all select 'set newname for tempfile ' || a.FILE# || ' to "' || a.NAME || '";' from v$tempfile a;

'SETNEWNAMEFORDATAFILE'||A.FILE#||'TO"'||A.NAME||'";'


set newname for datafile 1 to "/u01/app/oracle/oradata/ygdg/system01.dbf";

set newname for datafile 2 to "/u01/app/oracle/oradata/ygdg/sysaux01.dbf";

set newname for datafile 3 to "/u01/app/oracle/oradata/ygdg/undotbs01.dbf";

set newname for datafile 4 to "/u01/app/oracle/oradata/ygdg/users01.dbf";

set newname for datafile 5 to "/u01/app/oracle/oradata/ygdg/test01.dbf";

set newname for tempfile 1 to "/u01/app/oracle/oradata/ygdg/temp01.dbf";

已選擇6行。

SQL>

SELECT 'SQL "ALTER DATABASE RENAME FILE ''''' || a.MEMBER || ''''' to ''''' || a.MEMBER || ''''' ";' FROM v$logfile a;


SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/ygdg/redo01a.log'' to

''/u01/app/oracle/oradata/ygdg/redo01a.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/ygdg/redo02a.log'' to

''/u01/app/oracle/oradata/ygdg/redo02a.log'' ";

2.使用newnam for datafile來實(shí)現(xiàn)修改不同的文件路徑

3.switch datafile all用來更新還原回來的controlfile中的數(shù)據(jù)文件路徑與聯(lián)機(jī)日志文件路徑,要不然recover時(shí)會(huì)報(bào)錯(cuò)RMAN-06094

[oracle@localhost database]$ sqlplus / as sysdba

SQL> select status from v$instance;

STATUS


MOUNTED

SQL> alter database open resetlogs;

數(shù)據(jù)庫已更改。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI