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 ...
随机推荐
- Vue&Cesium&Ribbon界面: 将桌面GIS搬进浏览器
上一篇文章在这里:vue集成cesium,webgis平台第一步 把界面改了一下,开始实际填充功能. Ribbon是一种以面板及标签页为架构的用户界面(User Interface),原先出现在Mic ...
- unity3d WeelCollider 漂移
物理漂移 基础控制不在说明 Forward Friction 为轮胎直线摩擦力 Sideways Friction 为侧面摩擦力 Extremum Slip为速度达到多少后产生漂移效果 Extremu ...
- Chapter 3 :代码的坏味道
"如果尿布臭了,就换掉它." --Beck奶奶,论保持小孩清洁的哲学 代码的坏味道这一章集中论述该何时重构.具体的重构方法在后面的章节. "没有任何度量规矩比得上见识广博 ...
- Electron node integration enabled 设置
解决办法 参考博客:https://blog.csdn.net/hwytree/article/details/103167175
- H5中被废弃的标签
<br>换行,已经被<p>标签进行替换 <hr>画线 <font> <b>,<u>,<i>,<s>:加粗 ...
- 伸缩容器-display:flex设置flex属性的理解
1.flex属性 1.1 flex属性是flex-grow, flex-shrink 和 flex-basis的简写,默认值为0 1 auto. flex-grow: 定义项目的放大比例,默认为0,即 ...
- Django之models模块
一.字段 1. AutoField(Field) int自增列,必须填入参数 primary_key=True 2.BigAutoField(AutoField) bigint自增列,必须填入参数 p ...
- Caffe源码-Layer类
Layer类简介 Layer是caffe中搭建网络的基本单元,caffe代码中包含大量Layer基类派生出来的各种各样的层,各自通过虚函数 Forward() 和 Backward() 实现自己的功能 ...
- 【每天一题】LeetCode 0067. 二进制求和
开源地址:https://github.com/jiauzhang/algorithms 题目描述 * https://leetcode-cn.com/problems/add-binary * 给定 ...
- 关于MySQL注入漏洞到获取webshell
关于PHP网站报错性注入拿shell的方法,定位到报错在某个字段上的利用方式: 条件1: 爆出了网站的物理路径 条件2:MySQL具有into outfile权限 SQL语句为: 假如字段为2: un ...