首頁 資料庫 mysql教程 RMAN 异机迁移

RMAN 异机迁移

Jun 07, 2016 pm 05:20 PM
oracle 資料庫

目标库准备实例名准备:此实例名为原库的实例名。 不要随意设, 因控制文件里是有记录DB_NAME的, 如果你随便设置实例名,是没办

1. 环境说明:
原机:192.168.102.156     Oracle 10.2.0.1
目标:192.168.102.157     ORACLE 10.2.0.1
2.对数据库做创建一张表。
SQL> create table rmantest(id number(9));
Table created.
SQL> insert into rmantest(id) values(88);
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
3. 目标库准备实例名准备:此实例名为原库的实例名。 不要随意设, 因控制文件里是有记录DB_NAME的, 如果你随便设置实例名,是没办法完成迁移的。
[oracle@GOLDENGATE2 ~]$ export ORACLE_SID=gg1
[oracle@GOLDENGATE2 ~]$ echo $ORACLE_SID
gg1
4. 目标库准备参数文件。
(1) 在原库创建一个PFILE文件。
SQL> create pfile='/home/oracle/initgg1.ora' from spfile;
File created.
(2) 奖参数文件移至目标库。
[oracle@GOLDENGATE1 ~]$ scp initgg1.oraoracle@192.168.102.157:/home/oracle
oracle@192.168.102.157'spassword:
initgg1.ora                                                                                                100% 1051     1.0KB/s   00:00
5. 在目标库创建参数文件中所需要的目录。
[oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/adump
[oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/bdump
[oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/cdump
[oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/dpdump
[oracle@GOLDENGATE2 ~]$ mkdir -p admin/gg1/udump
[oracle@GOLDENGATE2 ~]$ mkdir flash_recovery_area
[oracle@GOLDENGATE2 ~]$ mkdir -p oradata/gg1
[oracle@GOLDENGATE2 ~]$ mkdir archivelog
6. 在目标库创建SPFILE文件,并将数据库启动到NOMOUNT状态。
[oracle@GOLDENGATE2 ~]$ export ORACLE_SID=gg1
[oracle@GOLDENGATE2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Sep 21 01:21:51 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> create spfile from pfile='/home/oracle/initgg1.ora';
File created.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1218292 bytes
Variable Size              83888396 bytes
Database Buffers           75497472 bytes
Redo Buffers                7168000 bytes
 
7. 对原数据库进行热备份。 必备条件: 数据库属归档模式。
[oracle@GOLDENGATE1 ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Sep 21 01:21:49 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: GG1 (DBID=1620494887)
RMAN>  run{
allocate channel a1 type disk;
allocate channel a2 type disk;
backup format='/home/oracle/rman/full_%d_%T_%s'  database;
backup format='/home/oracle/rman/arch_%d_%T_%s' archivelog all;
backup format='/home/oracle/rman/ctl_%U' current controlfile;
release channel a2;
 release channel a1;
}2> 3> 4> 5> 6> 7> 8> 9>
released channel: ORA_DISK_1
allocated channel: a1
channel a1: sid=158 devtype=DISK
allocated channel: a2
channel a2: sid=141 devtype=DISK
Starting backup at 21-SEP-12
channel a1: starting full datafile backupset
channel a1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/oracle/oradata/gg1/system01.dbf
input datafile fno=00005 name=/home/oracle/oradata/gg1/example01.dbf
input datafile fno=00003 name=/home/oracle/oradata/gg1/sysaux01.dbf
channel a1: starting piece 1 at 21-SEP-12
channel a2: starting full datafile backupset
channel a2: specifying datafile(s) in backupset
input datafile fno=00006 name=/home/oracle/oradata/gg1/gg01.dbf
input datafile fno=00002 name=/home/oracle/oradata/gg1/undotbs01.dbf
input datafile fno=00004 name=/home/oracle/oradata/gg1/users01.dbf
channel a2: starting piece 1 at 21-SEP-12
channel a2: finished piece 1 at 21-SEP-12
piece handle=/home/oracle/rman/full_GG1_20120921_10 tag=TAG20120921T013222 comment=NONE
channel a2: backup set complete, elapsed time: 00:00:25
channel a2: starting full datafile backupset
channel a2: specifying datafile(s) in backupset
including current control file in backupset
channel a2: starting piece 1 at 21-SEP-12
channel a2: finished piece 1 at 21-SEP-12
piece handle=/home/oracle/rman/full_GG1_20120921_11 tag=TAG20120921T013222 comment=NONE
channel a2: backup set complete, elapsed time: 00:00:03
channel a2: starting full datafile backupset
channel a2: specifying datafile(s) in backupset
including current SPFILE in backupset
channel a2: starting piece 1 at 21-SEP-12
channel a2: finished piece 1 at 21-SEP-12
piece handle=/home/oracle/rman/full_GG1_20120921_12 tag=TAG20120921T013222 comment=NONE
channel a2: backup set complete, elapsed time: 00:00:02
channel a1: finished piece 1 at 21-SEP-12
piece handle=/home/oracle/rman/full_GG1_20120921_9 tag=TAG20120921T013222 comment=NONE
channel a1: backup set complete, elapsed time: 00:00:48
Finished backup at 21-SEP-12
Starting backup at 21-SEP-12
current log archived
channel a1: starting archive log backupset
channel a1: specifying archive log(s) in backup set
input archive log thread=1 sequence=4 recid=1 stamp=794527523
channel a1: starting piece 1 at 21-SEP-12
channel a2: starting archive log backupset
channel a2: specifying archive log(s) in backup set
input archive log thread=1 sequence=5 recid=2 stamp=794538401
input archive log thread=1 sequence=6 recid=3 stamp=794539337
input archive log thread=1 sequence=7 recid=4 stamp=794539385
channel a2: starting piece 1 at 21-SEP-12
channel a2: finished piece 1 at 21-SEP-12
piece handle=/home/oracle/rman/arch_GG1_20120921_13 tag=TAG20120921T013312 comment=NONE
channel a2: backup set complete, elapsed time: 00:00:02
channel a1: finished piece 1 at 21-SEP-12
piece handle=/home/oracle/rman/arch_GG1_20120921_14 tag=TAG20120921T013312 comment=NONE
channel a1: backup set complete, elapsed time: 00:00:03
channel a2: starting archive log backupset
channel a2: specifying archive log(s) in backup set
input archive log thread=1 sequence=8 recid=5 stamp=794539992
channel a2: starting piece 1 at 21-SEP-12
channel a2: finished piece 1 at 21-SEP-12
piece handle=/home/oracle/rman/arch_GG1_20120921_15 tag=TAG20120921T013312 comment=NONE
channel a2: backup set complete, elapsed time: 00:00:02
Finished backup at 21-SEP-12
Starting backup at 21-SEP-12
channel a1: starting full datafile backupset
channel a1: specifying datafile(s) in backupset
including current control file in backupset
channel a1: starting piece 1 at 21-SEP-12
channel a1: finished piece 1 at 21-SEP-12
piece handle=/home/oracle/rman/ctl_0gnlndut_1_1 tag=TAG20120921T013317 comment=NONE
channel a1: backup set complete, elapsed time: 00:00:02
Finished backup at 21-SEP-12
released channel: a2
released channel: a1
8. 将备份移至目标机。
[oracle@GOLDENGATE1 ~]$ cd rman/
[oracle@GOLDENGATE1 rman]$ ls
arch_GG1_20120921_13  arch_GG1_20120921_15  full_GG1_20120921_10  full_GG1_20120921_12
arch_GG1_20120921_14  ctl_0gnlndut_1_1      full_GG1_20120921_11  full_GG1_20120921_9
[oracle@GOLDENGATE1 rman]$ scp *oracle@192.168.102.157:/home/oracle/rman
oracle@192.168.102.157'spassword:
arch_GG1_20120921_13                                                                                       100%   13MB  12.8MB/s   00:01  
arch_GG1_20120921_14                                                                                       100%   25MB  12.5MB/s   00:02  
arch_GG1_20120921_15                                                                                       100%  281KB 281.0KB/s   00:00  
ctl_0gnlndut_1_1                                                                                           100% 6944KB   6.8MB/s   00:00  
full_GG1_20120921_10                                                                                       100%   33MB   8.2MB/s   00:04  
full_GG1_20120921_11                                                                                       100% 6944KB   6.8MB/s   00:00  
full_GG1_20120921_12                                                                                       100%   96KB  96.0KB/s   00:01  
full_GG1_20120921_9                                                                                        100%  561MB  11.9MB/s   00:47  
9. 在目标机上恢复控制文件。
[oracle@GOLDENGATE2 rman]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Sep 21 01:36:10 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: gg1 (not mounted)
RMAN> restore controlfile from '/home/oracle/rman/ctl_0gnlndut_1_1';
Starting restore at 21-SEP-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/home/oracle/oradata/gg1/control01.ctl
output filename=/home/oracle/oradata/gg1/control02.ctl
output filename=/home/oracle/oradata/gg1/control03.ctl
Finished restore at 21-SEP-12
10. 启动数据库到MOUNT状态。
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
11.恢复数据库。
RMAN> restore database;
Starting restore at 21-SEP-12
Starting implicit crosscheck backup at 21-SEP-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 7 objects
Finished implicit crosscheck backup at 21-SEP-12
Starting implicit crosscheck copy at 21-SEP-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 21-SEP-12
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /home/oracle/oradata/gg1/undotbs01.dbf
restoring datafile 00004 to /home/oracle/oradata/gg1/users01.dbf
restoring datafile 00006 to /home/oracle/oradata/gg1/gg01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/rman/full_GG1_20120921_10
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/rman/full_GG1_20120921_10 tag=TAG20120921T013222
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /home/oracle/oradata/gg1/system01.dbf
restoring datafile 00003 to /home/oracle/oradata/gg1/sysaux01.dbf
restoring datafile 00005 to /home/oracle/oradata/gg1/example01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/rman/full_GG1_20120921_9
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/rman/full_GG1_20120921_9 tag=TAG20120921T013222
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 21-SEP-12
RMAN> recover database;
Starting recover at 21-SEP-12
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=8
channel ORA_DISK_1: reading from backup piece /home/oracle/rman/arch_GG1_20120921_15
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/rman/arch_GG1_20120921_15 tag=TAG20120921T013312
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
archive log filename=/home/oracle/archivelog/1_8_794474474.dbf thread=1 sequence=8
unable to find archive log
archive log thread=1 sequence=9
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 09/21/2012 01:38:18
RMAN-06054: media recovery requesting unknown log: thread 1 seq 9 lowscn 529513
查看原库日志:
[oracle@GOLDENGATE1 archivelog]$ ls
1_4_794474474.dbf  1_5_794474474.dbf  1_6_794474474.dbf  1_7_794474474.dbf  1_8_794474474.dbf
[oracle@GOLDENGATE1 archivelog]$
干, 这里就没有那日志。
因为原库并未生成SEQ为9的日志,这里根本就没有9的备份。
用SQLPLUS连进行执行恢复。
SQL> recover database using backup controlfile;
ORA-00279: change 529513 generated at 09/21/2012 01:33:11 needed for thread 1
ORA-00289: suggestion : /home/oracle/archivelog/1_9_794474474.dbf
ORA-00280: change 529513 for thread 1 is in sequence #9
 
Specify log: {=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
12。 打开数据库。
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/home/oracle/oradata/gg1/system01.dbf'
因为控制文件和数据文件不一致。
解决办法:
修改参数文件:增加 _allow_resetlogs_corruption='TURE'
关闭数据库,重建SPFILE文件,,并启动到NOMOUNT状态。
打开数据库:
SQL> alter database open resetlogs;
Database altered.
13。 检查
REDO日志和临时表空间文件会在打开数据库时根据控制文件中的记录去创建。
查看原库所建的表:
SQL> select * from rmantest;
        ID
----------
        88
迁移完成。

linux

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系統,解釋
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1664
14
CakePHP 教程
1423
52
Laravel 教程
1318
25
PHP教程
1269
29
C# 教程
1248
24
MySQL:世界上最受歡迎的數據庫的簡介 MySQL:世界上最受歡迎的數據庫的簡介 Apr 12, 2025 am 12:18 AM

MySQL是一種開源的關係型數據庫管理系統,主要用於快速、可靠地存儲和檢索數據。其工作原理包括客戶端請求、查詢解析、執行查詢和返回結果。使用示例包括創建表、插入和查詢數據,以及高級功能如JOIN操作。常見錯誤涉及SQL語法、數據類型和權限問題,優化建議包括使用索引、優化查詢和分錶分區。

oracle怎麼循環創建游標 oracle怎麼循環創建游標 Apr 12, 2025 am 06:18 AM

Oracle 中,FOR LOOP 循環可動態創建游標, 步驟為:1. 定義游標類型;2. 創建循環;3. 動態創建游標;4. 執行游標;5. 關閉游標。示例:可循環創建游標,顯示前 10 名員工姓名和工資。

為什麼要使用mysql?利益和優勢 為什麼要使用mysql?利益和優勢 Apr 12, 2025 am 12:17 AM

選擇MySQL的原因是其性能、可靠性、易用性和社區支持。 1.MySQL提供高效的數據存儲和檢索功能,支持多種數據類型和高級查詢操作。 2.採用客戶端-服務器架構和多種存儲引擎,支持事務和查詢優化。 3.易於使用,支持多種操作系統和編程語言。 4.擁有強大的社區支持,提供豐富的資源和解決方案。

HDFS配置CentOS需要哪些步驟 HDFS配置CentOS需要哪些步驟 Apr 14, 2025 pm 06:42 PM

在CentOS系統上搭建Hadoop分佈式文件系統(HDFS)需要多個步驟,本文提供一個簡要的配置指南。一、前期準備安裝JDK:在所有節點上安裝JavaDevelopmentKit(JDK),版本需與Hadoop兼容。可從Oracle官網下載安裝包。環境變量配置:編輯/etc/profile文件,設置Java和Hadoop的環境變量,使系統能夠找到JDK和Hadoop的安裝路徑。二、安全配置:SSH免密登錄生成SSH密鑰:在每個節點上使用ssh-keygen命令

oracle日誌寫滿怎麼辦 oracle日誌寫滿怎麼辦 Apr 12, 2025 am 06:09 AM

Oracle 日誌文件寫滿時,可採用以下解決方案:1)清理舊日誌文件;2)增加日誌文件大小;3)增加日誌文件組;4)設置自動日誌管理;5)重新初始化數據庫。在實施任何解決方案前,建議備份數據庫以防數據丟失。

甲骨文在商業世界中的作用 甲骨文在商業世界中的作用 Apr 23, 2025 am 12:01 AM

Oracle不僅是數據庫公司,還是雲計算和ERP系統的領導者。 1.Oracle提供從數據庫到雲服務和ERP系統的全面解決方案。 2.OracleCloud挑戰AWS和Azure,提供IaaS、PaaS和SaaS服務。 3.Oracle的ERP系統如E-BusinessSuite和FusionApplications幫助企業優化運營。

oracle視圖怎麼導出 oracle視圖怎麼導出 Apr 12, 2025 am 06:15 AM

可以通過 EXP 實用程序導出 Oracle 視圖:登錄 Oracle 數據庫。啟動 EXP 實用程序,指定視圖名稱和導出目錄。輸入導出參數,包括目標模式、文件格式和表空間。開始導出。使用 impdp 實用程序驗證導出。

MySQL與其他數據庫:比較選項 MySQL與其他數據庫:比較選項 Apr 15, 2025 am 12:08 AM

MySQL適合Web應用和內容管理系統,因其開源、高性能和易用性而受歡迎。 1)與PostgreSQL相比,MySQL在簡單查詢和高並發讀操作上表現更好。 2)相較Oracle,MySQL因開源和低成本更受中小企業青睞。 3)對比MicrosoftSQLServer,MySQL更適合跨平台應用。 4)與MongoDB不同,MySQL更適用於結構化數據和事務處理。

See all articles