当前位置: 代码迷 >> 综合 >> Oracle 11g DataGuard 物理备库配置及Active DataGuard测试
  详细解决方案

Oracle 11g DataGuard 物理备库配置及Active DataGuard测试

热度:64   发布时间:2023-12-19 17:01:23.0
??

Oracle 11g DataGuard 物理备库配置及Active DataGuard测试

from:http://koumm.blog.51cto.com/703525/1263870

说明:
本文安装配置了Oracle 11g Dataguard 物理备库,并测试了11g Dataguard 物理备库新特性Active Data

Guard, 是Oracle Database Enterprise Edition的一个功能,需要额外授权,本文只用于测试。


一、环境介绍

1. 主数据库环境

操作系统版本: rhel 5.8 x64
数据库版本  : Oracle 11.2.0.1 x64
数据库sid名 : ora11g


2. 备库环境

操作系统版本: OEL5.8 x64
数据库版本  : Oracle 11.2.0.1 x64 (只安装oracle数据库软件,no netca dbca)
数据库sid名 : orcl


3. DataGuard启动顺序

启动顺序:先启备库,后启主库
关闭顺序:先关主库,后关备库


二、主数据库配置

1. 配置hosts文件

# vi /etc/hosts

10.80.18.241  ----主库
10.80.18.243  ----备库


2. 修改配置lisener监听文件--配置静态监听

$ cat /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora 

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.80.18.241)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ora11g)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = ora11g)
    )
  )


3. 修改配置tnsname.ora文件---添加主备库的服务别名

说明:ora11g是主库的服务名,orcl是备库的服务名。

$ vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora

ora11g =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.80.18.241)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ora11g)
    )
  )

orcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.80.18.243)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )


4. 修改配置成规档模式

1)、检查数据库是否处于归档状态

SQL> archive log list;
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;


2)、将主库设置为 FORCE LOGGING 模式

SQL> alter database force logging;
SQL> select force_logging from v$database;

FORCE_LOG
———
YES


5. 修改参数文件

SQL>
alter system set db_unique_name='ora11g' scope=spfile; 
alter system set log_archive_config='DG_CONFIG=(ora11g,orcl)'; 
alter system set log_archive_dest_1='LOCATION=/u01/app/ora11/flash_recovery_area valid_for=

(all_logfiles,all_roles) db_unique_name=ora11g' scope=spfile;
alter system set log_archive_dest_2='SERVICE=ora11g lgwr async valid_for=

(online_logfile,primary_role) db_unique_name=ora11g'; 

alter system set fal_client='ora11g'; 
alter system set fal_server='orcl';
 
alter system set standby_file_management=auto; 


------添加standby redo log file---------
alter database add standby logfile group 4

'/u01/app/ora11/oradata/ORA11G/onlinelog/standby_redo04.log' size 50M;
alter database add standby logfile group 5

'/u01/app/ora11/oradata/ORA11G/onlinelog/standby_redo05.log' size 50M;
alter database add standby logfile group 6

'/u01/app/ora11/oradata/ORA11G/onlinelog/standby_redo06.log' size 50M;
 alter database add standby logfile group 7

'/u01/app/ora11/oradata/ORA11G/onlinelog/standby_redo07.log' size 50M;

 
----重启使部分参数生效---------
shutdown immediate 
startup 
create pfile='/home/oracle/pfile.ora' from spfile; 


6. 将pfile文件拷贝到备库。
$ scp /u01/app/ora11/product/11.2.0/dbhome_1/dbs/initora11g.ora 10.80.18.243:/home/oracle/

 

三、备库配置

1. 配置hosts文件

# vi /etc/hosts

10.80.18.241  ora11g
10.80.18.243  oracle11g-dag

2. 修改配置lisener监听文件----配置静态监听

$ vi /oracle/app/oracle/product/db_1/network/admin/listener.ora

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.80.18.243)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = ora11g
      (ORACLE_HOME = /oracle/app/oracle/product/11.2.0/db_1)
      (SID_NAME = ora11g)
    )
  (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /oracle/app/oracle/product/11.2.0/db_1)
      (SID_NAME = orcl)
   )
  )

注意:这里配置的是静态监听,下面在duplicate数据库时启动到nomount状态,nomount状态下数据库不

动态去注册监听。


3. 修改配置tnsname.ora文件---配置主备服务别名

说明:ora11g是主库的服务名,orcl是备库的服务名。

$ vi /oracle/app/oracle/product/db_1/network/admin/tnsnames.ora

ora11g =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.80.18.241)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = lixrora
    )
  )

orcl=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.80.18.243)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )


主备库测试服务名连通性:
tnsping ora11g
tnsping orcl

su - oracle
sqlplus sys/oracle@ora11g as sysdba
sqlplus sys/oracle@orcl as sysdba


4. 创建11g数据库基本目录

# su - oracle

mkdir -p /u01/app/oracle/admin/orcl/{adump,dpdump,pfile,scripts} 
mkdir -p /u01/app/oracle/oradata/orcl 
mkdir -p /u01/app/oracle/fast_recovery_area/orcl
mkdir -p /u01/archivelog


5. 修改pfile参数文件----这边的部分参数需结合4.中的实际创建目录

$ vi /home/oracle/initorcl.ora

orcl.__db_cache_size=188743680
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__oracle_base='/oracle/app/oracle'
orcl.__pga_aggregate_target=285212672
orcl.__sga_target=532676608
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=322961408
orcl.__streams_pool_size=4194304
*.audit_file_dest='/oracle/app/oracle/admin/orcl/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/oracle/app/oracle/oradata/orcl/controlfile/control01_.ctl'
*.db_block_size=8192
*.db_create_file_dest='/oracle/app/oracle/oradata'
*.db_domain=''
*.db_name='orcl'
*.db_recovery_file_dest='/oracle/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4070572032
*.diagnostic_dest='/oracle/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.fal_client='ora11g'
*.fal_server='orcl'
*.log_archive_config='DG_CONFIG=(ora11g,orcl)'
*.log_archive_dest_1='LOCATION=/oracle/app/oracle/flash_recovery_area valid_for=

(all_logfiles,all_roles) db_unique_name=orcl'
*.log_archive_dest_2='SERVICE=ora11g lgwr async valid_for=(online_logfile,primary_role)

db_unique_name=orcl'
*.memory_target=817889280
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

 

说明:修改DG相关配置参数。

 


6. 在主库创建口令文件

# su - oracle
$ orapwd file='/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl' password=oracle entries=10


7. 备库启动到nomount状态

$ sqlplus /nolog
SQL> conn / as sysdba;
SQL> create spfile from pfile='/home/oracle/initorcl.ora'; 
SQL> startup nomount;


四、 开始在RMAN duplicate数据库


1. RMAN同进连接主库与备库

----在主库连接RMAN
$ rman target sys/oracle@ora11g auxiliarysys/oracle@orcl
or
rman target / auxiliary sys/oracle@orcl

恢复管理器: Release 11.2.0.3.0 - Production on 星期日 8月 4 00:53:40 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

已连接到目标数据库: ORCL (DBID=1350215700)
已连接到辅助数据库: ORCL (未装载)


2. 开始duplicate数据库

RMAN> duplicate target database for standby nofilenamecheck from active database;

启动 Duplicate Db 于 04-8月 -13
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_AUX_DISK_1
通道 ORA_AUX_DISK_1: SID=19 设备类型=DISK

内存脚本的内容:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl' auxiliary format
 '/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl'   ;
}
正在执行内存脚本

启动 backup 于 04-8月 -13
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=21 设备类型=DISK
完成 backup 于 04-8月 -13

内存脚本的内容:
{
   backup as copy current controlfile for standby auxiliary format 

'/u01/app/oracle/oradata/orcl/control01.ctl';
   restore clone controlfile to  '/u01/app/oracle/fast_recovery_area/orcl/control02.ctl'

from
 '/u01/app/oracle/oradata/orcl/control01.ctl';
}
正在执行内存脚本

启动 backup 于 04-8月 -13
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 启动数据文件副本
复制备用控制文件
输出文件名=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_orcl.f 标记=TAG20130804T005344

RECID=7 STAMP=822531224
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:01
完成 backup 于 04-8月 -13

启动 restore 于 04-8月 -13
使用通道 ORA_AUX_DISK_1

通道 ORA_AUX_DISK_1: 已复制控制文件副本
完成 restore 于 04-8月 -13

内存脚本的内容:
{
   sql clone 'alter database mount standby database';
}
正在执行内存脚本

sql 语句: alter database mount standby database

内存脚本的内容:
{
   set newname for tempfile  1 to
 "/u01/app/oracle/oradata/orcl/temp01.dbf";
   switch clone tempfile all;
   set newname for datafile  1 to
 "/u01/app/oracle/oradata/orcl/system01.dbf";
   set newname for datafile  2 to
 "/u01/app/oracle/oradata/orcl/sysaux01.dbf";
   set newname for datafile  3 to
 "/u01/app/oracle/oradata/orcl/undotbs01.dbf";
   set newname for datafile  4 to
 "/u01/app/oracle/oradata/orcl/users01.dbf";
   backup as copy reuse
   datafile  1 auxiliary format
 "/u01/app/oracle/oradata/orcl/system01.dbf"   datafile
 2 auxiliary format
 "/u01/app/oracle/oradata/orcl/sysaux01.dbf"   datafile
 3 auxiliary format
 "/u01/app/oracle/oradata/orcl/undotbs01.dbf"   datafile
 4 auxiliary format
 "/u01/app/oracle/oradata/orcl/users01.dbf"   ;
   sql 'alter system archive log current';
}
正在执行内存脚本

正在执行命令: SET NEWNAME

临时文件 1 在控制文件中已重命名为 /u01/app/oracle/oradata/orcl/temp01.dbf

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

启动 backup 于 04-8月 -13
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件: 文件号=00001 名称=/u01/app/oracle/oradata/orcl/system01.dbf

输出文件名=/u01/app/oracle/oradata/orcl/system01.dbf 标记=TAG20130804T005352
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:09:20
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件: 文件号=00002 名称=/u01/app/oracle/oradata/orcl/sysaux01.dbf
输出文件名=/u01/app/oracle/oradata/orcl/sysaux01.dbf 标记=TAG20130804T005352
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:03:48
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件: 文件号=00003 名称=/u01/app/oracle/oradata/orcl/undotbs01.dbf
输出文件名=/u01/app/oracle/oradata/orcl/undotbs01.dbf 标记=TAG20130804T005352
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:25
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件: 文件号=00004 名称=/u01/app/oracle/oradata/orcl/users01.dbf
输出文件名=/u01/app/oracle/oradata/orcl/users01.dbf 标记=TAG20130804T005352
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:03
完成 backup 于 04-8月 -13

sql 语句: alter system archive log current

内存脚本的内容:
{
   switch clone datafile all;
}
正在执行内存脚本

数据文件 1 已转换成数据文件副本
输入数据文件副本 RECID=7 STAMP=822532054 文件名=/u01/app/oracle/oradata/orcl/system01.dbf
数据文件 2 已转换成数据文件副本
输入数据文件副本 RECID=8 STAMP=822532054 文件名=/u01/app/oracle/oradata/orcl/sysaux01.dbf
数据文件 3 已转换成数据文件副本
输入数据文件副本 RECID=9 STAMP=822532054 文件名=/u01/app/oracle/oradata/orcl/undotbs01.dbf
数据文件 4 已转换成数据文件副本
输入数据文件副本 RECID=10 STAMP=822532054 文件名=/u01/app/oracle/oradata/orcl/users01.dbf
完成 Duplicate Db 于 04-8月 -13

RMAN>
RMAN>
Starting Duplicate Db at 19-FEB-14
using channel ORA_AUX_DISK_1

contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/ora11/product/11.2.0/dbhome_1/dbs/orapwora11g' auxiliary format
 '/oracle/app/oracle/product/db_1/dbs/orapworcl'   ;
}
executing Memory Script

Starting backup at 19-FEB-14
using channel ORA_DISK_1
Finished backup at 19-FEB-14

contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format 

'/oracle/app/oracle/oradata/orcl/controlfile/control01_.ctl';
}
executing Memory Script

Starting backup at 19-FEB-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/u01/app/ora11/product/11.2.0/dbhome_1/dbs/snapcf_ora11g.f

tag=TAG20140219T090944 RECID=8 STAMP=839927384
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 19-FEB-14

contents of Memory Script:
{
   sql clone 'alter database mount standby database';
}
executing Memory Script

sql statement: alter database mount standby database

contents of Memory Script:
{
   set newname for clone tempfile  1 to new;
   switch clone tempfile all;
   set newname for clone datafile  1 to new;
   set newname for clone datafile  2 to new;
   set newname for clone datafile  3 to new;
   set newname for clone datafile  4 to new;
   set newname for clone datafile  5 to new;
   backup as copy reuse
   datafile  1 auxiliary format new
   datafile  2 auxiliary format new
   datafile  3 auxiliary format new
   datafile  4 auxiliary format new
   datafile  5 auxiliary format new
   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /oracle/app/oracle/oradata/ORCL/datafile/o1_mf_temp_%u_.tmp in control

file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 19-FEB-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002

name=/u01/app/ora11/oradata/ORA11G/datafile/o1_mf_sysaux_907t6zgo_.dbf
output file name=/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_05p10hj0_.dbf

tag=TAG20140219T090952
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:46
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001

name=/u01/app/ora11/oradata/ORA11G/datafile/o1_mf_system_907t6zf3_.dbf
output file name=/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_system_06p10hke_.dbf

tag=TAG20140219T090952
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003

name=/u01/app/ora11/oradata/ORA11G/datafile/o1_mf_undotbs1_907t6zgx_.dbf
output file name=/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_07p10hmp_.dbf

tag=TAG20140219T090952
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005

name=/u01/app/ora11/oradata/ORA11G/datafile/o1_mf_example_907t9tcd_.dbf
output file name=/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_example_08p10hnj_.dbf

tag=TAG20140219T090952
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004

name=/u01/app/ora11/oradata/ORA11G/datafile/o1_mf_users_907t6zht_.dbf
output file name=/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_users_09p10hnq_.dbf

tag=TAG20140219T090952
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 19-FEB-14

sql statement: alter system archive log current

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=8 STAMP=839913151 file

name=/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_system_06p10hke_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=9 STAMP=839913151 file

name=/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_05p10hj0_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=10 STAMP=839913151 file

name=/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_07p10hmp_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=11 STAMP=839913151 file

name=/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_users_09p10hnq_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=12 STAMP=839913151 file

name=/oracle/app/oracle/oradata/ORCL/datafile/o1_mf_example_08p10hnj_.dbf
Finished Duplicate Db at 19-FEB-14

RMAN> exit
Recovery Manager complete.

3. 查看备库状态

说明:duplicate数据库之后,备库只是处于mount状态,查看备库状态。

[oracle@slave orcl]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on 星期日 8月 4 01:09:07 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

SQL> conn / as sysdba;
已连接。


# 查看备库状态

SQL>  select open_mode,database_role,db_unique_name from v$database;

OPEN_MODE           DATABASE_ROLE    DB_UNIQUE_NAME
-------------------- ---------------- ------------------------------
MOUNTED             PHYSICAL STANDBY DG

 

4. 将备库置与应用日志模式状态

SQL> alter database recover managed standby database using current logfile disconnect from

session; 
Database altered. 

SQL> select open_mode,database_role,db_unique_name from v$database;

OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME
-------------------- ---------------- ------------------------------
MOUNTED              PHYSICAL STANDBY DG

 

5. 验证物理备库日志应用

1)主库上操作

SQL> conn / as sysdba;
SQL> create user abc identified by abc ;
用户已创建。

SQL> grant dba to abc;
授权成功。

SQL> conn abc/abc
已连接。

SQL> create table abc ( id integer , name char(10));
表已创建。

SQL> insert into abc values ( 0 , 'aaa' );
已创建 1 行。

SQL> commit;
提交完成。

SQL> conn / as sysdba;
已连接。

SQL> archive log list;
数据库日志模式            存档模式
自动存档                  启用
存档终点                  /u01/archivelog/
最早的联机日志序列        18
下一个存档日志序列        20
当前日志序列              20
SQL>


2)备库上验证

SQL> archive log list;
数据库日志模式            存档模式
自动存档                  启用
存档终点                  /u01/archivelog/
最早的联机日志序列        18
下一个存档日志序列        0
当前日志序列              20

SQL> select sequence#,first_time,next_time,applied from v$archived_log order by sequence#;

 SEQUENCE# FIRST_TIME     NEXT_TIME      APPLIED
---------- -------------- -------------- ---------
        12 04-8月 -13     04-8月 -13     YES
        13 04-8月 -13     04-8月 -13     YES
        14 04-8月 -13     04-8月 -13     YES
        15 04-8月 -13     04-8月 -13     YES
        16 04-8月 -13     04-8月 -13     YES
        17 04-8月 -13     04-8月 -13     YES
        18 04-8月 -13     04-8月 -13     YES
        19 04-8月 -13     04-8月 -13     YES
        20 04-8月 -13     04-8月 -13     IN-MEMORY

已选择9行。

说明: IN-MEMORY是11G的新特性。

 

五、将备库置于Active DataGuard模式,体验实时查询


在Oracle 11g之前,物理备库(physical Standby)在应用redo的时候,数据库需要处于mount状态。从

11g开始,应用redo的时候,物理备库可以处于read-only模式,这就称为Active Data Guard 。通过

Active Data Guard,可以在物理备库进行查询或者导出数据,从而减少对主库的访问和压力。


1. 备库上操作

1) 查看备库当前状态 mount

SQL> select open_mode,database_role,db_unique_name from v$database;

OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME
-------------------- ---------------- ------------------------------
MOUNTED              PHYSICAL STANDBY DG


2) 取消备库的自动恢复

SQL> alter database recover managed standby database cancel;
数据库已更改。


3) OPEN备库为只读模式(Dataguard只能启动到readonly模式)

SQL> alter database open;
数据库已更改。


SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ ONLY


4)打开实时应用状态模式

SQL> alter database recover managed standby database using current logfile disconnect;
数据库已更改。


SQL> select open_mode,database_role,db_unique_name from v$database;

OPEN_MODE            DATABASE_ROLE    DB_UNIQUE_NAME
-------------------- ---------------- ------------------------------
READ ONLY WITH APPLY PHYSICAL STANDBY DG

 

2. 主库上操作执行DDL,DML操作

# su - oracle

$ sqlplus /nolog
SQL> conn / as sysdba;

SQL> create tablespace abc datafile '/u01/app/oracle/oradata/orcl/abc.dbf' size 10m

autoextend on next 10m;
表空间已创建。

SQL> conn abc/abc
已连接。
SQL> insert into abc values (1 , 'bbb');
已创建 1 行。

SQL> commit;
提交完成。

SQL>


3. 备库上查看

SQL> select name from v$tablespace;

NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
ABC

已选择6行。


SQL> conn abc/abc;
已连接。

SQL> select * from abc;

        ID NAME
---------- ----------
         0 aaa
         1 bbb


主备的修改很快在备库上应用。

  相关解决方案