RMAN异机恢复主要步骤和注意事项
以后改行了或老了回头看看,我曾经会这些,也是件愉快的事
【备份】
--创建目录
[oracle@test20 backup]$ mkdir -p /home/oracle/backup
--备份脚本
[oracle@test20 backup]$ cat backup2.sh
#!/bin/bash
source /home/oracle/.bash_profile
$ORACLE_HOME/bin/rman target / log=/home/oracle/backup/backup_`date +%m%d`.log append <<EOF
CONFIGURE CONTROLFILE AUTOBACKUP ON;
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;
sql 'alter system archive log current';
#backup database format '/home/oracle/backup/data_%d_%T_%U.bak';
#compressed
backup as compressed backupset database format '/home/oracle/backup/data_%d_%T_%U.bak';
#backup archivelog all format '/home/oracle/backup/arch_%d_%T_%U.bak';
#compressed
backup as compressed backupset archivelog all format '/home/oracle/backup/arch_%d_%T_%U.bak';
#for standby
#backup current controlfile for standby format '/home/oracle/backup/ctl_%d_%T_%U.bak';
#for restore
backup current controlfile format '/home/oracle/backup/ctl_%d_%T_%U.bak';
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
EOF
--授权
[oracle@test20 backup]$ chmod +x backup.sh
--备份
[oracle@test20 backup]$ ./backup.sh
--传输
【恢复】
--创建目录。机器已装oracle软件,DB已关闭
mkdir -p /u01/app/oracle/admin/payme/{adump,bdump,cdump,dpdump,udump,pfile}
mkdir -p /u01/app/oracle/oradata/payme
mkdir -p /u01/app/oracle/fast_recovery_area/payme
--设置参数文件和SID
echo 'db_name=payme' > $ORACLE_HOME/dbs/initpayme.ora
more $ORACLE_HOME/dbs/initpayme.ora
export ORACLE_SID=payme
rman target /
--原始数据库dbid payme (DBID=1239133617) 从RMAN备份日志查下
set dbid 1239133617
--启动
SQL> startup nomount;
--恢复控制文件
rman target /
RMAN> restore controlfile from '/home/oracle/backup/ctl_payme_20191108_35ugc7rl_1_1.bak';
...
#会输出新的控制文件
output file name=/u01/app/oracle/oradata/datafile/TEST154/controlfile/o1_mf_grv284j3_.ctl
output file name=/u01/app/oracle/oradata/flash_recovery_area/TEST154/controlfile/o1_mf_grv284k0_.ctl
--启动实例到mount状态
alter database mount;
--检查备份有效性
crosscheck backup;
--在新的控制文件中注册数据文件备份和归档备份。结尾处要带/,且不能有空格,注意文件权限
catalog start with '/home/oracle/backup/';
--主库执行,生成rename SQL,替换成对应数据文件路径
col AA FOR a200
SET pagesize 100
SET line 200
SELECT 'set newname for datafile ' || A.FILE# || ' to "' || A.NAME || '";' AS AA
FROM V$DATAFILE A
UNION ALL
SELECT 'set newname for tempfile ' || A.FILE# || ' to "' || A.NAME || '";' AS AA
FROM V$TEMPFILE A;
--开始恢复
RMAN> 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 1 to "/u01/app/oracle/oradata/payme/system01.dbf";
set newname for datafile 2 to "/u01/app/oracle/oradata/payme/sysaux01.dbf";
set newname for datafile 3 to "/u01/app/oracle/oradata/payme/undotbs01.dbf";
set newname for datafile 4 to "/u01/app/oracle/oradata/payme/tbs_1.dbf";
set newname for datafile 5 to "/u01/app/oracle/oradata/payme/users01.dbf";
set newname for datafile 6 to "/u01/app/oracle/oradata/payme/example01.dbf";
...
set newname for tempfile 1 to "/u01/app/oracle/oradata/payme/temp01.dbf";
set newname for tempfile 2 to "/u01/app/oracle/oradata/payme/temp_01.dbf";
set newname for tempfile 3 to "/u01/app/oracle/oradata/payme/TEMP21.dbf";
set newname for tempfile 4 to "/u01/app/oracle/oradata/payme/temp_pfpt.dbf";
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
restore database;
switch datafile all;
switch tempfile all;
recover database;
}
renamed tempfile 1 to /u01/app/oracle/oradata/payme/temp01.dbf in control file
renamed tempfile 2 to /u01/app/oracle/oradata/payme/temp_01.dbf in control file
Starting recover at 2019-11-08 16:17:31
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=486
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/arch_payme_20191108_34ugc7r6_1_1.bak
channel ORA_DISK_1: piece handle=/home/oracle/backup/arch_payme_20191108_34ugc7r6_1_1.bak tag=TAG20191108T160349
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/oradata/flash_recovery_area/arch_1021737825_1_486.arc thread=1 sequence=486
unable to find archived log
archived log thread=1 sequence=487
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/08/2019 16:17:33
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 487 and starting SCN of 69884756
【处理redo log和temp】
--如果实例安装路径不同,或者redo log和临时表空间对应的文件在目标服务器上找不到
SQL> col status for a7
SQL> col type for a7;
SQL> col member for a64;
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_RECOVE
---------- ------- ------- ---------------------------------------------------------------- ---------
1 ONLINE /u01/app/oracle/oradata/dbtest/actlog/redo01.log NO
2 ONLINE /u01/app/oracle/oradata/dbtest/actlog/redo02.log NO
3 ONLINE /u01/app/oracle/oradata/dbtest/actlog/redo03.log NO
show parameter standby_file_management;
--alter system set standby_file_management=MANUAL scope=both;
--新、旧redo日志路径一致直接clear就可以,自动生成新的redo日志。不一致了先执行alter
alter database rename file '/u01/app/oracle/oradata/dbtest/actlog/redo01.log' to '/u01/app/oracle/oradata/flash_recovery_area/payme/onlinelog/redo01.log';
alter database clear logfile group 1;
alter database rename file '/u01/app/oracle/oradata/dbtest/actlog/redo02.log' to '/u01/app/oracle/oradata/flash_recovery_area/payme/onlinelog/redo02.log';
alter database clear logfile group 2;
alter database rename file '/u01/app/oracle/oradata/dbtest/actlog/redo03.log' to '/u01/app/oracle/oradata/flash_recovery_area/payme/onlinelog/redo03.log';
alter database clear logfile group 3;
--resetlogs,观察alter日志看是否有异常
SQL> alter database open resetlogs;
若TEMP文件路径不一致,先drop再add,此时DB要open才可以
SQL> col name for a80;
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/payme/temp01.dbf
/u01/app/oracle/oradata/payme/temp_01.dbf
alter database tempfile '/u01/app/oracle/oradata/payme/temp01.dbf' drop;
alter database tempfile '/u01/app/oracle/oradata/payme/temp_01.dbf' drop;
/*
--ORA-01109: 数据库未打开 需要在open状态下添加
alter tablespace temp add tempfile '/u01/app/oracle/oradata/payme/temp01.dbf' size 100M autoextend on next 10M maxsize 4G;
alter tablespace temp add tempfile '/u01/app/oracle/oradata/payme/temp_01.dbf' size 100M autoextend on next 10M maxsize 4G;
*/
【创建spfile】
create spfile from pfile='$ORACLE_HOME/dbs/initpayme.ora';
create pfile from spfile;
【配置环境变量】
vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
umask 022
export ORACLE_HOSTNAME=test154
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
#export ORACLE_SID=test154
export ORACLE_SID=payme
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="zh_CN.UTF-8"
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
alias sql="sqlplus '/as sysdba'"
set line 200
set pagesize 200
stty erase ^h
set _EDITOR=vi
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias dbs='cd /u01/app/oracle/product/11.2.0/dbhome_1/dbs/'
alias admin='cd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/'
alias oralog='cd /u01/app/oracle/diag/rdbms/payme/payme/trace/'
【修改TNSNAME和LISTENER】
--TNSNAME
payme =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL= TCP)(HOST = 192.168.xx.154)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME =payme)
)
)
--LISTENER
LISTENER=
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.xx.154)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY =EXTPROC1521))
)
)
SID_LIST_LISTENER=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = payme)
(ORACLE_HOME =/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = payme)
)
)
ADR_BASE_LISTENER = /u01/app/oracle
RMAN异机恢复主要步骤和注意事项的更多相关文章
- Oracle 单实例 迁移到 RAC 实例 -- 使用RMAN 异机恢复
Oracle 官网有关单实例迁移到RAC的一个步骤说明: How to Convert 10g Single-Instance database to 10g RAC using Manual Con ...
- 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 ...
- Oracle12c RAC RMAN异机恢复
######################################################## #编辑pfile文件initspdb.ora vi /oracle/app/oracl ...
- RMAN异机恢复步骤及故障处理
一.測试机安装OS+Oracle Software.包含配置oracle用户.组和环境变量(略) 二.開始异机恢复 1. 复制源库最新备份集.初始化參数.password文件到測试机 [oracle@ ...
- RMAN异机恢复遭遇ORA-01547、ORA-01152、ORA-01110错误案例
测试环境: 操作系统 : Red Hat Enterprise Linux ES release 4 (Nahant Update 4) VMWARE 数据库 : O ...
- 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异机恢复,全部恢复和增量恢复
1.首先准备工作:hostname 192.168.222.11 ol7.localdomain ol7建立相关目录:mkdir -p /u01/app/oracle/oradata/DB11G/mk ...
随机推荐
- Spring Cloud第六篇 | Hystrix仪表盘监控Hystrix Dashboard
本文是Spring Cloud专栏的第六篇文章,了解前五篇文章内容有助于更好的理解本文: Spring Cloud第一篇 | Spring Cloud前言及其常用组件介绍概览 Spring Cloud ...
- 基于webpack实现多html页面开发框架八 html引入图片打包和公共页面模块复用
一.解决什么问题 1.html中img引入的图片地址没有被替换,找不到图片 2.html公共部分复用问题,如头部.底部.浮动层等 二.html中img引入图片问题解决 1.在index.html插入i ...
- ios-AutoLayout(自动布局代码控制)简单总结
转自:http://blog.sina.com.cn/s/blog_7c336a830102vaht.html 原理:IOS6.0 之后,苹果优化了UI界面的布局方式,提出了自动布局的概念,和之前的a ...
- Cesium专栏-大量gltf三维模型加载
Cesium 是一款面向三维地球和地图的,世界级的JavaScript开源产品.它提供了基于JavaScript语言的开发包,方便用户快速搭建一款零插件的虚拟地球Web应用,并在性能,精度,渲染质量以 ...
- Binary Search Tree analog
Description Binary Search Tree, abbreviated as BST, is a kind of binary tree maintains the following ...
- [问题记录]——log4net记录多个级别文件
目录 前言 Log4net 测试 小结 前言 不知不觉可都快又一年了,最近这段时间一直在忙着图形方面的东西(确实快给我搞死了),虽说时间还是相对有的,但是精力耗费的十有十一,把问题记录单开一栏,是为了 ...
- TVP5150 PAL/NTSC ccd cmos 模拟摄像头视频 转换 VGA输出
新做了一批 视频模块,特此总结下: 解码ic:tvp5150 输入:CVBS PAL 输出:DVP(bt565 yuv dvp8 含vs hs) 测试分辨力:(vga输出 640*480) 实 ...
- CrazyBingo mini VIP 2.0 视频开发板 NIOS移植例程(原创)
创建一个NIOS环境 注意事项 前言:(先了解下硬件) 本板卡目前主要适合以下几类人: (1)对FPGA 逻辑开发有强烈的兴趣,并且有一定的HDL基础 (2)计划采用FPGA图像架构,学习并研究图像算 ...
- Day 10 面向对象基础
目录 面对过程编程 面向对象编程 类 定义类 对象 定义对象 定制对象独有特征 面对过程编程 分析解决问题所需要的步骤, 用函数将这些步骤一步一步实现, 使用的时候一个个调用就可以了 优点: 复杂的问 ...
- JSP请求是如何被处理的?jsp的执行原理
客户端通过浏览器发送jsp请求,服务器端接受到请求后,判断是否是第一次请求该页面,或者该页面是否改变,若是,服务器将jsp页面翻译为servlet,jvm将servlet编译为.class文件,字节码 ...