Oracle Livelabs实验: Setting Up Active Data Guard For On-Premises
本文是Oracle LiveLabs實驗:Setting Up Active Data Guard For On-Premises 的過程記錄。
實驗步驟請參考這里。
因為是利用你自己的OCI云環(huán)境搭建,因此實驗沒有終止時間。
首先創(chuàng)建2個虛擬機primary和standby,primary上創(chuàng)建數(shù)據(jù)庫,standby上僅安裝數(shù)據(jù)庫軟件。
這兩個環(huán)境是利用OCI創(chuàng)建的,使用了Oracle應(yīng)用市場上的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靜態(tài)安裝方式,可參考這里。
standby上沒有建庫,因此很快就緒。
主數(shù)據(jù)庫服務(wù)器配置
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)確認(rèn)數(shù)據(jù)庫已啟動:
[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創(chuàng)建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修改初始化參數(shù):
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參見這里 , 此處設(shè)為300秒。
主備數(shù)據(jù)庫服務(wù)器均開啟1521端口:
sudo firewall-cmd --zone=public --add-port=1521/tcp --permanent sudo firewall-cmd --reload sudo firewall-cmd --list-allVCN上已經(jīng)開啟1521端口,因此此處無需設(shè)置。
查詢主備數(shù)據(jù)庫服務(wù)器的IP地址和主機名:
# 主數(shù)據(jù)庫服務(wù)器 [opc@primary ~]$ hostname -A primary.subnet1.primaryvcn.oraclevcn.com [opc@primary ~]$ hostname primary [opc@primary ~]$ hostname -I 10.0.1.185# 備數(shù)據(jù)庫服務(wù)器 [opc@standby ~]$ hostname -A standby.subnet1.standbyvcn.oraclevcn.com [opc@standby ~]$ hostname standby [opc@standby ~]$ hostname -I 10.0.1.205然后將以下內(nèi)容添加到主備服務(wù)器的/etc/hosts文件:
10.0.1.185 primary primary.subnet1.primaryvcn.oraclevcn.com 10.0.1.205 standby standby.subnet1.standbyvcn.oraclevcn.com備數(shù)據(jù)庫服務(wù)器配置
在~oracle/.bash_profile中添加以下內(nèi)容:
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啟動監(jiān)聽:
$ lsnrctl start配置static listener,理由參見MOS 1387859.1 。在文件$ORACLE_HOME/network/admin/listener.ora中添加以下內(nèi)容:
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)))重啟監(jiān)聽:
$ lsnrctl reload在主數(shù)據(jù)庫服務(wù)器上的tnsnames.ora文件中添加以下內(nèi)容:
# $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)))在備數(shù)據(jù)庫服務(wù)器上的tnsnames.ora文件中添加以下內(nèi)容:
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)))在備數(shù)據(jù)庫服務(wù)器,以oracle用戶創(chuàng)建以下目錄:
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在備數(shù)據(jù)庫服務(wù)器,新建文件/u01/app/oracle/product/19c/dbhome_1/dbs/initORCLSTBY.ora,并添加以下內(nèi)容:
DB_NAME=ORCL DB_UNIQUE_NAME=ORCLSTBY在備數(shù)據(jù)庫服務(wù)器上,拷貝主數(shù)據(jù)庫服務(wù)器上的口令文件:
$ scp primary:/u01/app/oracle/product/19c/dbhome_1/dbs/orapwORCL $ORACLE_HOME/dbs/在備數(shù)據(jù)庫服務(wù)器上,啟動數(shù)據(jù)庫到nomount狀態(tài):
$ 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,從主庫復(fù)制數(shù)據(jù)庫:
$ 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在主備數(shù)據(jù)庫均運行以下命令:
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)測試配置,在主庫創(chuàng)建用戶:
[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從主數(shù)據(jù)庫服務(wù)器下載測試腳本:
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執(zhí)行 switchover,在主備數(shù)據(jù)庫服務(wù)器均可:
$ 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)主數(shù)據(jù)庫服務(wù)器變?yōu)閟tandby:
[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備數(shù)據(jù)庫服務(wù)器變?yōu)閜rimary:
[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前面已經(jīng)打開了,但備庫還沒有。因此需要打開
[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執(zhí)行 failover,在主備數(shù)據(jù)庫服務(wù)器均可:
$ 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)待改進之處
此實驗數(shù)據(jù)庫主機使用的是公網(wǎng)地址,而且源和目標(biāo)數(shù)據(jù)庫服務(wù)器均在不同VCN,且CIDR相同,導(dǎo)致也沒法做Local Peering,因此建議改為私網(wǎng)地址。
總結(jié)
以上是生活随笔為你收集整理的Oracle Livelabs实验: Setting Up Active Data Guard For On-Premises的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Qt编写可视化大屏电子看板系统16-标准
- 下一篇: python123子字符串输出_【无为则