search
HomeDatabaseMysql Tutorial oracle备份恢复之rman恢复到异机

注意事项:1此处实验环境为同平台,同字节序,同版本,源机器和目标机器相同的目录结构。2目标机器只需要安装oracle数据库软件即可。3第一次利用备份恢复测试环

 

注意事项:

1 此处实验环境为同平台,同字节序,美国空间,同版本,源机器和目标机器相同的目录结构。

2 目标机器只需要安装oracle数据库软件即可。

3 第一次利用备份恢复测试环境,香港服务器,之后从源机器拷贝备份到目标机器并在控制文件中注册,再见行恢复测试。

 

一 拷贝参数文件备份、控制文件备份、数据文件备份、以及归档备份到新主机上

 

1 rman 连接到源数据库

 

[oracle@oracle dbs]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Dec 11 19:02:05 2012

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

connected to target database: CRM (DBID=3601019238)

RMAN>

2  分别列出参数文件备份,控制文件备份,数据文件备份,以及归档备份的名字

 

参数文件备份如下:

RMAN> list backup of spfile;

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
13      Full    7.11M      DISK        00:00:04     09-DEC-12     
        BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: TAG20121209T040058
        Piece Name: /oracle/app/db1/dbs/0dnsd96i_1_1
  SPFILE Included: Modification time: 09-DEC-12

控制文件备份如下:

RMAN> list backup of controlfile;

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
13      Full    7.11M      DISK        00:00:04     09-DEC-12     
        BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: TAG20121209T040058
        Piece Name: /oracle/app/db1/dbs/0dnsd96i_1_1
  Control File Included: Ckp SCN: 2779528241   Ckp time: 09-DEC-12

数据文件备份如下:

RMAN> list backup of database;

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
12      Full    599.38M    DISK        00:03:33     09-DEC-12     
        BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: TAG20121209T040058
        Piece Name: /oracle/app/db1/dbs/0cnsd8vq_1_1
  List of Datafiles in backup set 12
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 2779528081 09-DEC-12 /oracle/test/system1.dbf
  2       Full 2779528081 09-DEC-12 /oracle/test/zxb.dbf
  3       Full 2779528081 09-DEC-12 /oracle/test/sysaux01.dbf
  4       Full 2779528081 09-DEC-12 /oracle/test/users01.dbf
  5       Full 2779528081 09-DEC-12 /oracle/test/zxa.dbf
  6       Full 2779528081 09-DEC-12 /oracle/test/test1.dbf
  7       Full 2779528081 09-DEC-12 /oracle/test/zxc.dbf
  8       Full 2779528081 09-DEC-12 /oracle/test/undotbs1.dbf
  9       Full 2779528081 09-DEC-12 /oracle/test/zxbig.dbf

 

列出归档备份如下:

RMAN> list backup of archivelog all;

注意:归档的备份应该包括当前联机日志文件。

3 copy 这些备份到新的主机

 

二 恢复参数文件及控制文件

 

 1 配置新主机上的ORACLE_SID

  export   ORACLE_SID=CRM

 

 2 在新主机上发起rman连接

 

[oracle@oracle dbs]$ rman target /

 

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Dec 10 05:49:11 2012

 

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

 

connected to target database (not started)

 

3  设置dbid 并启动实例到nomount状态

   

RMAN> set dbid 3601019238

 

executing command: SET DBID

 

RMAN> startup nomount

 

startup failed: ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/oracle/app/db1/dbs/initCRM.ora'

 

starting Oracle instance without parameter file for retrival of spfile

Oracle instance started

 

Total System Global Area     159383552 bytes

 

Fixed Size                     2019224 bytes

Variable Size                 67108968 bytes

Database Buffers              83886080 bytes

Redo Buffers                   6369280 bytes

注意:在rman下即使没有参数文件,默认也会启动一个DUMMY实例,香港服务器租用,以便能够恢复参数文件。

4  恢复spfile文件

 

RMAN> restore spfile to '/oracle/app/db1/dbs/spfileCRM.ora' from '/oracle/app/db1/dbs/0dnsd96i_1_1';

 

Starting restore at 10-DEC-12

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=34 devtype=DISK

 

