Practice 6 Monitoring Data Guard Configuration
Practice 6 Monitoring Data Guard Configuration
Purpose In this practice we will demonstrate how to use the tools to monitor a Data
Guard configuration.
SQL Developer
SQL Developer will be used to run the SQL commands in this practice. It can
be downloaded from the following link:
http://www.oracle.com/technetwork/developer-tools/sql-
developer/overview/index.html
VirtualBox Appliance
The practice has been implemented on an Oracle virtual appliances that have
been in practice number 3. We named that practice “Practice 3 Configure the
Broker”.
Simulate sample work load on the primary database. You will create the scripts
that will be used to apply simple DML load operations on the Data Guard
configuration.
Use the monitoring tools that you learnt about in the lecture.
Simulate an outage of the apply process in the standby database and study how
the output of our tools will be different.
Practice Procedure
1. In VirtualBox open the two appliances in the folder “Practice 3 Configure the Broker”
2. Start the appliances then start the databases and make sure they are available.
connect hr/oracle@oradb
5. We will create a package that has two procedures. One will insert some random testing data into
the NAMES table and one will apply random DML (INSERT, UPDATE, or DELETE) operations
against the NAMES table.
Note: You can download the script files from the lecture resources.
/* Create Random Load Package */
CREATE OR REPLACE PACKAGE LOAD_GENERATOR
IS
-- insert random rows in NAMES table
PROCEDURE INSERT_NAMES ( P_ROWS IN NUMBER);
-- random DML on NAMES
PROCEDURE RandomDML(P_ITERATION IN NUMBER, P_MAX IN NUMBER);
END load_generator;
/
TRUNC(SYSDATE-DBMS_RANDOM.VALUE(60,1800)), -- HDATE
ROUND(DBMS_RANDOM.VALUE(1000,55000)), -- SAL
DECODE( TO_CHAR(ROUND(DBMS_RANDOM.VALUE(1,4))), '1','N','2','W','3','E','4','S') );
-- REGION
IF MOD(I,100) = 0 THEN
COMMIT;
END IF;
END LOOP;
COMMIT;
END INSERT_NAMES;
6. Use the INSERT_NAMES procedure to insert some sample data into the NAMES table.
-- load 10000 rows in names table
execute load_generator.insert_names(10000);
mkdir scripts
cd scripts
vi loaddml.sql
begin
hr.LOAD_GENERATOR.RANDOMDML (&1, &2);
end;
/
8. Create loaddml.sh shell script as follows. This script accepts three arguments, number of
connections, number of iterations, and number for rows.
vi loaddml.sh
chmod +x loaddml.sh
#!/bin/bash
# apply random DML load on Oracle DB
# parameters: 1 connections, 2 Iterations, 3 rows in names
users=$1
SRVC="oradb"
UNPW="hr/oracle"
SQLCMD="/home/oracle/scripts/loaddml.sql"
x=1
y=$users
ITER=$2
MAX=$3
while [ $x -le $y ]
do
sqlplus -s $UNPW@$SRVC @$SQLCMD $ITER $MAX &
x=`expr $x + 1`
done
We will use SQL Developer to run the SQL commands that will be used to monitor our Data Guard
configuration.
10. Launch SQL Developer and make two connections. One to the primary database and one to the
standby database.
Note: if you want to make the editor font bigger, go to Tools menu -> User Preferances
11. Display the Data Guard related messages in the alert log file. Run the following script and
observe the output.
Tip: you can [Ctl]+[Enter] to run the statement on which the cursor is on.
ALTER SESSION SET NLS_DATE_FORMAT='DD-Mon-RR HH12:MI AM';
ALTER SESSION SET NLS_DATE_LANGUAGE=AMERICAN;
12. Check if there is any redo log gap. This should be run from the standby database.
SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE#
FROM V$ARCHIVE_GAP;
13. The following script is another way to check if there is any redo log gap, from the primary
database:
SELECT MAX(SEQUENCE#), THREAD#
FROM V$ARCHIVED_LOG
WHERE RESETLOGS_CHANGE# = (SELECT MAX(RESETLOGS_CHANGE#) FROM V$ARCHIVED_LOG)
GROUP BY THREAD#;
14. In the standby database, examine the transport and apply lag statistics. Run the following
script:
ALTER SESSION SET NLS_DATE_FORMAT='DD-Mon-RR HH12:MI AM';
ALTER SESSION SET NLS_DATE_LANGUAGE=AMERICAN;
15. Simulate an outage in the apply process. Do that by simply stopping the process in the dgmgrl.
You can do that in the standby putty session window.
dgmgrl sys/oracle@oradb
edit database oradb_s2 set state=apply-off;
17. In the standby database, examine again the apply lag statistics.
18. In the dgmgrl command prompt, issue the following command and observe the statistics:
SHOW DATABASE oradb_s2
20. In the standby database, examine again the apply lag statistics.
21. Obtain the active apply rate. Run the following command in the standby database:
SELECT START_TIME , ITEM, SOFAR || ' ' || UNITS Sofar
FROM V$RECOVERY_PROGRESS
WHERE ITEM IN ('Active Apply Rate', 'Average Apply Rate', 'Redo Applied');
22. In the dgmgrl command prompt, issue the following command and observe the statistics:
SHOW DATABASE oradb_s2
23. Using the Broker check if any archived redo log has not been sent to the standby database.
Note: I had to increase the width of the Putty window to maximum to properly observe the output.
If the STATUS column is ARCHIVED, this means the archived redo log file has not been sent to the
standby database. If it is CURRENT, it means the current online redo log file is being read and therefore
all the archived redo log files have been sent.
SHOW DATABASE oradb SendQEntries
24. Check if there is any archive log file received by the standby database but not applied:
SHOW DATABASE oradb_s2 RECVQENTRIES
25. In the standby database, list the processes that are running as part of the Data Guard
configuration and check out their operations:
SELECT PID, PROCESS, STATUS, CLIENT_PROCESS, CLIENT_PID, THREAD#, SEQUENCE# SEQ#, BLOCK#,
BLOCKS
FROM V$MANAGED_STANDBY
ORDER BY PROCESS;
Notes
Note: if there is a file that has not been transported yet to the standby database, the file will not be
deleted and you will receive a warning message.