oracle data guard备库备份恢复
客户有套data guard环境,主库在阿里云上,备库在本地机房,现在想定期做备份,但是因为一些原因,备份阿里云上的主库实现会有些问题,所以只能备份本地的备库。目前需求就是测试备库的备份文件是否可以进行恢复,当误删除等操作之后,能否通过备份找回数据。以下为具体的测试:
1. 在data guard的备库进行完整+归档的备份
RMAN> run {
2> allocate channel t1 type disk;
3> allocate channel t2 type disk;
4> allocate channel t3 type disk;
5> allocate channel t4 type disk;
6> backup as compressed backupset INCREMENTAL LEVEL 0 FORMAT '/u01/app/oracle/racdb_data_%T_%s' database;
7> backup format '/u01/app/oracle/racdb_arch_%T_%s' skip inaccessible archivelog ALL not backed up;
8> backup format '/u01/app/oracle/racdb_cont_%T_%s' current controlfile;
9> release channel t1;
10> release channel t2;
11> release channel t3;
12> release channel t4;
13> }
2. 将文件拷贝到测试库上
[oracle@dg1 oracle]$ scp racdb_* 192.168.100.100:/u01/app/oracle/
oracle@192.168.100.100's password:
racdb_arch_20171018_24 100% 3646KB 3.6MB/s 00:00
racdb_arch_20171018_25 100% 30MB 30.1MB/s 00:01
racdb_arch_20171018_26 100% 2995KB 2.9MB/s 00:00
racdb_arch_20171018_27 100% 59MB 59.2MB/s 00:01
racdb_arch_20171018_28 100% 21MB 20.9MB/s 00:00
racdb_cont_20171018_29 100% 9856KB 9.6MB/s 00:00
racdb_data_20171018_19 100% 194MB 48.6MB/s 00:04
racdb_data_20171018_20 100% 77MB 77.0MB/s 00:01
racdb_data_20171018_21 100% 30MB 30.2MB/s 00:01
racdb_data_20171018_22 100% 1104KB 1.1MB/s 00:00
racdb_data_20171018_23 100% 96KB 96.0KB/s 00:00
3. 在主库上生成pfile文件,并拷贝到测试库上
SQL> create pfile='/home/oracle/pfileabbott' from spfile; File created. [oracle@dg1 ~]$ scp pfileabbott 192.168.100.100:/home/oracle
oracle@192.168.100.100's password:
pfileabbott 100% 1375 1.3KB/s 00:00
4. 在测试库上修改参数文件
[oracle@Abbott ~]$ mv pfileabbott $ORACLE_HOME/dbs/initabbott.ora
[oracle@Abbott ~]$ cd $ORACLE_HOME/dbs
[oracle@Abbott dbs]$ export ORACLE_SID=abbott
[oracle@Abbott dbs]$ vi initabbott.ora
*.audit_file_dest='/u01/app/oracle/admin/abbott/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/abbott/control01.ctl','/u01/app/oracle/fast_recovery_area/abbott/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='abbott'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=abbottXDB)'
*.log_archive_dest_1='LOCATION=/u01/app/oracle/archivelog'
*.log_archive_format='%t_%s_%r.arc'
*.log_archive_max_processes=30
*.open_cursors=300
*.pga_aggregate_target=655360000
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1967128576
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
5. 测试库开启到nomount
[oracle@Abbott dbs]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Tue Oct 17 08:24:18 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount;
ORACLE instance started. Total System Global Area 1970864128 bytes
Fixed Size 2254544 bytes
Variable Size 520096048 bytes
Database Buffers 1442840576 bytes
Redo Buffers 5672960 bytes
SQL>
6. 恢复控制文件
[oracle@Abbott ~]$ rman target / Recovery Manager: Release 11.2.0.4.0 - Production on Tue Oct 17 09:29:20 2017 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: ABBOTT (not mounted) RMAN> restore controlfile from '/u01/app/oracle/racdb_cont_20171018_29'; Starting restore at 17-OCT-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/abbott/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/abbott/control02.ctl
Finished restore at 17-OCT-17 RMAN> alter database mount; database mounted
released channel: ORA_DISK_1
7. 恢复数据文件
RMAN> restore database; Starting restore at 17-OCT-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=150 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 00003 to /u01/app/oracle/oradata/abbott/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/abbott/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/racdb_data_20171018_21
channel ORA_DISK_1: piece handle=/u01/app/oracle/racdb_data_20171018_21 tag=TAG20171018T153509
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
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 00002 to /u01/app/oracle/oradata/abbott/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/abbott/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/racdb_data_20171018_20
channel ORA_DISK_1: piece handle=/u01/app/oracle/racdb_data_20171018_20 tag=TAG20171018T153509
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
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 /u01/app/oracle/oradata/abbott/system01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/racdb_data_20171018_19
channel ORA_DISK_1: piece handle=/u01/app/oracle/racdb_data_20171018_19 tag=TAG20171018T153509
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 17-OCT-17
8. 恢复数据库
RMAN> recover database; Starting recover at 17-OCT-17
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=196
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/racdb_arch_20171018_28
channel ORA_DISK_1: piece handle=/u01/app/oracle/racdb_arch_20171018_28 tag=TAG20171018T153550
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/archivelog1_196_953375126.arc thread=1 sequence=196
unable to find archived log
archived log thread=1 sequence=197
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/17/2017 09:33:30
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 197 and starting SCN of 1907246
9. 将数据库open
RMAN> alter database open; database opened RMAN> quit Recovery Manager complete.
10. 连接数据库后,无法创建表等,因为控制文件是standby controlfile,所以打开的模式为READ ONLY
[oracle@Abbott ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Tue Oct 17 09:41:46 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> create table t1(a int);
create table t1(a int)
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-16000: database open for read-only access SQL> select open_mode , database_role, flashback_on from v$database; OPEN_MODE DATABASE_ROLE FLASHBACK_ON
-------------------- ---------------- ------------------
READ ONLY PHYSICAL STANDBY NO
11. 尝试启用备库,因缺少standby log报错
SQL> alter database activate standby database;
alter database activate standby database
*
ERROR at line 1:
ORA-00314: log 4 of thread 1, expected sequence# 197 doesn't match 0
ORA-00312: online log 4 thread 1: '/u01/app/oracle/oradata/abbott/std_log4.log' SQL> select * from v$standby_log;
select * from v$standby_log
*
ERROR at line 1:
ORA-00339: archived log does not contain any redo
ORA-00334: archived log: '/u01/app/oracle/oradata/abbott/std_log4.log'
12. 因此对缺少的log进行clear及drop(当然,这里也可以把standby redo拷贝过来,并进行open)
SQL> alter database drop logfile group 4;
alter database drop logfile group 4
*
ERROR at line 1:
ORA-00314: log 4 of thread 1, expected sequence# 197 doesn't match 0
ORA-00312: online log 4 thread 1: '/u01/app/oracle/oradata/abbott/std_log4.log' SQL> ALTER DATABASE CLEAR LOGFILE GROUP 4; Database altered. SQL> alter database drop logfile group 4; Database altered.
13. 再次arctive备库,启动正常,并且open之后可读写
SQL> alter database activate standby database; Database altered. SQL> select open_mode , database_role, flashback_on from v$database; OPEN_MODE DATABASE_ROLE FLASHBACK_ON
-------------------- ---------------- ------------------
MOUNTED PRIMARY NO SQL> alter database open; Database altered. SQL> select open_mode , database_role, flashback_on from v$database; OPEN_MODE DATABASE_ROLE FLASHBACK_ON
-------------------- ---------------- ------------------
READ WRITE PRIMARY NO SQL> create table t1(a int); Table created. SQL>
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archivelog
Oldest online log sequence 1
Next log sequence to archive 1
Current log sequence 1
SQL>
oracle data guard备库备份恢复的更多相关文章
- ORACLE 11g 用Duplicate恢复Data Guard 备库详细过程
1.先查找备库控制文件路径 先在备库上找出控制文件的路径,通过和主库一样,不过为了以防万一,还是check为好. SQL> select name from v$controlfile; NA ...
- Oracle 12c DG备库Alert报错ORA-01110
环境是12.2.0.1 version, Oracle Data Guard备库近段时间一直报错,但是备库主库同步一致,数据一致. 2019-03-06T23:42:22.184048+08:00 E ...
- Oracle Data Guard
DG 是 Oracle Data Guard 的简称.也就是Oracle11g的 数据卫士. 由于在工作中 Oracle和 SQL SERVER2008 同时都需要维护管理.给我的感觉这里的 DG 其 ...
- (转)Oracle Data Guard学习
一.Data Guard提供如下三种数据保护模式: 1)最高保护模式(Maximum Protection) 这里的”最高保护“是指最大限度的保护数据不丢失,也就是至少有一个standby和prima ...
- Oracle Data Guard配置
Oracle Data Guard 的配置在网上有很多资料,但是没有一个完整的,配置下来多少有些问题.在踩了各种坑之后,自己终于配置成功,就想把这过程记录下来. 1 测试环境 主数据库:windo ...
- Oracle Data Guard 重要配置参数
Oracle Data Guard主要是通过为生产数据库提供一个或多个备用数据库(是产生数据库的一个副本),以保证在主库不可用或异常时数据不丢失并通过备用数据库继续提供服务.对于Oracle DG的配 ...
- Oracle data guard学习
Oracle data guard学习:三思笔记 Data guard 1data guard结构: data guard是一个集合,由一个primary数据库(生产数据库)和一个或多个standby ...
- Oracle Data Guard的配置
概述 Oracle Data Guard 是针对企业数据库的最有效和最全面的数据可用性.数据保护和灾难恢复解决方案.它提供管理.监视和自动化软件基础架构来创建和维护一个或多个同步备用数据库,从而保护数 ...
- Oracle data guard 10g 搭建
Oracle data guard 10g 搭建 1系统常规参数检查 硬盘 [root@localhost ~]# df -h 内核 [root@localhost ~]# uname -a [roo ...
随机推荐
- mysqldump --single-transaction 和--lock-tables参数详解
mysqldump的备份原理 mysqldump在备份过程中,是采用查询备份相关表的数据,然后导出,拼接成insert语句的形式进行备份. 关于--single-transaction 和--lo ...
- iOS 通讯录基础
iOS 6 之后应用訪问通讯录须要获得用户授权,而且仅仅授权一次,即使卸载了之后再安装.也不用再次授权. 开发通讯录应用须要两个框架: 1.ABAddressBook 主要用于提供訪问通讯录中 ...
- UIPasteboard粘贴板:UIMenuController自定义(三)
这篇咱总结总结自定义剪贴板的使用 其实自定义剪贴板也非常简单,无非是放开响应时间,通过UIMenuController自定义剪贴板,然后就是最关键的实现你所用的copy方法拉. 为了方便实用,我给ce ...
- CreateFileMapping和MapViewOfFile函数
大家都是到PG是分布式网络事务处理数据库,与其他数据库优点之一就在于服务器与客户的交流是一对一的,所谓一对一是指,针对客户的每一连接服务器都会产生一个进程为其服务,那么问题就来了,这些进程间是如何交互 ...
- 黑科技 —— Type-C 接口与 USB3.1
Type-C 接口解决了 USB 永远插不准的世界性难题. 小开科普一分钟:究竟USB Type-C是何方神圣? 1. Type-C USB Type-C,简称是 USB-C.Type-C 只是 US ...
- CMake生成OpenCV解决方案&&编译OpenCV源码
生成OpenCV工程需要用到CMake,所以第一步需要下载CMake软件,下载链接:CMake下载 目前最新的版本是3.7.1,这里选择下载Platform下的Windows win32-x86 ZI ...
- zedboard之GPIO驱动器(离FPGA直到LINUX申请书)
笔者:xiabodan 资源: http://blog.csdn.net/xiabodan/article/details/24308373 1 EDK 大家知道我们在EDK中建立GPIO然后倒出 ...
- WPF 3D model - Sphere, Cone, and Cylinder
原文:WPF 3D model - Sphere, Cone, and Cylinder Extending Visual3D - Sphere, Cone, and Cylinder http: ...
- matlab 工具函数 —— normalize(归一化数据)
function x = normalize(x, mu, sigma) x = bsxfun(@minus, x, mu); x = bsxfun(@rdivide, x, sigma); end ...
- [Swift]UIAlertController 以及 Swift 中的闭包和枚举
原文地址:http://blog.callmewhy.com/2014/10/08/uialertcontroller-swift-closures-enum/ 在 iOS8 的 SDK 中, UIK ...