數據庫不完全恢復 以及恢復到測試環境:

?sample 1:?

1.清空歸檔日志

RMAN> crosscheck archivelog all;

RMAN> delete achivelog all;

?

2.清空數據文件。

select name from v$datafile;

rm v$datafile

?

3.恢復數據

??##check file date:??

##把db數據恢復到:2017-02-05 00:00:00


?ls -lt /ngenprdblog/
?ls -lt /ngprdb/data
?
?##change data file location to '/ngprdb/data'
?rman nocatalog target /
?catalog start with '/ngprdb/data';
?switch database to copy;

?

(解釋如下)
現在換個角度來考慮,這些控制文件記錄的都是不存在的文件,只是數據庫認為是這些文件,而我的ASM上才是真實的數據文件,那么,
我可以把ASM上的文件都認為是數據文件的copy備份,完全可以使用RMAN的catalog start with手工將這些copy“備份”加進來,數據庫會認為這些文件就只是數據文件的copy備份,然后直接switch database to copy就可以成功切換。)


?### change logfile location to '/ngprdb/data'
?select 'alter database rename file '||''''||member||''''||' to '||chr(39)||replace(member,'/ngenprdb/','/ngprdb/')||''';'? ?
from v$logfile;



?###recover database method 1
recover database;
sql 'alter database open';
?
?##recover database method 2
run{
set until time "to_date('2017-02-05 00:00:00','YYYY-MM-DD? HH24:MI:SS')";
restore database;
recover database;
sql 'alter database open resetlogs';
}


sampe 2 .restore prod db to uat db


initedruat.ora

change db_name
#db_name = edruat
db_name = edrprod

dbngt6[/home/oracle][edruat] >sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue May 9 17:06:05 2017

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 5678927872 bytes
Fixed Size 2215680 bytes
Variable Size 1006633216 bytes
Database Buffers 4664066048 bytes
Redo Buffers 6012928 bytes
Database mounted.
SQL> alter database backup controlfile to trace;

Database altered.

SQL> select * from v$diag_info;


initedruat.ora
change db_name
db_name = edruat
#db_name = edrprod


sed -n "1,2p"
sed -n "70,210p" /edruatdb/diag/rdbms/edrprod/edruat/trace/edruat_ora_8217.trc > /tmp/contrl.sql
set ic
%s/prod/uat/g
%s/PROD/UAT/g


###
ORA-01503: CREATE CONTROLFILE failed
ORA-01161: database name EDRPROD in file header does not match given name of
EDRUAT
ORA-01110: data file 1: '/edruatdb/data/system_f01.dbf'
#####

vi /tmp/contrl.sql
chang "resue" to "SET" and "NORESETLOGS" to "RESETLOGS"

CREATE CONTROLFILE SET DATABASE "DEV" RESETLOGS ARCHIVELOG

?

######
ERROR at line 1:
ORA-01503: CREATE CONTROLFILE failed
ORA-00200: control file could not be created
ORA-00202: control file: '/edruatdb/data/cntl01.ctl'
ORA-27038: created file already exists
Additional information: 1
######

mv /edruatdb/data/cntl01.ctl /edruatdb/data/cntl01.ctl.bak
mv /edruatdb/data/cntl02.ctl /edruatdb/data/cntl02.ctl.bak

?

SQL> @/tmp/contrl.sql
ORACLE instance started.

Total System Global Area 5678927872 bytes
Fixed Size 2215680 bytes
Variable Size 1006633216 bytes
Database Buffers 4664066048 bytes
Redo Buffers 6012928 bytes

Control file created.

?

SQL> recover database using backup controlfile until cancel;
ORA-00279: change 9742867340450 generated at 05/08/2017 14:00:07 needed for
thread 1
ORA-00289: suggestion : /edruatdblog/edrprod_863435250_1_37704.arc
ORA-00280: change 9742867340450 for thread 1 is in sequence #37704


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 9742867342449 generated at 05/08/2017 14:43:31 needed for
thread 1
ORA-00289: suggestion : /edruatdblog/edrprod_863435250_1_37705.arc
ORA-00280: change 9742867342449 for thread 1 is in sequence #37705
ORA-00278: log file '/edruatdblog/edrprod_863435250_1_37704.arc' no longer
needed for this recovery

