oracle11g 在azure云中使用rman进行实例迁移

1,開始备份

备份脚本rman_full_backup.sh内容例如以下:

#!/bin/sh
export DATE=`date +%F`
export BACK_DIR=‘/backupdisk/backup/data‘
su - oracle -c "
mkdir -p $BACK_DIR/$DATE
rman log=$BACK_DIR/$DATE/rman_backup.log target / <<EOF
run{
        backup as compressed backupset database
                format ‘$BACK_DIR/$DATE/full_%d_%T_%s.bak‘
        plus archivelog
                format ‘$BACK_DIR/$DATE/arch_%d_%T_%s.bak‘ delete input;
        sql ‘alter system archive log current‘;
}
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;
delete noprompt obsolete;
exit
EOF
"
su - oracle -c "
chmod 775 $BACK_DIR/$DATE/*
"

#cd /home/pdbcakup/
echo "begin to copy the backup to pd servers." >>  /tmp/oracle_fullback.log
#cp -r $BACK_DIR/$DATE /home/pdbcakup
echo "end to copy the backup to pd server." >>  /tmp/oracle_fullback.log

备份步骤例如以下所看到的:

[[email protected]_90 ~]# bash -x /oracle/backup/scripts/rman_full_backup.sh
++ date +%F
+ export DATE=2016-03-17
+ DATE=2016-03-17
+ export BACK_DIR=/oracle/backup/data
+ BACK_DIR=/oracle/backup/data
+ su - oracle -c ‘
mkdir -p /oracle/backup/data/2016-03-17
rman log=/oracle/backup/data/2016-03-17/rman_backup.log target / <<EOF
run{
        backup as compressed backupset database
                format ‘\‘‘/oracle/backup/data/2016-03-17/full_%d_%T_%s.bak‘\‘‘
        plus archivelog
                format ‘\‘‘/oracle/backup/data/2016-03-17/arch_%d_%T_%s.bak‘\‘‘ delete input;
        sql ‘\‘‘alter system archive log current‘\‘‘;
}
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;
delete noprompt obsolete;
exit
EOF
‘
RMAN> 2> 3> 4> 5> 6> 7> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> + su - oracle -c ‘
chmod 775 /oracle/backup/data/2016-03-17/*
‘
+ echo ‘begin to copy the backup to pd servers.‘
+ echo ‘end to copy the backup to pd server.‘
[[email protected]_90 ~]# ll

2,查看备份的文件文件夹

RMAN> list backup of controlfile;

using target database control file instead of recovery catalog

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6       Full    1.05M      DISK        00:00:01     17-MAR-16
        BP Key: 6   Status: AVAILABLE  Compressed: YES  Tag: TAG20160317T202130
        Piece Name: /oracle/backup/data/2016-03-17/full_POWERDES_20160317_15.bak
  Control File Included: Ckp SCN: 31576216     Ckp time: 17-MAR-16

RMAN> list backup of spfile;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6       Full    1.05M      DISK        00:00:01     17-MAR-16
        BP Key: 6   Status: AVAILABLE  Compressed: YES  Tag: TAG20160317T202130
        Piece Name: /oracle/backup/data/2016-03-17/full_POWERDES_20160317_15.bak
  SPFILE Included: Modification time: 17-MAR-16
  SPFILE db_unique_name: POWERDES

RMAN> 

[[email protected]_90 ~]$ rlwrap sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Mar 17 21:08:32 2016

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
SQL> create pfile=‘/oracle/pfile_20160317.ora‘ from spfile;

File created.

SQL>

原blog地址: http://blog.csdn.net/mchdba/article/details/50990181,未经过原作者mchdba(黄杉)允许。谢绝转载。

3,传输

[[email protected]_90 ~]$ scp -P50390 -r /oracle/pfile_20160317.ora 2016-03-17 192.168.237.46:/oracle/backup/
The authenticity of host ‘[192.168.237.46]:50390 ([192.168.237.46]:50390)‘ can‘t be established.
RSA key fingerprint is c0:1c:30:8a:bd:8c:90:b2:af:57:1d:29:ab:1f:90:f9.
Are you sure you want to continue connecting (yes/no)?

yes
Warning: Permanently added ‘[192.168.237.46]:50390‘ (RSA) to the list of known hosts.
[email protected]‘s password:
pfile_20160317.ora                                                                                                                                           100% 1008     1.0KB/s   00:00
[[email protected]_90 ~]$
[[email protected]_90 data]$ scp -P50390 -r 2016-03-17  192.168.237.46:/oracle/backup/
[email protected]‘s password:
full_POWERDES_20160317_14.bak                                                                                                                                100% 1914MB   4.7MB/s   06:49
full_POWERDES_20160317_15.bak                                                                                                                                100% 1088KB   1.1MB/s   00:00
arch_POWERDES_20160317_16.bak                                                                                                                                100%  180KB 179.5KB/s   00:00
rman_backup.log                                                                                                                                              100% 6331     6.2KB/s   00:00
[[email protected]_90 data]$ 

4,去目标库上nomount方式启动数据库

SQL> shutdown immediate
ORA-01507: database not mounted

ORACLE instance shut down.
SQL> startup nomount pfile=‘/oracle/backup/pfile_20160317.ora‘;
ORACLE instance started.

Total System Global Area 1603411968 bytes
Fixed Size		    2213776 bytes
Variable Size		 1023412336 bytes
Database Buffers	  570425344 bytes
Redo Buffers		    7360512 bytes
SQL> 

5,恢复控制文件

RMAN> restore controlfile to ‘/oracle/app/oracle/orclstu/control01.ctl‘ from ‘/oracle/backup/2016-03-17/full_POWERDES_20160317_15.bak‘;

Starting restore at 17-MAR-16
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 17-MAR-16

RMAN>

6,将数据库状态改成mount:

RMAN> alter database mount
2> ;

database mounted
released channel: ORA_DISK_1

RMAN> 

7,注冊备份文件

RMAN> catalog start with ‘/oracle/backup/2016-03-17‘;

Starting implicit crosscheck backup at 17-MAR-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 17-MAR-16

Starting implicit crosscheck copy at 17-MAR-16
using channel ORA_DISK_1
Finished implicit crosscheck copy at 17-MAR-16

searching for all files in the recovery area
cataloging files...
no files cataloged

searching for all files that match the pattern /oracle/backup/2016-03-17

List of Files Unknown to the Database
=====================================
File Name: /oracle/backup/2016-03-17/rman_backup.log
File Name: /oracle/backup/2016-03-17/arch_POWERDES_20160317_16.bak
File Name: /oracle/backup/2016-03-17/full_POWERDES_20160317_15.bak
File Name: /oracle/backup/2016-03-17/full_POWERDES_20160317_14.bak

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

List of Cataloged Files
=======================
File Name: /oracle/backup/2016-03-17/arch_POWERDES_20160317_16.bak
File Name: /oracle/backup/2016-03-17/full_POWERDES_20160317_15.bak
File Name: /oracle/backup/2016-03-17/full_POWERDES_20160317_14.bak

List of Files Which Where Not Cataloged
=======================================
File Name: /oracle/backup/2016-03-17/rman_backup.log
  RMAN-07517: Reason: The file header is corrupted

RMAN> 

8。開始运行restore恢复操作。将数据从备份集写入到磁盘上的数据文件中面,还原已经备份的数据文件

RMAN> restore database;

Starting restore at 17-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /data/oracle/orclstu/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /data/oracle/orclstu/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /data/oracle/orclstu/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /data/oracle/orclstu/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /data/oracle/orclstu/orclstuk01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /data/oracle/orclstu/plas01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /data/oracle/orclstu/plcrm01.dbf
channel ORA_DISK_1: restoring datafile 00008 to /data/oracle/orclstu/pl01.dbf
channel ORA_DISK_1: restoring datafile 00009 to /data/oracle/orclstu/help01.dbf
channel ORA_DISK_1: reading from backup piece /oracle/backup/2016-03-17/full_POWERDES_20160317_14.bak
channel ORA_DISK_1: piece handle=/oracle/backup/2016-03-17/full_POWERDES_20160317_14.bak tag=TAG20160317T202130
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:14:25
Finished restore at 17-MAR-16

RMAN>

9,应用归档日志恢复数据文件

RMAN> recover database;

Starting recover at 17-MAR-16
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=1428
channel ORA_DISK_1: reading from backup piece /oracle/backup/2016-03-17/arch_POWERDES_20160317_16.bak
channel ORA_DISK_1: piece handle=/oracle/backup/2016-03-17/arch_POWERDES_20160317_16.bak tag=TAG20160317T202918
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
archived log file name=/oracle/app/oracle/flash_recovery_area/POWERDES/archivelog/2016_03_17/o1_mf_1_1428_cgog3ons_.arc thread=1 sequence=1428
channel default: deleting archived log(s)
archived log file name=/oracle/app/oracle/flash_recovery_area/POWERDES/archivelog/2016_03_17/o1_mf_1_1428_cgog3ons_.arc RECID=2 STAMP=906760822
unable to find archived log
archived log thread=1 sequence=1429
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 03/17/2016 22:00:29
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1429 and starting SCN of 31576222

RMAN> 

须要将缺失的归档日志从原始备份库copy到微软云azure的oracle服务器上 ,或者直接恢复到SCN点上:

RMAN> recover database until scn 31576222;

Starting recover at 17-MAR-16
using channel ORA_DISK_1

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

Finished recover at 17-MAR-16

RMAN> 

10,打开数据库

RMAN> alter database open resetlogs;

database opened

RMAN> 

11,验证数据库

[[email protected]_crm admin]$ more tnsnames.ora
# tnsnames.ora Network Configuration File: /oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

POWERDES =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orclstu)
    )
  )

CRM390 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.158.3.91)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orclstu)
    )
  )
[[email protected]_crm admin]$ 

[[email protected]_crm admin]$ rlwrap sqlplus orclstuk/[email protected];

SQL*Plus: Release 11.2.0.1.0 Production on Thu Mar 17 22:15:41 2016

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table z_te(id number);

Table created.

SQL> insert into z_te(id)values(1);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from z_te;

	ID
----------
	 1

SQL> drop table z_te;

Table dropped.

SQL> select * from z_te;
select * from z_te
              *
ERROR at line 1:
ORA-00942: table or view does not exist

SQL>
时间: 2024-10-23 09:14:58

oracle11g 在azure云中使用rman进行实例迁移的相关文章

Oracle 单实例 迁移到 RAC 实例 -- 使用RMAN 异机恢复

Oracle 官网有关单实例迁移到RAC的一个步骤说明: How to Convert 10g Single-Instance database to 10g RAC using Manual Conversion procedure [ID 747457.1] http://blog.csdn.net/tianlesoftware/archive/2010/12/09/6065903.aspx   RMAN 备份异机恢复 并创建新DBID http://blog.csdn.net/tianle

Azure云中Web应用的持续集成实践

由于从事的工作领域关系,目前会或多或少的关注DevOps课题的相关领域,当然目前还在尝试多种适应于持续开发持续集成领域的工具和组合方式,个人粗浅的领会是DevOPS其实既不会只是开发者需要关注的,也是运维人员应该关注的领域,因为未来的IT世界其实是个"相对混合"的空间,发展之快超出想象:在开发测试领域的工具上看,Chef/Puppet/PowerShell DSC,到开源领域广泛应用Salt Stack, Ansible到 Docker生态圈等封装一系列基础架构即代码等概念的涌现,无时

将Linux和开源解决方案带到Azure云中第二场培训

因福州微软孵化器需要,3月27日下午给入孵企业进行第二场将Linux和开源解决方案带到Azure云中的培训. 本次培训的内容有: 概述:将开源技术带入 Azure 云中 Linux and OSS on Azure 如何将定制的 Linux & FreeBSD 环境迁入到 Azure Azure 上 Linux 虚拟机创建并通过 DSC For Linux 扩展来管理 在 Azure 中创建和管理 Docker 多容器环境

ORACLE11G RAC 应用分开到不同的实例上.TAF

有套POS系统 如今应用量大了,数据量大了! 统计分析历史交易一定程度上影响了另外个应用. 这两个应用分别是OLTP和OLAP. 其实很多项目都有这样的两方的应用需求.  最近另外个系统的大量读取,统计下载数据,导致CPU飙高,后IO飙高.LINUX下的负载达到104. 所以对新上线的RAC 要求做应用切割. 平时两个应用分别在两个不同的实例上. 如果一个实例挂了就自动切到另外个实例上. 新搭好了两个节点的RAC 然后添加服务进去 srvctl add service -d POSDB -s p

Rman实现数据库迁移

Rman实现数据库迁移(从库A迁移到库B)环境:服务器A:Oracle10g+AS3服务器B:Oracle10g+AS4准备工作: 1 在数据库B上建立与库A相同的目录结构(若由于磁盘空间等原因可以用软链接做到),其中包括:  $ORACLE_BASE;$ORACLE_HOME;以及archivelog目录和BASE下的admin目录及其子目录2 在数据库B上安装数据库软件(不建库)实施工作:1 备份:在数据库A上  断开连接到A上的应用,并做全备份  [[email protected] or

impdb network_link参数 练习(不同实例迁移数据)

将源库ip:192.168.10.218 , sid:cradle  数据通过使用network_link参数导入到目标库 步骤: 1.  在目标库创建指向源库的dblink 确认目标tnsnames.ora文件中的连接串 CRADLE218 =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.218)(PORT = 1521))    (CONNECT_DATA =      (SERVICE_NAME = cr

RMAN备份与恢复实例

1. 检查数据库模式:   sqlplus /nolog    conn /as sysdba   archive log list (查看数据库是否处于归档模式中) 若为非归档,则修改数据库归档模式.   startup mount   alter database archivelog   alter database open 2.连接到target数据库 命令: connect target  / (connect target system/[email protected],如果数据

Oracle 11G RMAN 单实例异机恢复

数据备份当然是为数据恢复准备,新环境的oracle一直在进行备份,但都没有测试验证备份的有效性,所以本次测试的重要性不言而喻了!以下为WIN平台下RMAN异机恢复实例. 源库 目标库 操作系统 WIN SVR 2008 R2 WIN SVR 2008 R2 主机名 Ora ORATEST IP 192.168.18.20 192.168.18.25 数据库版本 11.2.0.1.0 11.2.0.1.0 存储方式 单实例 单实例 ORACLE_HOME D:\app\Administrator\

RMAN 备份与恢复 实例

1. 检查数据库模式:    sqlplus /nolog     conn /as sysdba    archive log list (查看数据库是否处于归档模式中) 若为非归档,则修改数据库归档模式.    startup mount    alter database archivelog    alter database open 2.连接到target数据库 命令: connect target  / (connect target system/[email protected