欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

Oracle Data Guard_启动和关闭物理备库

程序员文章站 2022-05-28 14:43:44
...

启动时应用重做日志,关闭时取消重做日志: 8.1Starting Up and Shutting Down a Physical Standby Database This section descr

启动时应用重做日志,关闭时取消重做日志:

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.

Starting Up a Physical Standby Database

8.1.1 启动物理备库

To start a physical standby database, use SQL*Plus to connect to the database with administrator privileges, and then use either the SQL*PlusSTARTUPorSTARTUPMOUNTstatement. When used on a physical standby database:

  • TheSTARTUPstatement starts the database, mounts the database as a physical standby database, and opens the database for read-only access.

  • TheSTARTUP MOUNTstatement 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 DATABASE

    2>DISCONNECT FROM SESSION;

    #########################################################################

    Sat Mar 29 11:48:57 2014

    ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION

    Sat Mar 29 11:48:57 2014

    Attempt to start background Managed Standby Recovery process (PRODSTD)

    MRP0 started with pid=54, OS id=3158

    Sat Mar 29 11:48:57 2014

    MRP0: Background Managed Standby Recovery process started (PRODSTD)

    Managed Standby Recovery not using Real Time Apply

    Media Recovery Waiting for thread 1 sequence 29

    Sat Mar 29 11:49:03 2014

    Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION

    ############################################################################

    To start real-time apply, issue the following statement:

    SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE

    2>USING CURRENT LOGFILE;

  • On the primary database, query theRECOVERY_MODEcolumn in theV$ARCHIVE_DEST_STATUSview, which displays the standby database's operation asMANAGED_RECOVERYfor Redo Apply andMANAGED REAL TIME APPLYfor real-time apply.

    在主库上,你可以查询V$ARCHIVE_DEST_STATUS的RECOVERY_MODE列,可以显示出备库的操作是MANAGED_RECOVERY 重做应用还是MANAGED REAL TIME APPLY实时应用。

    Seefor information about Redo Apply,for information about real-time apply, andfor 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-01112message 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.

    当你在一个新创建的物理备库上第一次应用重做时,主库并没有归档日志传输到备库来,于是报错ORA-01112.这意味着重做应用无法为介质恢复提供一个日志序号。如果这个情况发生,你必须手动在备库上生成一个归档日志,,或者在重做应用之前自动归档。

    8.1.2Shutting Down a Physical Standby Database

    Toshut down a physical standby database and stop Redo Apply, use the SQL*PlusSHUTDOWNstatement. 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 CONNECTED

    ARCH CONNECTED

    MRP0 WAIT_FOR_LOG

    RFS IDLE

    RFS IDLE

    ###############################################################################

  • If Redo Apply is running, cancel it as shown in the following example:

    2.如果重做应用正在运行,用如下例子来取消它。

    SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

    ###############################################################################

    Sat Mar 29 11:49:40 2014

    ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL

    Sat Mar 29 11:49:42 2014

    MRP0: Background Media Recovery cancelled with status 16037

    Sat Mar 29 11:49:42 2014

    Errors in file /u01/app/Oracle/admin/PRODSTD/bdump/prodstd_mrp0_3158.trc:

    ORA-16037: user requested cancel of managed recovery operation

    Recovery interrupted!

    Sat Mar 29 11:49:43 2014

    Waiting for MRP0 pid 3158 to terminate

    Waiting for MRP0 pid 3158 to terminate

    Waiting for MRP0 pid 3158 to terminate

    Sat Mar 29 11:49:45 2014

    Errors in file /u01/app/oracle/admin/PRODSTD/bdump/prodstd_mrp0_3158.trc:

    ORA-16037: user requested cancel of managed recovery operation

    Sat Mar 29 11:49:45 2014

    MRP0: Background Media Recovery process shutdown (PRODSTD)

    Sat Mar 29 11:49:46 2014

    Managed Standby Recovery Canceled (PRODSTD)

    Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL

    取消日志应用之后,即没有MRP0的进程了。

    ###############################################################################

  • Shut down the standby database.

    3.关闭备库。

    SQL> SHUTDOWN IMMEDIATE;

  • 推荐阅读:

    RMAN 配置归档日志删除策略

    Oracle基础教程之通过RMAN复制数据库

    RMAN备份策略制定参考内容

    RMAN备份学习笔记

    Oracle数据库备份加密 RMAN加密