?

SQL> alter database open resetlogs;

Database altered.

cd /edruatdb/change/env

SQL> @chg_env_edruat.sql

?

?

rm /edruatdb/data/temp_f*

alter tablespace TEMP add tempfile '/edruatdb/data/temp_f01.dbf' size 4000m autoextend on;
alter tablespace TEMP add tempfile '/edruatdb/data/temp_f02.dbf' size 4000m autoextend on;
alter tablespace TEMP add tempfile '/edruatdb/data/temp_f03.dbf' size 4000m autoextend on;

alter database default temporary tablespace temp;

?

?

Solution


How to restore a complete database from an RMAN backup


This note assumes an RMAN catalog is not available. The use of a catalog is optional in this scenario as the backup information is available in the controlfile.

Prior to restoring a database you must ensure you have a valid RMAN backup.

In this example we will assume all files are required to be restored:

* Datafiles
* Controlfiles
* Archivelogs (In order to perform recovery)

Online redo logs and temp files are recreated automatically by RMAN when a resetlogs is issued. Online redo logs and temp files are not backed up by RMAN

Step 1: ?Identify controlfile backup to restore


Note: If? you do not need to restore a controlfile proceed to step 3.


* Locate the RMAN backup you wish to restore.
* These files should be located in the directory where they were backed up to.
* If you have the RMAN backup log available this will also be of assistance.

Within the RMAN backup log you will see the controlfile is backed up last the the piece handle is shown.

....
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2009/01/01 12:00:00
channel ORA_DISK_1: finished piece 1 at 2009/01/01 12:00:02
piece handle=/recovery_area/V11/backupset/2009_05_0 /o1_mf_ncsnf_TAG20090506T11_501tr0h7_.bkp tag=TAG20090506T11 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02

If you do not have an RMAN backup log simply locate the last file RMAN backed up.? This should contain the controlfile backup.

Step 2: ?Restore the controlfile

2a) If you DO NOT have a spfile.

If you do have an spfile or init.ora move to Step 2b

If you do not have a valid spfile or init.ora RMAN has the ability to nomount an instance without the requirement of a spfile. This will allow you to restore your spfile from a valid backup.

% rman target /

RMAN> startup nomount force;

You will see this message:

..
starting Oracle instance without parameter file for retrieval of spfile
..

At this point you can restore the spfile:

RMAN> restore spfile from '/recovery_area/V11/backupset/2009_05_05/o1_mf_ncsnf_TAG20_501tr0h7_.bkp';

RMAN> shutdown immediate;

Once the spfile has been successfully restored proceed to Step 2b.

2b)

SQL>?startup?nomount;

Following?the?successful?nomount?of?the?instance?you?are?ready?to?restore?the
controlfile;

NOTE:?The?controlfile?will?be?restored?to?the?following?location:

SQL>?show?parameter?control_files

NAME?TYPE?VALUE
------------------------------------?-----------?------------------------------
control_files?string?/oradata/V11/control01.ctl

%?rman?target?/

You?will?see?the?message:

connected?to?target?database:?V11?(not?mounted)


RMAN> restore controlfile from '/recovery_area/V11/backupset/2009_05_06/o1_mf_ncsnf_TAG20090506T113947_501tr0h7_.bkp';

Starting restore at 2009/05/11 11:01:26
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=151 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oradata/V11/control01.ctl
Finished restore at 2009/05/11 11:01:27

In this example the controlfile has been restored to '/oradata/V11/control01.ctl'

Step 3: ?Restore and recover the database

Your next task is to restore the database and perform recovery. ?Mount the database now that the controlfile has been restored:

RMAN> alter database mount;

Now you have two options for recovery.

1) Full/Complete recovery.
2) Point In Time Recovery (PIT)

In both examples it is assumed that all archivelogs are available to perform the recovery.

?

Full recovery
==========

To Perform a full restore and recovery.

run{
restore database;
recover database;
alter database open resetlogs;
}


If you performed a complete recovery with current controlfile and online redologs in place, you might get below error when opening the database with resetlogs:

ORA-01139: RESET LOGS option only valid after an incomplete database recovery

At this point simply open the database without resetlogs option.

