rman异机恢复,全部恢复和增量恢复
1.首先准备工作:
hostname
192.168.222.11 ol7.localdomain ol7
建立相关目录:
mkdir -p /u01/app/oracle/oradata/DB11G/
mkdir -p /oracle/redo1/
mkdir -p /u01/app/oracle/product/11.2.0.4/db_1/dbs/
mkdir -p /oracletemp/DB11G/archive_log/
mkdir -p /oraclearch/archive_log/
mkdir -p /oraclearch/flash_recovery_area/DB11G/
mkdir -p /u01/app/oracle/oradata/DB11G/
mkdir -p /oracledata/nc/ncindex/
mkdir -p /u01/app/oracle/oradata/DB11G/
mkdir -p /oracledata/nc/nctables/
mkdir -p /oracledata/DB11G/
mkdir -p /u01/app/oracle/oradata/DB11G/
mkdir -p /u01/app/oracle/admin/DB11G/{adump,dpdump,pfile}
chown -R oracle:oinstall /u01
chmod -R 775 /u01
chown -R oracle:oinstall /oracle/redo1/
chmod -R 775 /oracle/redo1/
chown -R oracle:oinstall /oracletemp/DB11G/archive_log/
chmod -R 775 /oracletemp/DB11G/archive_log/
chown -R oracle:oinstall /oraclearch/archive_log/
chmod -R 775 /oraclearch/archive_log/
chown -R oracle:oinstall /oracledata/nc/ncindex/
chmod -R 775 /oracledata/nc/ncindex/
mkdir /oracledata/nc_ma/nc_ma_tables/ -p
chown oracle:oinstall -R /oracledata/nc_ma/nc_ma_tables/
更新yum update
执行脚本:
[root@ol7 ~]# cat dbinstall.sh
#!/bin/bash
IP=`ip addr |grep 'inet'|grep 'brd'|awk '{print $2}'|awk -F / '{print $1}'`
echo $IP ol7.localdomain ol7 >> /etc/hosts
hostnamectl set-hostname ol7.localdomain
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce 0
yum -y install oracle-rdbms-*
yum -y install rlwrap
mkdir -p /u01/app/oracle/product/11.2.0.4/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01
systemctl stop firewalld
systemctl disable firewalld
cat >>/home/oracle/.bash_profile<<EOF
# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=ol7.localdomain; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=\$ORACLE_BASE/product/11.2.0.4/db_1; export ORACLE_HOME
ORACLE_SID=DB11G; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:\$PATH; export PATH
PATH=\$ORACLE_HOME/bin:\$PATH; export PATH
LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=\$ORACLE_HOME/JRE:\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib; export CLASSPATH
alias sql='rlwrap sqlplus'
alias sqlplus='rlwrap sqlplus'
alias lsnrctl='rlwrap lsnrctl'
alias rman='rlwrap rman'
alias envo='env | grep ORACLE'
alias cdob='cd \$ORACLE_BASE'
alias cdoh='cd \$ORACLE_HOME'
alias tns='cd \$ORACLE_HOME/network/admin'
EOF
再次执行脚本:
[root@ol7 ~]# cat iso.sh
#!/bin/bash
yum install createrepo -y
yum install unzip -y
yum install gcc* -y
yum install xhost -y
yum -y install elfutils*
[root@ol7 ~]#
解压:
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0.4/db_1/root.sh
二:在目的服务器上复制备份数据,并准备好相关的目录
[oracle@orcl ~]$ mkdir /u01/backup
[oracle@orcl ~]$ scp -rp 192.168.227.20:/u01/backup/* /u01/backup/
oracle@192.168.227.20's password:
control20110906.bak 100% 6944KB 1.7MB/s 00:04
db_full_0fmlsmdt_1_1.bkp 100% 97MB 4.4MB/s 00:22
db_full_0gmlsme5_1_1.bkp 100% 593MB 9.1MB/s 01:05
db_full_0hmlsmg7_1_1.bkp 100% 6656 6.5KB/s 00:00
spfile20110906.bak 100% 96KB 96.0KB/s 00:00
[oracle@orcl ~]$ mkdir -p /u01/app/oracle/admin/orcl/{adump,bdump,cdump,dpdump,udump,pfile}
[oracle@orcl ~]$ mkdir -p /u01/app/oracle/oradata/orcl
[oracle@orcl ~]$ mkdir -p /u01/app/oracle/flash_recover_area/ORCL
三:在目的服务器上进行恢复
[oracle@orcl ~]$ echo 'db_name=orcl' > $ORACLE_HOME/dbs/initorcl.ora
[oracle@orcl ~]$ export ORACLE_SID=orcl
[oracle@orcl ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Sep 6 16:18:19 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> set dbid 1287906064; //指定DBID,需要和源服务器的DBID一致
RMAN> startup nomount; //启动数据库到nomount状态,这里需要前面创建initorcl.ora文件,否则将报错
RMAN> restore spfile from '/u01/backup/spfile20110906.bak'; //恢复参数文件
RMAN> startup nomount force; //重启实例到nomout状态
RMAN> restore controlfile from '/u01/backup/control20110906.bak'; //恢复控制文件
RMAN> restore database; //还原数据库文件 (记得注册目录)
RMAN> recover database; //恢复数据库文件,这里将报错
RMAN-03002: failure of recover command at 09/06/2011 17:03:51
RMAN-06054: media recovery requesting unknown log: thread 1 seq 15 lowscn 547974
RMAN> exit
[oracle@orcl ~]$ sqlplus /nolog //在sqlplus中对数据库进行until cancel操作后以resetlogs方式打开
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 6 17:04:22 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 547974 generated at 09/06/2011 16:49:11 needed for thread 1
ORA-00289: suggestion :
/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_09_06/o1_mf_1_15_%u_.ar
c
ORA-00280: change 547974 for thread 1 is in sequence #15
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> alter database open resetlogs;
四:测试
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/redo03.log
/u01/app/oracle/oradata/orcl/redo02.log
/u01/app/oracle/oradata/orcl/redo01.log
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/example01.dbf
/u01/app/oracle/oradata/orcl/tbs_apple01.dbf
6 rows selected.
SQL> select count(*) from dba_temp_files;
COUNT(*)
----------
1
SQL> select count(*) from hr.employees;
COUNT(*)
----------
107
五:注意事项
RMAN> list incarnation; //生成一个新的incarnation
using target database control file instead of recovery catalog
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 ORCL 1287906064 PARENT 1 2005-06-30:19:09:40
2 2 ORCL 1287906064 PARENT 446075 2011-08-25:17:55:31
3 3 ORCL 1287906064 CURRENT 547975 2011-09-06:17:07:09
[oracle@orcl ~]$ emctl start dbconsole //dbconsole需要重新配置,orapwd文件也需要创建
TZ set to PRC
首先:
/u01/app/oracle/product/11.2.0.4/db_1/dbs
orapwd file='/u01/app/oracle/product/11.2.0.4/db_1/dbs/orapwDB11G' password=oracle entries=5 force=y;
OC4J Configuration issue. /u01/app/oracle/product/10.2.0/db_1/oc4j/j2ee/OC4J_DBConsole_orcl.herostart.com_orcl not found
然后:
你按着这个顺序来试试,不行的话我也不会了
1、设置好监听器,用lsnrctl start启动,然后用lsnrctl statu观察一下是否成功
2、emca -deconfig dbcontrol db 删除dbcontrol
3、emca -repos drop删除EM资料库
4、emca -repos create创建资料库
5、emca -config dbcontrol db重新配置dbcontrol
如果能顺利做下来就应该没问题了
ok!!!!!
六:增量备份的异机恢复
1:源服务器
SQL> create user rman_inr identified by "123456" default tablespace users;
User created.
SQL> grant connect,resource to rman_inr;
Grant succeeded.
SQL> create table rman_inr.test as select * from dba_source;
Table created.
RMAN> backup incremental level 1
2> format '/u01/backup/inr1_db_%U' tag 'inr_1'
3> database plus archivelog;
[oracle@orcl ~]$ rman target /
RMAN> backup incremental level 1
2> format '/u01/backup/inr1_db_%U' tag 'inr_1'
3> database plus archivelog;
RMAN> backup current controlfile format '/u01/backup/control02.bak';
[oracle@orcl ~]$ ls -lh /u01/backup/inr1_db_1*
-rw-r----- 1 oracle oinstall 53M Sep 8 16:34 /u01/backup/inr1_db_1omm1ud0_1_1
-rw-r----- 1 oracle oinstall 51M Sep 8 16:35 /u01/backup/inr1_db_1pmm1udk_1_1
-rw-r----- 1 oracle oinstall 6.9M Sep 8 16:35 /u01/backup/inr1_db_1qmm1uf2_1_1
-rw-r----- 1 oracle oinstall 11K Sep 8 16:35 /u01/backup/inr1_db_1rmm1uf5_1_1
[oracle@orcl ~]$ scp /u01/backup/inr1_db_1* 192.168.227.30:/u01/backup/
[oracle@orcl ~]$ scp /u01/backup/control02.bak 192.168.227.30:/u01/backup/
2:目标服务器
[oracle@orcl ~]$ sqlplus /nolog
SQL> conn /as sysdba
Connected.
SQL> shutdown immediate;
RMAN> set dbid=1287906064;
RMAN> startup nomount;
RMAN> restore controlfile from '/u01/backup/control02.bak';
RMAN> startup mount force;
RMAN> restore database;
RMAN> recover database;
RMAN-03002: failure of recover command at 09/08/2011 16:46:44
RMAN-06054: media recovery requesting unknown log: thread 1 seq 45 lowscn 598452
RMAN> exit
[oracle@orcl ~]$ sqlplus /nolog
SQL> conn /as sysdba
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 598452 generated at 09/08/2011 16:35:49 needed for thread 1
ORA-00289: suggestion : /u01/arch/orcl/1_45_760125331.arc
ORA-00280: change 598452 for thread 1 is in sequence #45
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> alter database open resetlogs;
Database altered.
3:测试
SQL> conn rman_inr/123456
Connected
SQL> select count(*) from test;
COUNT(*)
----------
292428
rman异机恢复,全部恢复和增量恢复的更多相关文章
- Oracle 单实例 迁移到 RAC 实例 -- 使用RMAN 异机恢复
Oracle 官网有关单实例迁移到RAC的一个步骤说明: How to Convert 10g Single-Instance database to 10g RAC using Manual Con ...
- Oracle12c RAC RMAN异机恢复
######################################################## #编辑pfile文件initspdb.ora vi /oracle/app/oracl ...
- RMAN异机恢复遭遇ORA-01547、ORA-01152、ORA-01110错误案例
测试环境: 操作系统 : Red Hat Enterprise Linux ES release 4 (Nahant Update 4) VMWARE 数据库 : O ...
- Linux平台下RMAN异机恢复总结
下面总结.整理一下RMAN异机恢复这方面的知识点,这篇笔记在个人笔记里面躺了几年了,直到最近偶然被翻看到,遂整理.总结一下.如下所示,个人将整个RMAN异机恢复分为准备工作和操作步骤两大部分.当然,准 ...
- RMAN异机恢复实验---转载
一.RMAN异机恢复实验 2011年3月23日00:44 1.环境介绍: 主机1: 操作系统 REDHAT5.5 IP地址 172.16.1.120 主机名 sigle 数据库版本 10.2.0.4 ...
- NBU Rman异机恢复Oracle
前段时间一个亿级分区表,被分割成历史表和业务表,历史表中保留15天以外的数据,每天都会从业务表中的15天外的数据copy到历史表,并删除业务表15天外的数据,逻辑也很简单,但插入历史表的where 条 ...
- oracle rman异机恢复
Oracle源主机 Oracle目标主机 主机平台 CentOS6.2(final) CentOs6.2(FInal) 主机名 vick rman IP地址 192.168.1.11 192.16 ...
- RMAN异机恢复步骤及故障处理
一.測试机安装OS+Oracle Software.包含配置oracle用户.组和环境变量(略) 二.開始异机恢复 1. 复制源库最新备份集.初始化參数.password文件到測试机 [oracle@ ...
- Oracle RMAN 异机恢复一例
背景介绍:本例需求是将NBU备份的oracle数据库恢复到另一主机上. NBU环境配置.异机上的Oracle软件安装配置忽略,下面只介绍OracleDB恢复的过程. ----------------- ...
随机推荐
- java泛型<? extends E> 有上限通配符与<? Super E>有上限通配符
通配符?,?表示占位,表明将来使用的时候在指明类型 <?>无限定的通配符, 是让泛型能够接受未知类型的数据 <? extends E> 有上限通配符,能够接受指定类及其子类类型 ...
- Android Studio modify language level to Java 8
If you need use lambda, should modify language level File -> Project Structure -> app -> Pr ...
- dubbo-admin管理控制台安装和使用
现在链接都变成了https://github.com/apache/incubator-dubbo/,找不到dubbo-admin这个目录. 那就直接去下载他们打包好的源代码:https://gith ...
- 设置Git 记住密码
设置记住密码(默认15分钟): git config --global credential.helper cache 如果想自己设置时间,可以这样做: git config credential.h ...
- 有没有不适合使用flex/lex作为词法分析器的语言?(摘自知乎)
本问题及解答摘自本人知乎 http://www.zhihu.com/people/chaos-xie http://www.zhihu.com/question/29922657 感谢知乎网友的回 ...
- 『AngularJS』创建 Service
创建服务 Angular提供了几种有用的服务,对于所有的应用来说,你将会发现这些服务对于创建你自己的服务是有用处的.为了创建自己的服务,你应该从通过一个模块(module)注册一个服务工厂方法开始(可 ...
- beanshell引用参数化数据
步骤: 1.添加参数化组件CSV Data Set Config: 2.添加beanshell preprocessor,引用变量: 验证: 2个线程,迭代2次,分别取了4个不同的值.
- Htmlemail邮件发送
/** * * @param path //发送附件路径 * @param name //附件名称 * @param hostName //邮件服务器名称 * @param port //服务器端口 ...
- [OpenCV]DMatch类和KeyPoints类:特征点匹配
DMatch struct CV_EXPORTS_W_SIMPLE DMatch { CV_WRAP DMatch() : queryIdx(-), trainIdx(-), imgIdx(-), d ...
- 使用ListOperations操作redis
使用ListOperations对象操作redis list: 方法 c参数 s说明 List<V> range(K key, long start, long end); K key ...