RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
异地rman恢复数据库

Source db端:

繁峙ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!

ORACLE_BASE=/u01/app/oracle

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

ORACLE_SID=ygdg

数据文件位置:/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

数据文件位置:/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'<

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.备份文件传至目标库】

scp /u01/ygtest/*.bak oracle@10.1.1.11:/u01/ygtest 记得确定目录权限和所属者

【5.原库目标库结合修改pfile,并将修改后的参数文件传到目标端】

建议将原库生成的pfile和目标库的spfile都下载到本地,根据“参数位置看pfile,其他看spfile”的原则进行修改

【6.目标数据库创建spfile,并使用spfile启动数据库到nomount状态】

如果上面参数修改没问题,正常应该是下面这样:

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

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

SQL> shutdown immediate;

SQL> startup nomount;

但是有些参数没注意修改,就会出现ORA-,不用担心,看到什么错改什么就行,如下:

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

ORACLE 例程已经启动。

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'

分析:查看参数文件中compatible值为11.2.0.0.0,与控制文件中的值冲突;

解决:

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

文件已创建。

SQL> shutdown immediate;

ORA-01507: ??????

ORACLE 例程已经关闭。

解决:修改spfile文件compatible参数后,使用spfile启动

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

复制到dbs目录下:

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

SQL> startup nomount;

ORACLE 例程已经启动。

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=/

恢复管理器: 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.

已连接到目标数据库: 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.还原与恢复数据库】

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.原库执行

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来实现修改不同的文件路径

3.switch datafile all用来更新还原回来的controlfile中的数据文件路径与联机日志文件路径,要不然recover时会报错RMAN-06094

[oracle@localhost database]$ sqlplus / as sysdba

SQL> select status from v$instance;

STATUS


MOUNTED

SQL> alter database open resetlogs;

数据库已更改。


当前标题:异地rman恢复数据库
标题网址:http://scyingshan.cn/article/jpcoge.html