PITR Recovery
===========


Point-In-Time Recovery (PITR) would be used if you have decided to restore a database to a particular point in time. This may be warranted for a hardware fault or if you are aware of a database corruption that occured at a certain date/time.

run{
set until time "to_date('Aug 16 2014 10:30:00','Mon DD YYYY HH24:MI:SS')";
restore database;
recover database;
sql 'alter database open resetlogs';
}



NOTE: The above scripts may be altered to allocate more channels. Good practice would be to review the backup log and use the same number of channels for restore as that used by the backup.?

轉載于:https://www.cnblogs.com/feiyun8616/p/6396735.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/457204.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/457204.shtml
英文地址,請注明出處:http://en.pswp.cn/news/457204.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

centos7安裝java6_CentOS7.6安裝jdk1.8

2、登錄Linux服務器&#xff0c;通過rz命令將jdk導入服務器如果沒有rz命令 需要先安裝lrzszyum install lrzsz -y3、將jdk壓縮包解壓到指定路徑 -C 指定路徑4、配置環境變量編輯/etc/profile文件 在末尾加上以下內容 wq保存退出source /etc/profile文件 使配置文件生效export J…

ubuntu安裝wkhtmltopdf

下載安裝wkhtmltox系統環境 http://wkhtmltopdf.org/downloads.html wget https://bitbucket.org/wkhtmltopdf/wkhtmltopdf/downloads/wkhtmltox-0.13.0-alpha-7b36694_linux-precise-amd64.deb dpkg -i 安裝包名字 當我把它生成pdf的時候我想讓每個塊都是一頁&#xff0c;經過…

人生苦短,我用python——當我在玩python的時候我玩些什么 -

程序的基本思路 用一個txt文件記錄電腦的一天內累計使用時間累計使用時間超過若干小時就會自動關機程序開機自動運行 為什么我最后選擇了python 想著怎么寫、搜資料的時候就發現Java并不適合&#xff0c;雖然不是不能實現&#xff0c;但有好幾個問題解決起來都有點麻煩。對我這…

IO流的練習5 —— 讀取文件中的字符串,排序后寫入另一文件中

需求&#xff1a;已知s.txt文件中有這樣的一個字符串&#xff1a;“hcexfgijkamdnoqrzstuvwybpl”     請編寫程序讀取數據內容&#xff0c;把數據排序后寫入ss.txt中。分析&#xff1a;   A&#xff1a;讀取文件中的數據   B&#xff1a;把數據存在一個字符串中   C…

java解析未知key json_Gson解析JSON中動態未知字段key的方法

前面一篇文章我介紹了Gson的解析的基本方法。但我們在享受Gson解析的高度封裝帶來的便利時&#xff0c;有時可能會遇到一些特殊情況&#xff0c;比如json數據中的字段key是動態可變的時候&#xff0c;由于Gson是使用靜態注解的方式來設置實體對象的&#xff0c;因此我們很難直接…

Twisted入門教程(5)

2019獨角獸企業重金招聘Python工程師標準>>> 第五部分&#xff1a;由Twited支持的詩歌下載服務客戶端 你可以從這里從頭開始閱讀這個系列 抽象地構建客戶端 在第四部分中&#xff0c;我們構建了第一個使用Twisted的客戶端。它確實能很好地工作&#xff0c;但仍有提高…

Jquery 學習之基礎一

