oracle11g 在azure云中使用rman进行实例迁移
来源:互联网 发布:腾讯抽奖软件 编辑:程序博客网 时间:2024/06/10 15:09
1,开始备份
备份脚本rman_full_backup.sh内容如下:
#!/bin/shexport DATE=`date +%F`export BACK_DIR='/backupdisk/backup/data'su - oracle -c "mkdir -p $BACK_DIR/$DATErman log=$BACK_DIR/$DATE/rman_backup.log target / <<EOFrun{ 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;exitEOF"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/pdbcakupecho "end to copy the backup to pd server." >> /tmp/oracle_fullback.log
备份过程如下所示:
[root@test_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-17rman log=/oracle/backup/data/2016-03-17/rman_backup.log target / <<EOFrun{ 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;exitEOF'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.'[root@test_90 ~]# ll
2,查看备份的文件目录
RMAN> list backup of controlfile;using target database control file instead of recovery catalogList 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-16RMAN> 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: POWERDESRMAN> [oracle@test_90 ~]$ rlwrap sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Thu Mar 17 21:08:32 2016Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> SQL> create pfile='/oracle/pfile_20160317.ora' from spfile;File created.SQL>
原blog地址: http://blog.csdn.net/mchdba/article/details/50990181,未经过原作者mchdba(黄杉)同意,谢绝转载。
3,传输
[oracle@test_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)? yesWarning: Permanently added '[192.168.237.46]:50390' (RSA) to the list of known hosts.oracle@192.168.237.46's password: pfile_20160317.ora 100% 1008 1.0KB/s 00:00 [oracle@test_90 ~]$ [oracle@test_90 data]$ scp -P50390 -r 2016-03-17 192.168.237.46:/oracle/backup/oracle@192.168.237.46'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 [oracle@test_90 data]$
4,去目标库上nomount方式启动数据库
SQL> shutdown immediateORA-01507: database not mountedORACLE instance shut down.SQL> startup nomount pfile='/oracle/backup/pfile_20160317.ora';ORACLE instance started.Total System Global Area 1603411968 bytesFixed Size 2213776 bytesVariable Size 1023412336 bytesDatabase Buffers 570425344 bytesRedo Buffers 7360512 bytesSQL>
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-16using channel ORA_DISK_1channel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:01Finished restore at 17-MAR-16RMAN>
6,将数据库状态改成mount:
RMAN> alter database mount2> ;database mountedreleased channel: ORA_DISK_1RMAN>
7,注册备份文件
RMAN> catalog start with '/oracle/backup/2016-03-17';Starting implicit crosscheck backup at 17-MAR-16allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=134 device type=DISKCrosschecked 4 objectsFinished implicit crosscheck backup at 17-MAR-16Starting implicit crosscheck copy at 17-MAR-16using channel ORA_DISK_1Finished implicit crosscheck copy at 17-MAR-16searching for all files in the recovery areacataloging files...no files catalogedsearching for all files that match the pattern /oracle/backup/2016-03-17List of Files Unknown to the Database=====================================File Name: /oracle/backup/2016-03-17/rman_backup.logFile Name: /oracle/backup/2016-03-17/arch_POWERDES_20160317_16.bakFile Name: /oracle/backup/2016-03-17/full_POWERDES_20160317_15.bakFile Name: /oracle/backup/2016-03-17/full_POWERDES_20160317_14.bakDo you really want to catalog the above files (enter YES or NO)? YEScataloging files...cataloging doneList of Cataloged Files=======================File Name: /oracle/backup/2016-03-17/arch_POWERDES_20160317_16.bakFile Name: /oracle/backup/2016-03-17/full_POWERDES_20160317_15.bakFile Name: /oracle/backup/2016-03-17/full_POWERDES_20160317_14.bakList of Files Which Where Not Cataloged=======================================File Name: /oracle/backup/2016-03-17/rman_backup.log RMAN-07517: Reason: The file header is corruptedRMAN>
8,开始执行restore恢复操作,将数据从备份集写入到磁盘上的数据文件里面,还原已经备份的数据文件
RMAN> restore database;Starting restore at 17-MAR-16using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=133 device type=DISKchannel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00001 to /data/oracle/orclstu/system01.dbfchannel ORA_DISK_1: restoring datafile 00002 to /data/oracle/orclstu/sysaux01.dbfchannel ORA_DISK_1: restoring datafile 00003 to /data/oracle/orclstu/undotbs01.dbfchannel ORA_DISK_1: restoring datafile 00004 to /data/oracle/orclstu/users01.dbfchannel ORA_DISK_1: restoring datafile 00005 to /data/oracle/orclstu/orclstuk01.dbfchannel ORA_DISK_1: restoring datafile 00006 to /data/oracle/orclstu/plas01.dbfchannel ORA_DISK_1: restoring datafile 00007 to /data/oracle/orclstu/plcrm01.dbfchannel ORA_DISK_1: restoring datafile 00008 to /data/oracle/orclstu/pl01.dbfchannel ORA_DISK_1: restoring datafile 00009 to /data/oracle/orclstu/help01.dbfchannel ORA_DISK_1: reading from backup piece /oracle/backup/2016-03-17/full_POWERDES_20160317_14.bakchannel ORA_DISK_1: piece handle=/oracle/backup/2016-03-17/full_POWERDES_20160317_14.bak tag=TAG20160317T202130channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:14:25Finished restore at 17-MAR-16RMAN>
9,应用归档日志恢复数据文件
RMAN> recover database;Starting recover at 17-MAR-16using channel ORA_DISK_1starting media recoverychannel ORA_DISK_1: starting archived log restore to default destinationchannel ORA_DISK_1: restoring archived logarchived log thread=1 sequence=1428channel ORA_DISK_1: reading from backup piece /oracle/backup/2016-03-17/arch_POWERDES_20160317_16.bakchannel ORA_DISK_1: piece handle=/oracle/backup/2016-03-17/arch_POWERDES_20160317_16.bak tag=TAG20160317T202918channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:03archived log file name=/oracle/app/oracle/flash_recovery_area/POWERDES/archivelog/2016_03_17/o1_mf_1_1428_cgog3ons_.arc thread=1 sequence=1428channel 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=906760822unable to find archived logarchived log thread=1 sequence=1429RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 03/17/2016 22:00:29RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1429 and starting SCN of 31576222RMAN>
需要将缺失的归档日志从原始备份库copy到微软云azure的oracle服务器上 ,或者直接恢复到SCN点上:
RMAN> recover database until scn 31576222;Starting recover at 17-MAR-16using channel ORA_DISK_1starting media recoverymedia recovery complete, elapsed time: 00:00:00Finished recover at 17-MAR-16RMAN>
10,打开数据库
RMAN> alter database open resetlogs;database openedRMAN>
11,验证数据库
[oracle@yueworldoracle_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) ) )[oracle@yueworldoracle_crm admin]$ [oracle@yueworldoracle_crm admin]$ rlwrap sqlplus orclstuk/pa1624390@CRM390;SQL*Plus: Release 11.2.0.1.0 Production on Thu Mar 17 22:15:41 2016Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> 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---------- 1SQL> 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 existSQL>
3 0
- oracle11g 在azure云中使用rman进行实例迁移
- 使用rman进行数据库迁移
- 使用RMAN进行数据迁移
- 微软云 azure 数据迁移之oracle11g dataguard
- RAC 实例 迁移到 单实例 -- 使用RMAN Duplicate
- RAC 实例 迁移到 单实例 -- 使用RMAN Duplicate
- RAC 实例 迁移到 单实例 -- 使用RMAN Duplicate
- RAC 实例 迁移到 单实例 -- 使用RMAN Duplicate
- RAC 实例迁移到单实例 -- 使用RMAN Duplicate
- Linux平台下使用rman进行oracle数据库迁移
- 使用rman将数据库迁移到ASM实例
- Oracle11g新特性:RMAN脚本中使用替换变量
- 用rman进行数据迁移
- 使用VHDUpload上传VHD文件到云存储,并在Azure VM中加挂Azure Drive
- [Azure]使用CustomScriptExtension在Azure虚拟机中执行自定义脚本
- 利用RMAN针对同平台下Oracle的实例进行异机迁移
- 证券公司G4S使用Windows Azure迁移到云
- 使用RMAN迁移数据库到异机
- 注意代码的规范和可读性
- iOS 断言 NSAssert的使用 调试程序错误
- APP隐私政策
- Java设计模式之策略模式
- ios-其他之【1】-证书
- oracle11g 在azure云中使用rman进行实例迁移
- 六款小巧的HTTP Server
- 在matlab上安装svm
- 第五周项目1-三角形类雏形(1)
- 更新ubuntu15.10内核后,驱动解决
- Git Visual Studio gitignore 去除不需要的dll Nuget包等等文件
- 浮点数用double
- android项目引用library导致引用android-support-v4.jar冲突
- c++设计一个计时器(能够暂停,重新开始,继续)的功能。写的不好,仅供参考!