启动时应用重做日志,关闭时取消重做日志:
8.1 Starting Up and Shutting Down a Physical Standby Database
This section describes the SQL*Plus statements used to start up and shut down a physical standby database.
8.1.1 Starting Up a Physical Standby Database
To start a physical standby database, use SQL*Plus to connect to the database with administrator privileges, and then use either the SQL*Plus STARTUP
or STARTUP
MOUNT
statement. When used on a physical standby database:
-
The
STARTUP
statement starts the database, mounts the database as a physical standby database, and opens the database for read-only access. -
The
STARTUP MOUNT
statement starts and mounts the database as a physical standby database, but does not open the database. -
Once mounted, the database can receive archived redo data from the primary database. You then have the option of either starting Redo Apply or real-time apply, or opening the database for read-only access.
一旦数据库装载后,数据库就能从主库接收归档重做日志。然后,你可以选择启用应用重做或者实时应用,再或者以只读方式打开数据库来访问。
For example:
-
Start and mount the physical standby database:
SQL> STARTUP MOUNT; -
Start Redo Apply or real-time apply:
To start Redo Apply, issue the following statement:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE2> DISCONNECT FROM SESSION;
#########################################################################Sat Mar 29 11:48:57 2014ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSIONSat Mar 29 11:48:57 2014Attempt to start background Managed Standby Recovery process (PRODSTD)MRP0 started with pid=54, OS id=3158Sat Mar 29 11:48:57 2014MRP0: Background Managed Standby Recovery process started (PRODSTD)Managed Standby Recovery not using Real Time ApplyMedia Recovery Waiting for thread 1 sequence 29Sat Mar 29 11:49:03 2014Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION
############################################################################To start real-time apply, issue the following statement:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE2> USING CURRENT LOGFILE;
On the primary database, query the RECOVERY_MODE
column in the V$ARCHIVE_DEST_STATUS
view, which displays the standby database's operation as MANAGED_RECOVERY
for Redo Apply and MANAGED REAL TIME APPLY
for real-time apply.
在主库上,你可以查询V$ARCHIVE_DEST_STATUS的RECOVERY_MODE列,可以显示出备库的操作是
MANAGED_RECOVERY 重做应用还是MANAGED REAL TIME APPLY实时应用。
See Section 6.3 for information about Redo Apply, Section 6.2.1 for information about real-time apply, and Section 8.2 for information about opening a physical standby database for read-only or read/write access.
Note:
When you first start Redo Apply on a newly created physical standby database that has not yet received any redo data from the primary database, anORA-01112
message may be returned. This indicates that Redo Apply is unable to determine the starting sequence number for media recovery. If this occurs, you must either manually retrieve and register an archived redo log file on the standby database, or wait for the automatic archiving to occur before restarting Redo Apply.
8.1.2 Shutting Down a Physical Standby Database
To shut down a physical standby database and stop Redo Apply, use the SQL*Plus SHUTDOWN
statement. Control is not returned to the session that initiates a database shutdown until shutdown is complete.
关闭物理备库以及关闭重做应用,使用SHUTDOWN
语句。
If the primary database is up and running, defer the destination on the primary database and perform a log switch before shutting down the standby database.
如果主库正在运行,在主数据库上推迟目的地以及在关闭备库之前先执行日志切换。
To stop Redo Apply before shutting down the database, use the following steps:
在关闭数据库之前要先停止重做应用,使用一下步骤:
-
Issue the following query to find out if the standby database is performing Redo Apply or real-time apply. If the MRP0 or MRP process exists, then the standby database is applying redo.
1.通过如下查询找出备库是在重做应用还是实时应用,如果MRP0或者MRP进程存在,那么备库正在应用重做。
SQL> SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;
###############################################################################PROCESS STATUS--------- ------------ARCH CONNECTEDARCH CONNECTEDMRP0 WAIT_FOR_LOGRFS IDLERFS IDLE############################################################################### -
If Redo Apply is running, cancel it as shown in the following example:
2.如果重做应用正在运行,用如下例子来取消它。
###############################################################################Sat Mar 29 11:49:40 2014ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCELSat Mar 29 11:49:42 2014MRP0: Background Media Recovery cancelled with status 16037Sat Mar 29 11:49:42 2014Errors in file /u01/app/oracle/admin/PRODSTD/bdump/prodstd_mrp0_3158.trc:ORA-16037: user requested cancel of managed recovery operationRecovery interrupted!Sat Mar 29 11:49:43 2014Waiting for MRP0 pid 3158 to terminateWaiting for MRP0 pid 3158 to terminateWaiting for MRP0 pid 3158 to terminateSat Mar 29 11:49:45 2014Errors in file /u01/app/oracle/admin/PRODSTD/bdump/prodstd_mrp0_3158.trc:ORA-16037: user requested cancel of managed recovery operationSat Mar 29 11:49:45 2014MRP0: Background Media Recovery process shutdown (PRODSTD)Sat Mar 29 11:49:46 2014Managed Standby Recovery Canceled (PRODSTD)Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
取消日志应用之后,即没有MRP0的进程了。############################################################################### -
Shut down the standby database.
3.关闭备库。
SQL> SHUTDOWN IMMEDIATE;