Home Database Mysql Tutorial 【Oracle】基于SCN的增量备份修复DataGuard GAP

【Oracle】基于SCN的增量备份修复DataGuard GAP

Jun 07, 2016 pm 02:51 PM
oracle repair based on backup

1. 首先来模拟 Gap 的产生 1.1. 备库关闭: SYS@dgtest_sshutdown immediate; 1.2. 主库切换日志 SYS@dgtestselect SEQUENCE#,ARCHIVED,STATUS from v$log; SEQUENCE# ARC STATUS ---------- --- ---------------- 61 YES ACTIVE 62 YES ACTIVE 63 NO CURREN

1. 首先来模拟Gap的产生

1.1. 备库关闭:

SYS@dgtest_s>shutdown immediate;

1.2. 主库切换日志

SYS@dgtest>select SEQUENCE#,ARCHIVED,STATUS from v$log;

 

 SEQUENCE# ARC STATUS

---------- --- ----------------

        61 YES ACTIVE

        62 YES ACTIVE

        63 NO  CURRENT

 

SYS@dgtest>alter system archive log current;

 

System altered.

 

SYS@dgtest>select SEQUENCE#,ARCHIVED,STATUS from v$log;

 

 SEQUENCE# ARC STATUS

---------- --- ----------------

        64 NO  CURRENT

        62 YES ACTIVE

        63 YES ACTIVE

刚才current的日志已经归档

1.3. 删除归档,产生UNRESOLVABLE GAP

现在删除63号归档

[oracle@primary arch]$ mv 1_63_909786801.dbf 1_63_909786801.dbf.bak

 

2. 查看报错

2.1. 启动备库

SYS@dgtest_s>startup

2.2. 查看备库的alert

Media Recovery Log /u01/app/oracle/arch/1_62_909786801.dbf

Media Recovery Waiting for thread 1 sequence 63

Fetching gap sequence in thread 1, gap sequence 63-63

Fri May 06 05:28:09 2016

FAL[client]: Failed to request gap sequence

 GAP - thread 1 sequence 63-63

 DBID 3866310445 branch 909786801

FAL[client]: All defined FAL servers have been attempted.

------------------------------------------------------------

Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization

parameter is defined to a value that's sufficiently large

enough to maintain adequate log switch information to resolve

archivelog gaps.

------------------------------------------------------------

2.3. 主库查询SWITCHOVER_STATUS

SYS@dgtest>SELECT SWITCHOVER_STATUS FROM V$DATABASE;

 

SWITCHOVER_STATUS

--------------------

UNRESOLVABLE GAP

UNRESOLVABLE GAP,说明此时的GAP需要我们自己手工去修复,无法自动修复,可自动修复的GAP显示为RESOLVABLE GAP

 

3. 基于SCM的增量备份修复GAP

3.1. 在备库上查询current scn

SYS@dgtest_s>select current_scn from v$database;

 

CURRENT_SCN

-----------

    2567388

3.2. 到主库去进行基于此SCN的增量备份

RMAN> BACKUP INCREMENTAL FROM SCN 2567388 DATABASE FORMAT '/u01/app/oracle/oradata/tmp/ora11_scn_%U' tag 'For Standby Gap';

3.3. 传输到备库:

[oracle@primary tmp]$ scp * standby:/u01/app/oracle/oradata/tmp

oracle@standby's password:

ora11_scn_0kr54hvk_1_1                                                                                                               100%  125MB 125.2MB/s   00:01    

ora11_scn_0lr54l99_1_1                                                                                                               100% 9664KB   9.4MB/s   00:00  

3.4. 备库重新启动到mount,并取消日志应用

SYS@dgtest_s>shutdown immediate;

SYS@dgtest_s>startup mount;

SYS@dgtest_s>alter database recover managed standby database cancel;

3.5. 注册刚才传输过来的备份集

RMAN> CATALOG START WITH '/u01/app/oracle/oradata/tmp';

3.6. recover备库

RMAN> recover database noredo;

恢复完毕,这时我们可以观察备库的alert日志:

Incremental restore complete of datafile 4 /u01/app/oracle/oradata/dgtest_s/users01.dbf

  checkpoint is 2893208

  last deallocation scn is 3

Incremental restore complete of datafile 3 /u01/app/oracle/oradata/dgtest_s/undotbs01.dbf

  checkpoint is 2893208

  last deallocation scn is 973300

Incremental restore complete of datafile 5 /u01/app/oracle/oradata/dgtest_s/example01.dbf

  checkpoint is 2893208

  last deallocation scn is 942056

Mon May 09 05:20:25 2016

Incremental restore complete of datafile 2 /u01/app/oracle/oradata/dgtest_s/sysaux01.dbf

  checkpoint is 2893208

  last deallocation scn is 956093

Incremental restore complete of datafile 1 /u01/app/oracle/oradata/dgtest_s/system01.dbf

  checkpoint is 2893208

  last deallocation scn is 955346

发现数据文件的scn号都已经重新刷新,但是此时还不能重新起库,需要重新从主库生成一个standby controlfile

3.7. 主库备份控制文件

RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/u01/app/oracle/oradata/tmp/ctl.bak';

3.8. 传输standby控制文件到备库

oracle@standby's password:

ctl.bak                                                                                                                              100% 9664KB   9.4MB/s   00:00

3.9. 备库恢复standby控制文件

备库库起到nomount阶段:

SYS@dgtest_s>shutdown immediate

SYS@dgtest_s>startup nomount;

rman恢复控制文件

RMAN> RESTORE STANDBY CONTROLFILE FROM '/u01/app/oracle/oradata/tmp/ctl.bak';

3.10. mount备库,并取消日志应用

SYS@dgtest_s> alter database mount;

SYS@dgtest_s>alter database recover managed standby database cancel;

3.11. 清空备库日志组

SYS@dgtest_s>ALTER DATABASE CLEAR LOGFILE GROUP 1;

 

Database altered.

注:如果采用了standby log模式,不需要清空,如果清空会出现

SQL> ALTER DATABASE CLEAR LOGFILE GROUP 1;

ALTER DATABASE CLEAR LOGFILE GROUP 1

*

ERROR at line 1:

ORA-19527: physical standby redo log must be renamed

ORA-00312: online log 1 thread 1: '/u01/oradata/badly9/redo01.log'

说明:如果没有采用standby log模式,有几组需要清空几组

 

3.12. 备库重设flashback

SYS@dgtest_s>ALTER DATABASE FLASHBACK OFF;

SYS@dgtest_s>ALTER DATABASE FLASHBACK ON;

3.13. 备库开始应用日志

SYS@dgtest_s>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

 

4. 确认修复成功

在主库中执行

SYS@dgtest>alter system switch logfile;

分别主备库中执行select max(sequence#) from v$archived_log;如果一致标示修复成功

SYS@dgtest>select max(sequence#) from v$archived_log;

 

MAX(SEQUENCE#)

--------------

            81

 

SYS@dgtest_s>select max(sequence#) from v$archived_log;

 

MAX(SEQUENCE#)

--------------

            81

至此GAP修复完毕。

Statement of this Website
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

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

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

This Apple ID is not yet in use in the iTunes Store: Fix This Apple ID is not yet in use in the iTunes Store: Fix Jun 10, 2024 pm 05:42 PM

When logging into iTunesStore using AppleID, this error saying "This AppleID has not been used in iTunesStore" may be thrown on the screen. There are no error messages to worry about, you can fix them by following these solution sets. Fix 1 – Change Shipping Address The main reason why this prompt appears in iTunes Store is that you don’t have the correct address in your AppleID profile. Step 1 – First, open iPhone Settings on your iPhone. Step 2 – AppleID should be on top of all other settings. So, open it. Step 3 – Once there, open the “Payment & Shipping” option. Step 4 – Verify your access using Face ID. step

How long will Oracle database logs be kept? How long will Oracle database logs be kept? May 10, 2024 am 03:27 AM

The retention period of Oracle database logs depends on the log type and configuration, including: Redo logs: determined by the maximum size configured with the "LOG_ARCHIVE_DEST" parameter. Archived redo logs: Determined by the maximum size configured by the "DB_RECOVERY_FILE_DEST_SIZE" parameter. Online redo logs: not archived, lost when the database is restarted, and the retention period is consistent with the instance running time. Audit log: Configured by the "AUDIT_TRAIL" parameter, retained for 30 days by default.

Function to calculate the number of days between two dates in oracle Function to calculate the number of days between two dates in oracle May 08, 2024 pm 07:45 PM

The function in Oracle to calculate the number of days between two dates is DATEDIFF(). The specific usage is as follows: Specify the time interval unit: interval (such as day, month, year) Specify two date values: date1 and date2DATEDIFF(interval, date1, date2) Return the difference in days

The order of the oracle database startup steps is The order of the oracle database startup steps is May 10, 2024 am 01:48 AM

The Oracle database startup sequence is: 1. Check the preconditions; 2. Start the listener; 3. Start the database instance; 4. Wait for the database to open; 5. Connect to the database; 6. Verify the database status; 7. Enable the service (if necessary ); 8. Test the connection.

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to use interval in oracle How to use interval in oracle May 08, 2024 pm 07:54 PM

The INTERVAL data type in Oracle is used to represent time intervals. The syntax is INTERVAL <precision> <unit>. You can use addition, subtraction, multiplication and division operations to operate INTERVAL, which is suitable for scenarios such as storing time data and calculating date differences.

How to see the number of occurrences of a certain character in Oracle How to see the number of occurrences of a certain character in Oracle May 09, 2024 pm 09:33 PM

To find the number of occurrences of a character in Oracle, perform the following steps: Get the total length of a string; Get the length of the substring in which a character occurs; Count the number of occurrences of a character by subtracting the substring length from the total length.

Oracle database server hardware configuration requirements Oracle database server hardware configuration requirements May 10, 2024 am 04:00 AM

Oracle database server hardware configuration requirements: Processor: multi-core, with a main frequency of at least 2.5 GHz. For large databases, 32 cores or more are recommended. Memory: At least 8GB for small databases, 16-64GB for medium sizes, up to 512GB or more for large databases or heavy workloads. Storage: SSD or NVMe disks, RAID arrays for redundancy and performance. Network: High-speed network (10GbE or higher), dedicated network card, low-latency network. Others: Stable power supply, redundant components, compatible operating system and software, heat dissipation and cooling system.

See all articles