channel ORA_DISK_1: autobackup found: /oracle/app/db1/dbs/0dnsd96i_1_1

channel ORA_DISK_1: SPFILE restore from autobackup complete

Finished restore at 10-DEC-12

 

5 startup force nomount

 

RMAN> startup force nomount;

 

Oracle instance started

 

Total System Global Area     322961408 bytes

 

Fixed Size                     2020480 bytes

Variable Size                 96471936 bytes

Database Buffers             218103808 bytes

Redo Buffers                   6365184 bytes

 

6 恢复控制文件

 

RMAN> restore controlfile to '/oracle/CRM2/CRM/control01.ctl' from '/oracle/app/db1/dbs/0dnsd96i_1_1';

 

Starting restore at 10-DEC-12

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=210 devtype=DISK

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:04

Finished restore at 10-DEC-12

 

 

cp /oracle/CRM2/CRM/control01.ctl /oracle/CRM2/CRM/control02.ctl

 

7 启动数据库到加载状态

RMAN> alter database mount;

 

database mounted

released channel: ORA_DISK_1

 

三  在新控制文件中注册数据文件备份和归档备份

 

RMAN> catalog start with '/backup/';

 

searching for all files that match the pattern /backup/

 

List of Files Unknown to the Database

=====================================

File Name: /backup/0ensd96n_1_1

File Name: /backup/0bnsd8vn_1_1

File Name: /backup/0cnsd8vq_1_1

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

 

List of Cataloged Files

=======================

File Name: /backup/0ensd96n_1_1

File Name: /backup/0bnsd8vn_1_1

File Name: /backup/0cnsd8vq_1_1

 

四  恢复整个库

 

1 RMAN> restore database;

 

Starting restore at 10-DEC-12

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=209 devtype=DISK

 

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /oracle/test/system1.dbf

restoring datafile 00002 to /oracle/test/zxb.dbf

restoring datafile 00003 to /oracle/test/sysaux01.dbf

restoring datafile 00004 to /oracle/test/users01.dbf

restoring datafile 00005 to /oracle/test/zxa.dbf

restoring datafile 00006 to /oracle/test/test1.dbf

restoring datafile 00007 to /oracle/test/zxc.dbf

restoring datafile 00008 to /oracle/test/undotbs1.dbf

restoring datafile 00009 to /oracle/test/zxbig.dbf

channel ORA_DISK_1: reading from backup piece /oracle/app/db1/dbs/0cnsd8vq_1_1

channel ORA_DISK_1: restored backup piece 1

piece handle=/oracle/app/db1/dbs/0cnsd8vq_1_1 tag=TAG20121209T040058

channel ORA_DISK_1: restore complete, elapsed time: 00:02:56

Finished restore at 10-DEC-12

 

2 RMAN> recover database;

 

Starting recover at 10-DEC-12

using channel ORA_DISK_1

 

starting media recovery

 

archive log thread 1 sequence 16 is already on disk as file /oracle/CRM2/CRM/redo04b.log

archive log thread 1 sequence 17 is already on disk as file /oracle/CRM2/CRM/redo05.log

archive log filename=/oracle/CRM2/CRM/redo04b.log thread=1 sequence=16

archive log filename=/oracle/CRM2/CRM/redo05.log thread=1 sequence=17

media recovery complete, elapsed time: 00:00:05

Finished recover at 10-DEC-12

 

3 alter database open resetlogs 打开数据库

SQL> alter database open resetlogs;

 

Database altered.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How to solve the problem of mysql cannot open shared libraryHow to solve the problem of mysql cannot open shared libraryMar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

Reduce the use of MySQL memory in DockerReduce the use of MySQL memory in DockerMar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How do you alter a table in MySQL using the ALTER TABLE statement?How do you alter a table in MySQL using the ALTER TABLE statement?Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin)Run MySQl in Linux (with/without podman container with phpmyadmin)Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overviewWhat is SQLite? Comprehensive overviewMar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

How do I configure SSL/TLS encryption for MySQL connections?How do I configure SSL/TLS encryption for MySQL connections?Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Running multiple MySQL versions on MacOS: A step-by-step guideRunning multiple MySQL versions on MacOS: A step-by-step guideMar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor