本文是Oracle LiveLabs实验:Setting Up Active Data Guard For On-Premises 的过程记录。

实验步骤请参考这里。

因为是利用你自己的OCI云环境搭建,因此实验没有终止时间。

首先创建2个虚拟机primary和standby,primary上创建数据库,standby上仅安装数据库软件。

这两个环境是利用OCI创建的,使用了Oracle应用市场上的Oracle Database Image。

虚机primary的初始化脚本如下:

#cloud-config
runcmd:- mount /u01- /u01/ocidb/GenerateNetconfig.sh > /u01/ocidb/netconfig.ini- SIDNAME=ORCL DBNAME=ORCL DBCA_PLUGGABLE_DB_NAME=orclpdb /u01/ocidb/buildsingle.sh -s

虚机standby的初始化脚本如下:

#cloud-config
runcmd:- mount /u01- /u01/ocidb/GenerateNetconfig.sh > /u01/ocidb/netconfig.ini- sudo /bin/chown -HRf oracle:oinstall /u01/app- sudo -u oracle /u01/app/oracle/product/19c/dbhome_1/oui/bin/runInstaller -silent -ignoreSysPrereqs -waitforcompletion -attachHome INVENTORY_LOCATION='/u01/app/oraInventory' ORACLE_HOME='/u01/app/oracle/product/19c/dbhome_1' ORACLE_HOME_NAME='OraDB19Home1' ORACLE_BASE='/u01/app/oracle'   -local- sudo -u oracle /u01/app/oraInventory/orainstRoot.sh

其中runInstaller使用OUI静态安装方式,可参考这里。

standby上没有建库,因此很快就绪。

主数据库服务器配置

primary上建库就绪需要约30分钟:

[opc@primary ~]$ tail -f /u01/ocidb/buildsingle*.log
==> /u01/ocidb/buildsingle_createdbpostsql_2021Dec14_12_53_12.log <==
2021-12-14 12:53:12:[createdbpostsql:Start:primary] Running DBCA post creation scriptsINFO (node:primary): Not executing /u01/app/oracle/product/19c/dbhome_1/OPatch/datapatch since DBCA runs it automatically on release 18c and higher; detected Database major release (19)
2021-12-14 12:53:12:[createdbpostsql:Done :primary] Running DBCA post creation scripts
2021-12-14 12:53:12:[createdbpostsql:Time :primary] Completed successfully in 0 seconds (0h:00m:00s)==> /u01/ocidb/buildsingle.log <==INFO (node:primary): Current Single Instance state (12:53:13)...
oracle   13706     1  0 12:23 ?        00:00:00 /u01/app/oracle/product/19c/dbhome_1/bin/tnslsnr LISTENER -inherit
oracle   18737     1  0 12:52 ?        00:00:00 ora_dbw0_ORCLINFO (node:primary): Single Instance running (see output above)2021-12-14 12:53:13:[singlestate:Time :primary] Completed successfully in 0 seconds (0h:00m:00s)
2021-12-14 12:53:13:[buildsingle:Done :primary] Building 19c Single Instance
2021-12-14 12:53:13:[buildsingle:Time :primary] Completed successfully in 1836 seconds (0h:30m:36s)

确认数据库已启动:

[opc@primary ~]$ ps -ef | grep smon
oracle   18753     1  0 12:52 ?        00:00:00 ora_smon_ORCL

主库开启归档:

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/product/19c/dbhome_1/dbs/arch
Oldest online log sequence     13
Current log sequence           15
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.SQL> startup mount
ORACLE instance started.Total System Global Area 4630509232 bytes
Fixed Size                  9143984 bytes
Variable Size             855638016 bytes
Database Buffers         3758096384 bytes
Redo Buffers                7630848 bytes
Database mounted.SQL> alter database archivelog;
Database altered.SQL> alter database open;
Database altered.SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/product/19c/dbhome_1/dbs/arch
Oldest online log sequence     13
Next log sequence to archive   15
Current log sequence           15

主库开启闪回:

SQL> !mkdir -p /u01/app/oracle/fra/ORCLSQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 10G SCOPE=BOTH SID='*';
System altered.SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/u01/app/oracle/fra/ORCL' SCOPE=BOTH SID='*';
System altered.SQL> alter database flashback on;
Database altered.

启用force logging:

SQL> alter database force logging;
Database altered.

按照文档,启用force logging的目的如下:

In FORCE LOGGING mode, Oracle Database logs all changes in the database except changes in temporary tablespaces and temporary segments. This setting takes precedence over and is independent of any NOLOGGING or FORCE LOGGING settings you specify for individual tablespaces and any NOLOGGING settings you specify for individual database objects.

修改Redo Log大小:

SQL> select group#, bytes, status from v$log;GROUP#      BYTES STATUS
---------- ---------- ----------------1  209715200 INACTIVE2  209715200 INACTIVE3  209715200 CURRENTSQL>
alter database add logfile group 4 '/u01/app/oracle/oradata/ORCL/redo04.log' size 1024M;
alter database add logfile group 5 '/u01/app/oracle/oradata/ORCL/redo05.log' size 1024M;
alter database add logfile group 6 '/u01/app/oracle/oradata/ORCL/redo06.log' size 1024M;Database altered.
Database altered.
Database altered.SQL> select group#, bytes, status from v$log;GROUP#      BYTES STATUS
---------- ---------- ----------------1  209715200 INACTIVE2  209715200 INACTIVE3  209715200 CURRENT4 1073741824 UNUSED5 1073741824 UNUSED6 1073741824 UNUSED6 rows selected.-- switch log group,目的是为了删除老的log group
SQL>
alter system switch logfile;
alter system checkpoint;System altered.
System altered.SQL> select group#, bytes, status from v$log;GROUP#      BYTES STATUS
---------- ---------- ----------------1  209715200 INACTIVE2  209715200 INACTIVE3  209715200 INACTIVE4 1073741824 CURRENT5 1073741824 UNUSED6 1073741824 UNUSED6 rows selected.-- 删除老的redo log group
SQL>
alter database drop logfile group 1;
alter database drop logfile group 2;
alter database drop logfile group 3;SQL> select group#, bytes, status from v$log;GROUP#      BYTES STATUS
---------- ---------- ----------------4 1073741824 CURRENT5 1073741824 UNUSED6 1073741824 UNUSED

创建Standby Log,要比Primary redo log多一个:

SQL>
alter database add standby logfile thread 1 '/u01/app/oracle/oradata/ORCL/srl_redo01.log' size 1024M;
alter database add standby logfile thread 1 '/u01/app/oracle/oradata/ORCL/srl_redo02.log' size 1024M;
alter database add standby logfile thread 1 '/u01/app/oracle/oradata/ORCL/srl_redo03.log' size 1024M;
alter database add standby logfile thread 1 '/u01/app/oracle/oradata/ORCL/srl_redo04.log' size 1024M;-- 为何是1、2、3、7?因为4、5、6已占用
SQL> select group#,thread#,bytes from v$standby_log;GROUP#    THREAD#      BYTES
---------- ---------- ----------1          1 10737418242          1 10737418243          1 10737418247          1 1073741824

修改初始化参数:

alter system set STANDBY_FILE_MANAGEMENT=AUTO scope=both;
alter system set DB_LOST_WRITE_PROTECT=TYPICAL scope=both;
alter system set FAST_START_MTTR_TARGET=300 scope=both;

STANDBY_FILE_MANAGEMENT概念参见这里。

DB_LOST_WRITE_PROTECT概念参见这里。

FAST_START_MTTR_TARGET参见这里 , 此处设为300秒。

主备数据库服务器均开启1521端口:

sudo firewall-cmd --zone=public --add-port=1521/tcp --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-all

VCN上已经开启1521端口,因此此处无需设置。

查询主备数据库服务器的IP地址和主机名:

# 主数据库服务器
[opc@primary ~]$ hostname -A
primary.subnet1.primaryvcn.oraclevcn.com
[opc@primary ~]$ hostname
primary
[opc@primary ~]$ hostname -I
10.0.1.185# 备数据库服务器
[opc@standby ~]$ hostname -A
standby.subnet1.standbyvcn.oraclevcn.com
[opc@standby ~]$ hostname
standby
[opc@standby ~]$ hostname -I
10.0.1.205

然后将以下内容添加到主备服务器的/etc/hosts文件:

10.0.1.185 primary primary.subnet1.primaryvcn.oraclevcn.com
10.0.1.205 standby standby.subnet1.standbyvcn.oraclevcn.com

备数据库服务器配置

在~oracle/.bash_profile中添加以下内容:

export ORACLE_BASE=/u01/app/oracle;
export ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1;
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_SID=ORCL

使其生效:

$ source .bash_profile

启动监听:

$ lsnrctl start

配置static listener,理由参见MOS 1387859.1 。在文件$ORACLE_HOME/network/admin/listener.ora中添加以下内容:

SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(GLOBAL_DBNAME=ORCL)(ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1)(SID_NAME=ORCL))(SID_DESC=(GLOBAL_DBNAME=ORCL_DGMGRL)(ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1)(SID_NAME=ORCL)))

重启监听:

$ lsnrctl reload

在主数据库服务器上的tnsnames.ora文件中添加以下内容:

# $ORACLE_HOME/network/admin/tnsnames.oraORCLSTBY =(DESCRIPTION =(SDU=65536)(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORCLSTBY)(UR=A)))

在备数据库服务器上的tnsnames.ora文件中添加以下内容:

LISTENER_ORCLSTBY =(ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521))ORCLSTBY =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORCLSTBY)))ORCL =(DESCRIPTION =(SDU=65536)(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = primary)(PORT = 1521)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORCL)(UR=A)))

在备数据库服务器,以oracle用户创建以下目录:

mkdir -p /u01/app/oracle/oradata/ORCLSTBY/pdbseed
mkdir -p /u01/app/oracle/oradata/ORCLSTBY/orclpdb
mkdir -p /u01/app/oracle/admin/ORCLSTBY/adump
mkdir -p /u01/app/oracle/admin/ORCLSTBY/dpdump
mkdir -p /u01/app/oracle/admin/ORCLSTBY/pfile

在备数据库服务器,新建文件/u01/app/oracle/product/19c/dbhome_1/dbs/initORCLSTBY.ora,并添加以下内容:

DB_NAME=ORCL
DB_UNIQUE_NAME=ORCLSTBY

在备数据库服务器上,拷贝主数据库服务器上的口令文件:

$ scp primary:/u01/app/oracle/product/19c/dbhome_1/dbs/orapwORCL $ORACLE_HOME/dbs/

在备数据库服务器上,启动数据库到nomount状态:

$ sqlplus / as sysdba
SQL> startup nomount pfile='/u01/app/oracle/product/19c/dbhome_1/dbs/initORCLSTBY.ora'
ORACLE instance started.Total System Global Area  251656864 bytes
Fixed Size                  8895136 bytes
Variable Size             184549376 bytes
Database Buffers           50331648 bytes
Redo Buffers                7880704 bytes

启动RMAN,从主库复制数据库:

$ rman target sys/Ora_DB4U@ORCL auxiliary sys/Ora_DB4U@ORCLSTBYRecovery Manager: Release 19.0.0.0.0 - Production on Tue Dec 14 15:13:49 2021
Version 19.11.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.connected to target database: ORCL (DBID=1619057509)
connected to auxiliary database: ORCL (not mounted)RMAN>
run {
duplicate target database for standby from active database
spfile
parameter_value_convert 'ORCL','ORCLSTBY'
set db_name='ORCL'
set db_unique_name='ORCLSTBY'
set db_create_file_dest='/u01/app/oracle/oradata/ORCLSTBY'
set db_recovery_file_dest='/u01/app/oracle/oradata/ORCLSTBY'
set db_file_name_convert='/ORCL/','/ORCLSTBY/'
set log_file_name_convert='/ORCL/','/ORCLSTBY/'
;
}...
Finished Duplicate Db at 14-DEC-21

在主备数据库均运行以下命令:

show parameter dg_broker_config_file;
show parameter dg_broker_start;
alter system set dg_broker_start=true;
select pname from v$process where pname like 'DMON%';

输出如下:

-- 主库
SQL> show parameter dg_broker_config_file;NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1               string      /u01/app/oracle/product/19c/dbhome_1/dbs/dr1ORCL.dat
dg_broker_config_file2               string      /u01/app/oracle/product/19c/dbhome_1/dbs/dr2ORCL.datSQL> show parameter dg_broker_start;NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dg_broker_start                      boolean     FALSESQL> alter system set dg_broker_start=true;System altered.SQL> select pname from v$process where pname like 'DMON%';PNAME
-----
DMON-- 备库
SQL> show parameter dg_broker_config_file;NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1               string      /u01/app/oracle/product/19c/dbhome_1/dbs/dr1ORCLSTBY.dat
dg_broker_config_file2               string      /u01/app/oracle/product/19c/dbhome_1/dbs/dr2ORCLSTBY.datSQL> show parameter dg_broker_start;NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dg_broker_start                      boolean     TRUESQL> alter system set dg_broker_start=true;System altered.SQL> select pname from v$process where pname like 'DMON%';PNAME
-----
DMON

在DGMGRL中注册ADG配置:

[oracle@primary dbs]$ dgmgrl sys/Ora_DB4U@ORCL
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Tue Dec 14 15:24:07 2021
Version 19.11.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.Welcome to DGMGRL, type "help" for information.
Connected to "ORCL"
Connected as SYSDBA.
DGMGRL> CREATE CONFIGURATION adgconfig AS PRIMARY DATABASE IS ORCL CONNECT IDENTIFIER IS ORCL;
Configuration "adgconfig" created with primary database "orcl"
DGMGRL> ADD DATABASE ORCLSTBY AS CONNECT IDENTIFIER IS ORCLSTBY MAINTAINED AS PHYSICAL;
Database "orclstby" added
DGMGRL> ENABLE CONFIGURATION;
Enabled.
DGMGRL> SHOW CONFIGURATION;Configuration - adgconfigProtection Mode: MaxPerformanceMembers:orcl     - Primary databaseorclstby - Physical standby databaseWarning: ORA-16854: apply lag could not be determinedFast-Start Failover:  DisabledConfiguration Status:
WARNING   (status updated 5 seconds ago)

测试配置,在主库创建用户:

[oracle@primary dbs]$ sqlplus / as sysdbaSQL> show pdbsCON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------2 PDB$SEED                       READ ONLY  NO3 ORCLPDB                        READ WRITE NOalter session set container=orclpdb;
create user testuser identified by testuser;
grant connect,resource to testuser;
alter user testuser quota unlimited on users;
connect testuser/testuser@orclpdb
create table test(a number,b varchar2(20));
insert into test values(1,'line1');
commit;

然后在备库:

$ sqlplus / as sysdba
SQL> select open_mode,database_role from v$database;OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
MOUNTED              PHYSICAL STANDBYSQL> alter database open;
Database altered.SQL> alter pluggable database orclpdb open;
Pluggable database altered.SQL> show pdbsCON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------2 PDB$SEED                       READ ONLY  NO3 ORCLPDB                        READ ONLY  NOSQL> select open_mode,database_role from v$database;OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ ONLY            PHYSICAL STANDBY-- https://oracle-base.com/articles/9i/data-guard
SQL> alter database recover managed standby database cancel;
Database altered.SQL> alter database recover managed standby database using current logfile disconnect;
Database altered.SQL> select open_mode,database_role from v$database;OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ ONLY WITH APPLY PHYSICAL STANDBYSQL> connect testuser/testuser@localhost:1521/orclpdb
Connected.SQL> select * from test;A B
---------- --------------------1 line1

从主数据库服务器下载测试脚本:

wget https://objectstorage.us-ashburn-1.oraclecloud.com/p/Bq05Vhib-p_vraOu-wFpTEmyydA4d8qekXWXcb6W6M3pL43LVSAS2eFwKpYvAVxQ/n/c4u04/b/data-management-library-files/o/workload.sh
wget https://objectstorage.us-ashburn-1.oraclecloud.com/p/KNpGKB2VdoBWC5VWOHvD5vHg9P1OO5mqBJUxNonwY9LzaMaZ8Kcu7w3wBq9xgebW/n/c4u04/b/data-management-library-files/o/scn.sql

这两个脚本和多租户实验中的几乎一样:

[oracle@primary ~]$ cat workload.sh
echo ""
echo "  NOTE:"
echo "  To break out of this batch"
echo "  job, please issue CTL-C "
echo ""
echo "...sleeping 5 seconds"
echo ""
sleep 5sqlplus -S /nolog << EOFconnect testuser/testuser@orclpdb;drop table sale_orders;create table sale_orders(ORDER_ID number, ORDER_DATE varchar2(9), CUSTOMER_ID number);
EOFc=1
while [ $c -le 1000 ]
dosqlplus -S /nolog  << EOFconnect testuser/testuser@orclpdb;insert allinto sale_orders (ORDER_ID, ORDER_DATE, CUSTOMER_ID) VALUES (3041,'10-MAY-20', 13287)into sale_orders (ORDER_ID, ORDER_DATE, CUSTOMER_ID) VALUES (3041,'10-MAY-20', 13287)into sale_orders (ORDER_ID, ORDER_DATE, CUSTOMER_ID) VALUES (3041,'10-MAY-20', 13287)into sale_orders (ORDER_ID, ORDER_DATE, CUSTOMER_ID) VALUES (3041,'10-MAY-20', 13287)into sale_orders (ORDER_ID, ORDER_DATE, CUSTOMER_ID) VALUES (3041,'10-MAY-20', 13287)into sale_orders (ORDER_ID, ORDER_DATE, CUSTOMER_ID) VALUES (3041,'10-MAY-20', 13287)into sale_orders (ORDER_ID, ORDER_DATE, CUSTOMER_ID) VALUES (3041,'10-MAY-20', 13287)into sale_orders (ORDER_ID, ORDER_DATE, CUSTOMER_ID) VALUES (3035,'10-MAY-20', 13287)into sale_orders (ORDER_ID, ORDER_DATE, CUSTOMER_ID) VALUES (3041,'10-MAY-20', 13287)into sale_orders (ORDER_ID, ORDER_DATE, CUSTOMER_ID) VALUES (3041,'10-MAY-20', 13287)select 1 from dual;commit;select count(*) from sale_orders;@scn.sql
EOF
sleep 1
(( c++))

scn.sql如下:

$ cat scn.sql
conn system/Ora_DB4U@orclpdb
select current_scn, to_char(sysdate, 'YYYYMMDD-HH12MISS') time from v$database;

在主库运行脚本:

chmod a+x workload.sh
./workload.sh

在备库可以看到变化:

SQL> connect testuser/testuser@localhost:1521/orclpdb
Connected.SQL> select count(*) from sale_orders;COUNT(*)
----------310SQL> /COUNT(*)
----------360SQL> /COUNT(*)
----------380SQL> connect / as sysdba
Connected.
SQL> SELECT current_scn FROM v$database;CURRENT_SCN
-----------2685705SQL> /CURRENT_SCN
-----------2685750

查看主备之间的延迟:

SQL>
set linesize 120;
column name format a25;
column value format a20;
column time_computed format a20;
column datum_time format a20;
select name, value, time_computed, datum_time from v$dataguard_stats;NAME                      VALUE                TIME_COMPUTED        DATUM_TIME
------------------------- -------------------- -------------------- --------------------
transport lag             +00 00:00:00         12/14/2021 15:40:04  12/14/2021 15:40:03
apply lag                 +00 00:00:00         12/14/2021 15:40:04  12/14/2021 15:40:03
apply finish time         +00 00:00:00.000     12/14/2021 15:40:04
estimated startup time    9                    12/14/2021 15:40:04

使用DGMGRL查看延迟:

$ dgmgrl sys/Ora_DB4U@orcl
DGMGRL> show database ORCLSTBYDatabase - orclstbyRole:               PHYSICAL STANDBYIntended State:     APPLY-ONTransport Lag:      0 seconds (computed 0 seconds ago)Apply Lag:          0 seconds (computed 1 second ago)Average Apply Rate: 3.00 KByte/sReal Time Query:    ONInstance(s):ORCLDatabase Status:
SUCCESS

执行 switchover,在主备数据库服务器均可:

$ dgmgrl sys/Ora_DB4U@orclDGMGRL> validate database ORCLSTBYDatabase Role:     Physical standby databasePrimary Database:  orclReady for Switchover:  YesReady for Failover:    Yes (Primary Running)Flashback Database Status:orcl    :  Onorclstby:  OffManaged by Clusterware:orcl    :  NOorclstby:  NOValidating static connect identifier for the primary database orcl...The static connect identifier allows for a connection to database "orcl".DGMGRL> switchover to orclstby
Performing switchover NOW, please wait...
Operation requires a connection to database "orclstby"
Connecting ...
Connected to "ORCLSTBY"
Connected as SYSDBA.
New primary database "orclstby" is opening...
Operation requires start up of instance "ORCL" on database "orcl"
Starting instance "ORCL"...
Connected to an idle instance.
ORACLE instance started.
Connected to "ORCL"
Database mounted.
Database opened.
Connected to "ORCL"
Switchover succeeded, new primary is "orclstby"DGMGRL> show configurationConfiguration - adgconfigProtection Mode: MaxPerformanceMembers:orclstby - Primary databaseorcl     - Physical standby databaseFast-Start Failover:  DisabledConfiguration Status:
SUCCESS   (status updated 13 seconds ago)

主数据库服务器变为standby:

[oracle@primary ~]$ sqlplus / as sysdbaSQL> show pdbsCON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------2 PDB$SEED                       READ ONLY  NO3 ORCLPDB                        READ ONLY  NOSQL> select open_mode,database_role from v$database;OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ ONLY WITH APPLY PHYSICAL STANDBY

备数据库服务器变为primary:

[oracle@standby ~]$ sqlplus / as sysdbaSQL> show pdbsCON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------2 PDB$SEED                       READ ONLY  NO3 ORCLPDB                        READ WRITE NOSQL> select open_mode,database_role,flashback_on from v$database;OPEN_MODE            DATABASE_ROLE    FLASHBACK_ON
-------------------- ---------------- ------------------
READ WRITE           PRIMARY          NO

下面测试failover。主库的flash back前面已经打开了,但备库还没有。因此需要打开

[oracle@standby ~]$ sqlplus / as sysdba
shutdown immediate;
startup mount;
!mkdir -p /u01/app/oracle/fra/ORCL
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 10G SCOPE=BOTH;
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/u01/app/oracle/fra/ORCL' SCOPE=BOTH;
alter database flashback on;
alter database open;
alter pluggable database all open;
select open_mode,database_role,flashback_on from v$database;OPEN_MODE            DATABASE_ROLE    FLASHBACK_ON
-------------------- ---------------- ------------------
READ WRITE           PRIMARY          YES

执行 failover,在主备数据库服务器均可:

$ dgmgrl sys/Ora_DB4U@orclDGMGRL> show configurationConfiguration - adgconfigProtection Mode: MaxPerformanceMembers:orclstby - Primary databaseorcl     - Physical standby databaseFast-Start Failover:  DisabledConfiguration Status:
SUCCESS   (status updated 23 seconds ago)DGMGRL> validate database orclstbyDatabase Role:    Primary databaseReady for Switchover:  YesManaged by Clusterware:orclstby:  NOValidating static connect identifier for the primary database orclstby...The static connect identifier allows for a connection to database "orclstby".DGMGRL> validate database orclDatabase Role:     Physical standby databasePrimary Database:  orclstbyReady for Switchover:  YesReady for Failover:    Yes (Primary Running)Managed by Clusterware:orclstby:  NOorcl    :  NOValidating static connect identifier for the primary database orclstby...The static connect identifier allows for a connection to database "orclstby".DGMGRL> failover to orcl
Performing failover NOW, please wait...
Failover succeeded, new primary is "orcl"
DGMGRL> connect sys/Ora_DB4U@orclstby
Connected to "ORCLSTBY"
Connected as SYSDBA.
DGMGRL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
Connected to an idle instance.
DGMGRL> startup mount
Connected to "ORCLSTBY"
ORACLE instance started.
Database mounted.DGMGRL> connect sys/Ora_DB4U@orcl
Connected to "ORCL"
Connected as SYSDBA.
DGMGRL> reinstate database orclstby
Reinstating database "orclstby", please wait...
Reinstatement of database "orclstby" succeeded
DGMGRL> show configurationConfiguration - adgconfigProtection Mode: MaxPerformanceMembers:orcl     - Primary databaseorclstby - Physical standby databaseFast-Start Failover:  DisabledConfiguration Status:
SUCCESS   (status updated 19 seconds ago)

待改进之处

此实验数据库主机使用的是公网地址,而且源和目标数据库服务器均在不同VCN,且CIDR相同,导致也没法做Local Peering,因此建议改为私网地址。

