search
HomeDatabaseMysql Tutorial以只读方式打开PHYSICAL STANDBY数据库,进行测试,然后还原

以只读方式打开PHYSICAL STANDBY数据库,进行测试,然后还原

a. 检查standby的状态
SQL> select name,database_role,OPEN_MODE,SWITCHOVER_STATUS from v$database;
NAME      DATABASE_ROLE    OPEN_MODE  SWITCHOVER_STATUS
--------- ---------------- ---------- --------------------
ORCLDB    PHYSICAL STANDBY MOUNTED    NOT ALLOWED

b.判断flashback_on是否开启
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------
YES

c.闪回恢复区设置检测
SQL> show parameter db_recovery_file_dest
NAME                                TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      /u01/Oracle/flash_recovery_are
a
db_recovery_file_dest_size          big integer 2G

d.取消日志应用
SQL> alter database recover managed standby database cancel;
Database altered.

e.创建还原点
SQL> create restore point restore_point_readonly guarantee flashback database;
Restore point created.

f.在主库上进行日志切换,日志发送设置为延迟
SQL> alter system archive log current;
System altered.
SQL> alter system set log_archive_dest_state_2=defer;
System altered.

 
h.激活备库到read write状态,并打开
SQL> alter database activate standby database;
Database altered.
SQL> alter database open;
Database altered.
SQL> select name,open_mode,database_role,db_unique_name from v$database;
NAME      OPEN_MODE  DATABASE_ROLE    DB_UNIQUE_NAME
--------- ---------- ---------------- ------------------------------
ORCLDB    READ WRITE PRIMARY          PHYSTDBY

i.进行read write测试
SQL> create table scott.t as select * from dba_objects;
Table created.
SQL> select count(*) from scott.t;
COUNT(*)
----------
49745
SQL> truncate table scott.t;
Table truncated.
SQL> select count(*) from scott.t;
COUNT(*)
----------
0

j.测试结束,准备还原备库。  先强制启动到mount状态,然后进行数据库闪回
 
SQL> startup mount force
ORACLE instance started.
Total System Global Area  390070272 bytes
Fixed Size                  2021024 bytes
Variable Size            142608736 bytes
Database Buffers          243269632 bytes
Redo Buffers                2170880 bytes
Database mounted.
SQL> flashback database to restore point restore_point_readonly;
Flashback complete.

k.将数据库转换为physical standby
SQL> alter database convert to physical standby;
Database altered.

 
l.再次强制启动到mout状态,,然后应用日志
 
SQL> startup mount force
ORACLE instance started.
Total System Global Area  390070272 bytes
Fixed Size                  2021024 bytes
Variable Size            142608736 bytes
Database Buffers          243269632 bytes
Redo Buffers                2170880 bytes
Database mounted.
SQL> alter database recover managed standby database disconnect from session;
Database altered.

m.在主库把日志传送启用,切换日志
SQL> alter system set log_archive_dest_state_2=enable;
System altered.
SQL> alter system archive log current;
System altered.

n.观察备库日志,即可发现已经正常切换至physical standby,应用日志正常。
 
alter database recover managed standby database disconnect from session
Sun Jan  5 07:43:47 2014
Attempt to start background Managed Standby Recovery process (PHYSTDBY)
MRP0 started with pid=22, OS id=13951
Sun Jan  5 07:43:47 2014
MRP0: Background Managed Standby Recovery process started (PHYSTDBY)
Managed Standby Recovery not using Real Time Apply
Clearing online redo logfile 1 /u01/oracle/oradata/ORCLDB/redo01.log
Clearing online log 1 of thread 1 sequence number 1
Sun Jan  5 07:43:53 2014
Completed: alter database recover managed standby database disconnect from session
Sun Jan  5 07:43:55 2014
Clearing online redo logfile 1 complete
Media Recovery Log /u01/oracle/arch1/PHYSTDBY/1_39_795970778.dbf
Media Recovery Log /u01/oracle/arch1/PHYSTDBY/1_40_795970778.dbf
Media Recovery Waiting for thread 1 sequence 41
Sun Jan  5 07:44:56 2014
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[1]: Assigned to RFS process 13953
RFS[1]: Identified database type as 'physical standby'
Primary database is in MAXIMUM AVAILABILITY mode
Changing standby controlfile to RESYNCHRONIZATION level
Sun Jan  5 07:44:56 2014
RFS LogMiner: Client disabled from further notification
Primary database is in MAXIMUM AVAILABILITY mode
Changing standby controlfile to MAXIMUM AVAILABILITY level
RFS[1]: Successfully opened standby log 4: '/u01/oracle/oradata/ORCLDB/stdby_redo04.log'
Sun Jan  5 07:44:56 2014
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[2]: Assigned to RFS process 13955
RFS[2]: Identified database type as 'physical standby'
RFS[2]: Successfully opened standby log 5: '/u01/oracle/oradata/ORCLDB/stdby_redo05.log'
Sun Jan  5 07:45:01 2014
Media Recovery Log /u01/oracle/arch1/PHYSTDBY/1_41_795970778.dbf
Media Recovery Waiting for thread 1 sequence 42 (in transit)
Sun Jan  5 07:45:16 2014
Redo Shipping Client Connected as PUBLIC
-- Connected User is Valid
RFS[3]: Assigned to RFS process 13959
RFS[3]: Identified database type as 'physical standby'

推荐阅读:

Data Guard 配置 Standby Redo Log

RMAN duplicate for Standby失败解决过程

Data Gurad物理备份方式下以READ ONLY/WRITE模式打开物理Standby

RAC primary+Single Standby DG配置实践

Oracle Standby 策略 PPT

linux

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

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.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)