1.添加一個CSS類 $("button").click(function(){ $("#div1").addClass("important blue");}); 2.移除一個類 $("button").click(function(){ $("h1,h2,p").removeClass("blue");}); 3.切換類 $("button&…

**print('人生苦短 我愛Python')**

print(‘人生苦短 我愛Python’) 一、變量 **""" 1.代碼自上而下執行 2_運算符和表達式.一行一句&#xff0c;不要把多個語句寫到一行上&#xff0c;可讀性不好 3中文只能出現在引號里&#xff0c;其他地方不能出現中文 4不能隨意縮進 """**pr…

java線程提高速度_如何在JAVA中減慢線程速度

我有這個類,我在其中運行10次for循環.該類實現了Runnable接口.現在在main()中我創建了2個線程.現在兩個都將循環運行到10.但我想檢查每個線程的循環計數.如果t1超過7,則讓它休眠1秒,以便讓t2完成.但是如何實現這一目標呢&#xff1f;請參閱代碼.我嘗試但看起來完全愚蠢.只是如何…

(轉ORCLE導入導出命令)

oracle數據庫導入導出命令&#xff01;Oracle數據導入導出imp/exp 功能&#xff1a;Oracle數據導入導出imp/exp就相當與oracle數據還原與備份。 大多情況都可以用Oracle數據導入導出完成數據的備份和還原&#xff08;不會造成數據的丟失&#xff09;。 Oracle有個好處&…

筆記本(華碩UL80VT)軟件超頻setFSB

Warning !!!If you are a beginner, do not use this software. This software is for power users only. Use "SetFSB.exe" at your own risk.試了setfsb各種版本&#xff0c;基本不能打開。還有官網的免費版&#xff0c;居然不能用&#xff0c;真是很奇怪。 官網&a…

Day01-python編程基礎

1. 程序 為了完成某種特定功能&#xff0c;以某種程序設計語言編寫的有序指令的集合。程序是指揮cpu工作的“工作手冊”。計算機只能執行二進制代碼&#xff0c;程序設計語言一般類似英文&#xff0c;想要讓計算機理解你寫的程序&#xff0c;必須把程序代碼“翻譯”成計算機能…

pro c 訪問 MySQL_Pro*C??OCI??OCCI??及OCI介紹

Pro*C OCIOCCI 這三種都是C/C訪問數據庫的手段。Pro*C&#xff1a;內嵌SQL,預編譯后把內嵌SQL處理為ORACLE標準運行庫的調用&#xff0c;然后再象編譯一般的C程序一樣進行編譯、連接、運行。1.proc XXX.pc2.gcc/g XXX.c –lclntsh(PRO*C的預編譯&#xff0c;也可直接MAKEFILE…

細說Cookie

http://www.cnblogs.com/fish-li/archive/2011/07/03/2096903.html轉載于:https://www.cnblogs.com/benpaodexiaopangzi/p/5933230.html

Node.js~在linux上的部署

我們以centOS為例來說說如何部署node.js環境 一 打開centos,然后開始下載node.js包 curl --silent --location https://rpm.nodesource.com/setup_6.x | bash - yum -y install nodejs 二 安裝gcc環境 yum install gcc-c make 安裝完成! 三 安裝nodejs的npm,這是一個包程序工具…

Django中的class Meta知識點

今天來回顧一下Django中model的class Meta class Main(models.Model):img models.CharField(max_length200) # 圖片name models.CharField(max_length100) # 名稱trackid models.CharField(max_length16) # 通用idclass Meta:abstract True #抽象類class MainWheel(…

python wheel使用_Python wheel.Wheel方法代碼示例

# 需要導入模塊: from pip import wheel [as 別名]# 或者: from pip.wheel import Wheel [as 別名]def from_line(cls, name, comes_fromNone, prereleasesNone):"""Creates an InstallRequirement from a name, which might be arequirement, directory contai…

英語學習Day1

今天要開始學英語了&#xff0c;我這個人沒什么長性&#xff0c;語言這種東西對我來說又是很不擅長的一種技能&#xff0c;那為什么要學英語呢&#xff1f;我要做翻譯&#xff0c;也是呵呵了&#xff0c;主要是我想賺錢&#xff0c;這個力量能夠支撐我吧&#xff0c;我想。 網上…

LeetCode題解-3-Longest Substring Without Repeating Characters

2019獨角獸企業重金招聘Python工程師標準>>> 解題思路 首先要讀懂題目&#xff0c;它要求的是找到最長的子串&#xff0c;并且子串中沒有出現重復的字符。 我的想法&#xff0c;是用一個map存儲每個字符最后出現的位置&#xff0c;還要有個變量start&#xff0c;它用…

Day02-變量_數據類型和運算符

1 數據類型 不同類型的變量可以進行的運算是不同的&#xff0c;所以必須理解變量的類型&#xff0c;python中數據類型可以分為&#xff1a; 內置類型 數值類型&#xff1a;整型int&#xff0c;浮點型float&#xff0c;復數&#xff08;complex&#xff09; 35j str:字符串 b…