Oracle Livelabs实验: Setting Up Active Data Guard For On-Premises相关推荐

  1. Oracle Active Data Guard和Data Guard的区别

    当谈到概念时,Data Guard涉及范围更广,它有时会指一种配置,一种灾备方案等.而Active Data Guard则指数据库企业版选件. 但谈到功能时,Data Guard已包含在Oracle数 ...

  2. Steps to configure Oracle 11g Data Guard Physical Standby – Active Data Guard Part-I

    2019独角兽企业重金招聘Python工程师标准>>> Steps to configure Oracle 11g Data Guard Physical Standby – Act ...

  3. 体验一下Oracle 11g物理Active Data Guard实时查询(Real-time query)

    以下为[高可用] 课后一则实验日志: --------------------------------------------------------------------------------- ...

  4. oracle查效能,【DataGuard】Oracle 11g物理Active Data Guard实时查询(Real-time query)特性...

    在Oracle 11g以前版本中的的Data Guard物理备用数据库,可以以只读的方式打开数据库,但此时Media Recovery利用日志进行数据同步的过程就停止了,如果物理备用数据库处于恢复的过 ...

  5. oracle active data guard概述

    Oracle Active Data Guard 每个 I.T. 组织都面临在提高服务质量的同时降低成本和复杂性的挑战.要使关键业务事务实现一致的高性能,一个方法就是将附加工作卸载到生产数据库的副本. ...

  6. oracle查效能,Oracle 11g物理Active Data Guard实时查询(Real-time query)特性

    table t (x varchar2(8)); Table created. secooler@ora11g> insert into t values ('Secooler'); 1 row ...

  7. [置顶] Oracle 11.2.0.3.0 Active Data Guard 遇 ORA-10458、ORA-01152、ORA-01110 错误

    今天第一次配 Oracle 11g R2 Active Data Guard,在用 RMAN 创建好 physical standby database 后, 尝试将 standby 以 read o ...

  8. oracle的farsync,Oracle 12c 新特性 Active Data Guard Far Sync

    Active Data Guard Far Sync 概述 Active Data Guard Far Sync 是Oracle 12c 的新功能(也称为Far Sync Standby),Far S ...

  9. Oracle LiveLabs实验:Manage and Monitor Autonomous Database

    概述 本研讨会中的实验将引导您完成开始使用 Oracle 自治数据库的所有步骤. 首先,您将创建一个 Oracle 自治数据库实例. 然后,您将练习使用自治数据库工具和 API 从不同位置以不同格式加 ...

最新文章

  1. dingo php,用laravel dingo/api创建简单的api
  2. 数字三角形W(加强版) codevs 2189
  3. xss漏洞的poc与exp
  4. double类型计算
  5. python相关背景及语言特点
  6. Java基础----JAVA语言的概述和开发环境的搭配
  7. 数据科学家们会被 AutoML 代替吗?
  8. 软件测试——126邮箱网页注册和登陆功能测试
  9. 已经出狱的李一男和即将出狱的王欣,还能赶上这个时代吗?
  10. QGraphicsItem限制拖动方向和位置
  11. Windows 编程基础(四)
  12. integrate函数python_scipy.integrate Pseudo-Voigt函数,积分变为0
  13. USB电路EMC设计标准电路详解
  14. apicloud菜鸟教程_干货教程 | APICloud新手学习心得分享
  15. MAC终端常用命令行(后续继续更新,敬请关注)
  16. C++ 1031 查验身份证
  17. S7-200 SMART PLC接线图
  18. RetinaNet系列1:ResNet和FPN部分总结
  19. 工厂类——java理解
  20. 计算机科学概论第二版胡明课后答案,算法设计与分析(第2版)王红梅胡明习题答案.doc...

热门文章

  1. 采药(c语言贪心算法)
  2. AcWing 692. G巴士计数 差分+前缀和
  3. 世界 IT 公司 20 强企业的敏捷转型实例
  4. 攻防世界 Reverse进阶区 BABYRE WP
  5. Check failed: top_shape[j] == bottom[i]-shape(j) (1 vs. 2) All inputs must have the same shape, exc
  6. m3u8链接加密源码
  7. 【金融财经】金融市场一周简报(2017-11-03)
  8. 将文件转存到钉钉的钉盘中
  9. teamspeak搭建_教你快速便捷的搭建Teamspeak 3 服务器和基友开黑必备!
  10. oracle 00600 kccpb,ora-00600 [kccpb_sanity_check_2] 错误处理