Wednesday, February 3, 2021

Oracle Data Guard Broker set up, ORA-12514, ORA-16713, Insufficient SRLs, etc.,

 We have seen how to set up or create an Oracle physical standby database in this post. As a continuation, we will look into how to set up a Data Guard Broker to manage the primary and standby databases. Data Guard Broker provides many advantages such as 

  • enabling configure and manage multiple databases from single location and automatically unifies all DBs in broker configuration, 
  • automatically setting up redo transport services and log apply services, 
  • simplifying switchover and failover, integrating role changes with Oracle clusterware, etc., 
All of the details and advantages can be found in the Oracle Data Guard Broker concepts guide here.

In this post we will look into configuring the Oracle Data Guard Broker and general issues we will encounter during the set up with their work arounds/ fixes. 

Step 1: Preserve current pfile or spfile

As we will be altering/adding a few parameters, it is always a best practice to backup the original pfile/spfile before changing the contents. 

SQL> create pfile='/oracle/ABC/19.0.0/dbs/init_ABC.ora_b4DGBroker' from spfile;

File created.
SQL> 

Step 2
: Starting Data Guard Broker DMON process
  • During physical standby set up we would have set log_archive_dest_2 parameter. We need to clear this parameter where Broker will automatically takes care of this parameter. 
  • If you do not reset the parameter, you will encounter the below error when performing the Create configuration command. 
            Error: ORA-16698: LOG_ARCHIVE_DEST_n parameter set for object to be added
  • We can alter the location of the broker configuration files as needed using dg_broker_config_file1 and dg_broker_config_file2 parameters
  • dg_broker_start should be set to true to let the broker DMON process start automatically when the instance starts up
SQL> ALTER SYSTEM SET dg_broker_config_file1 = '+DATA/ABC1/broker1.dat' scope=both;

System altered.

SQL> ALTER SYSTEM SET dg_broker_config_file2 = '+RECO/ABC1/broker2.dat' scope=both;

System altered.

SQL> alter system reset log_Archive_dest_2 scope=both;

System altered.

SQL> alter system set dg_broker_start=true scope=both;

System altered.

SQL> 

SQL> ALTER SYSTEM SET dg_broker_config_file1 = '+DATA/ABC_STANDBY/broker1.dat' scope=both;

System altered.

SQL> ALTER SYSTEM SET dg_broker_config_file2 = '+RECO/ABC_STANDBY/broker2.dat' scope=both;

System altered.

SQL> alter system reset log_Archive_dest_2 scope=both;

System altered.

SQL> alter system set dg_broker_start=true scope=both;

System altered.

SQL> 
Step 3: Create configuration

Connect to dgmgrl and create configuration as shown below.
-sh-4.2$ dgmgrl
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Thu Jan 21 23:40:44 2021
Version 19.8.0.0.0

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

Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys
Password:
Connected to "ABC1"
Connected as SYSDBA.

DGMGRL> CREATE CONFIGURATION 'ABC_DGD' AS PRIMARY DATABASE IS 'ABC1' CONNECT IDENTIFIER IS ABC1;
Configuration "ABC_DGD" created with primary database "ABC1"
DGMGRL> show configuration;

Configuration - ABC_DGD

  Protection Mode: MaxPerformance
  Members:
  ABC1 - Primary database

Fast-Start Failover:  Disabled

Configuration Status:
DISABLED

DGMGRL> 
Step 4: Add Standby database
DGMGRL> add database ABC_STANDBY as connect identifier is ABC_STANDBY;
Database "ABC_standby" added
DGMGRL> show configuration;

Configuration - ABC_DGD

  Protection Mode: MaxPerformance
  Members:
  ABC1        - Primary database
    ABC_standby - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
DISABLED

DGMGRL> 
Now you can see the standby database is added but the status is showing as DISABLED

Step 5: Enable configuration
DGMGRL> enable configuration;
Enabled.

DGMGRL> show configuration;

Configuration - ABC_DGD

  Protection Mode: MaxPerformance
  Members:
  ABC1        - Primary database
    ABC_standby - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 8 seconds ago)

DGMGRL> show database ABC1;

Database - ABC1

  Role:               PRIMARY
  Intended State:     TRANSPORT-ON
  Instance(s):
    ABC

Database Status:
SUCCESS

DGMGRL> show database ABC_STANDBY;

Database - ABC_standby

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 0 seconds ago)
  Apply Lag:          1 second (computed 0 seconds ago)
  Average Apply Rate: 66.78 MByte/s
  Real Time Query:    OFF
  Instance(s):
    ABC

Database Status:
SUCCESS

DGMGRL> 
We can see the Configuration status is now showing as SUCCESS. 
Line 18 and 30 provides the properties of both Primary and Standby database where the status of both the database is SUCCESS

Step 6: Validate the databases

We can now validate the configuration in which the actual connectivity testing along with a comprehensive set of database checks are being performed. We need to make sure validate database works without any issue for the conversion to take place if intended to. 
DGMGRL> validate database verbose ABC1;

  Database Role:    Primary database

  Ready for Switchover:  Yes

  Flashback Database Status:
    ABC1:  Off

  Capacity Information:
    Database  Instances        Threads
    ABC1      1                1

  Managed by Clusterware:
    ABC1:  NO
    Validating static connect identifier for the primary database ABC1...
Unable to connect to database using (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hic023124.dc.honeywell.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ABC1_DGMGRL)(INSTANCE_NAME=ABC)(SERVER=DEDICATED)(STATIC_SERVICE=TRUE)))
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor Failed.
    Warning: Ensure primary database's StaticConnectIdentifier property
    is configured properly so that the primary database can be restarted
    by DGMGRL after switchover

  Temporary Tablespace File Information:
    ABC1 TEMP Files:  31

  Data file Online Move in Progress:
    ABC1:  No

  Transport-Related Information:
    Transport On:  Yes

  Log Files Cleared:
    ABC1 Standby Redo Log Files:  Cleared

DGMGRL> 
We can see that the validate database is throwing connection error w.r.to connect identifier even though we have properly set up tnsnames and is working fine. The reason being broker adds the static entry in broker configuration as SID_DGMGRL where as the GLOBAL_NAME in listener will be SID which causes the mismatch. Refer Oracle support note Doc ID 1582927.1 for details.
The fix is to set the StaticConnectIdentifier configuration property properly as below 
DGMGRL> edit database ABC1 set property StaticConnectIdentifier='ABC1';
Property "staticconnectidentifier" updated

DGMGRL> edit database ABC_STANDBY set property StaticConnectIdentifier='ABC_STANDBY';                                                                     
Property "staticconnectidentifier" updated

DGMGRL> 
Next we will validate the standby database similar to the above we did for primary database. 
DGMGRL> validate database verbose ABC_STANDBY;
Error: ORA-16713: The Oracle Data Guard broker command timed out.

DGMGRL> 
Now we have a different issue when validating the standby database. Referring Support note Doc ID 1322877.1 and Doc ID 2300040.1 we can extend the Operationtimeout parameter of the broker configuration. The ADR can also be cleaned up prior to running validate database if the database is too huge.
DGMGRL> show configuration OperationTimeout;
  OperationTimeout = '30'
DGMGRL> validate database verbose ABC_STANDBY;
Error: ORA-16713: The Oracle Data Guard broker command timed out.
DGMGRL> EDIT CONFIGURATION SET PROPERTY OperationTimeout=600;
Property "operationtimeout" updated
DGMGRL> validate database verbose ABC_STANDBY;

  Database Role:     Physical standby database
  Primary Database:  ABC1

  Ready for Switchover:  Yes
  Ready for Failover:    Yes (Primary Running)

  Flashback Database Status:
    ABC1       :  Off
    ABC_standby:  Off

  Capacity Information:
    Database     Instances        Threads
    ABC1         1                1
    ABC_standby  1                1

  Managed by Clusterware:
    ABC1       :  NO
    ABC_standby:  NO
    Validating static connect identifier for the primary database ABC1...
    The static connect identifier allows for a connection to database "ABC1".

  Temporary Tablespace File Information:
    ABC1 TEMP Files:         31
    ABC_standby TEMP Files:  30

  Data file Online Move in Progress:
    ABC1:         No
    ABC_standby:  No

  Standby Apply-Related Information:
    Apply State:      Running
    Apply Lag:        0 seconds (computed 0 seconds ago)
    Apply Delay:      0 minutes

  Transport-Related Information:
    Transport On:  Yes
    Gap Status:    No Gap
    Transport Lag:  0 seconds (computed 0 seconds ago)
    Transport Status:  Success

  Log Files Cleared:
    ABC1 Standby Redo Log Files:         Cleared
    ABC_standby Online Redo Log Files:   Cleared
    ABC_standby Standby Redo Log Files:  Available

  Current Log File Groups Configuration:
    Thread #  Online Redo Log Groups  Standby Redo Log Groups Status
              (ABC1)                  (ABC_standby)
    1         8                       9                       Sufficient SRLs

  Future Log File Groups Configuration:
    Thread #  Online Redo Log Groups  Standby Redo Log Groups Status
              (ABC_standby)           (ABC1)
    1         8                       4                       Insufficient SRLs

  Current Configuration Log File Sizes:
    Thread #   Smallest Online Redo      Smallest Standby Redo
               Log File Size             Log File Size
               (ABC1)                    (ABC_standby)
    1          3136 MBytes               3136 MBytes

  Future Configuration Log File Sizes:
    Thread #   Smallest Online Redo      Smallest Standby Redo
               Log File Size             Log File Size
               (ABC_standby)             (ABC1)
    1          3136 MBytes               3136 MBytes

  Apply-Related Property Settings:
    Property                        ABC1 Value               ABC_standby Value
    DelayMins                       0                        0
    ApplyParallel                   AUTO                     AUTO
    ApplyInstances                  0                        0

  Transport-Related Property Settings:
    Property                        ABC1 Value               ABC_standby Value
    LogShipping                     ON                       ON
    LogXptMode                      ASYNC                    ASYNC
    Dependency                      <empty>                  <empty>
    DelayMins                       0                        0
    Binding                         optional                 optional
    MaxFailure                      0                        0
    ReopenSecs                      300                      300
    NetTimeout                      30                       30
    RedoCompression                 DISABLE                  DISABLE

DGMGRL> 
The command now executed successfully without any issues after configuration change. 
We can see in line 62, broker is reporting insufficient Standby Redo Logs. This is because when the SRLs were added the thread number is not specified in the command. We can drop and recreate the SRLs for which the thread number is not correct to overcome this issue. Refer support note Doc ID 1956103.1 for more details
SQL> select thread#,group#,bytes,status from v$standby_log;

   THREAD#     GROUP#      BYTES STATUS
---------- ---------- ---------- ----------
         1         11 4.1943E+10 UNASSIGNED
         1         12 4.1943E+10 UNASSIGNED
         1         13 4.1943E+10 UNASSIGNED
         1         14 4.1943E+10 UNASSIGNED
         0         15 4.1943E+10 UNASSIGNED
         0         16 4.1943E+10 UNASSIGNED
         0         17 4.1943E+10 UNASSIGNED
         0         18 4.1943E+10 UNASSIGNED
         0         19 4.1943E+10 UNASSIGNED

9 rows selected.

SQL> alter database drop logfile group 15;

Database altered.

SQL> alter database add standby logfile thread 1 group 15 size 40000m;

Database altered.

/* Drop and recreate other groups as well
--alter database drop logfile group 16;
--alter database drop logfile group 17;
--alter database drop logfile group 18;
--alter database drop logfile group 19;

--alter database add standby logfile thread 1 group 16 size 40000m;
--alter database add standby logfile thread 1 group 17 size 40000m;
--alter database add standby logfile thread 1 group 18 size 40000m;
--alter database add standby logfile thread 1 group 19 size 40000m;
*/

SQL> select thread#,group#,bytes/1024/1024, status from v$standby_log;

   THREAD#     GROUP# BYTES/1024/1024 STATUS
---------- ---------- --------------- ----------
         1         11           40000 UNASSIGNED
         1         12           40000 UNASSIGNED
         1         13           40000 UNASSIGNED
         1         14           40000 UNASSIGNED
         1         15           40000 UNASSIGNED
         1         16           40000 UNASSIGNED
         1         17           40000 UNASSIGNED
         1         18           40000 UNASSIGNED
         1         19           40000 UNASSIGNED

9 rows selected.

SQL> 
You can now see that all the SRLs are with proper thread number assigned. Let's check the validate database command for the standby database again. 
DGMGRL> validate database verbose ABC_STANDBY;

  Database Role:     Physical standby database
  Primary Database:  ABC1

  Ready for Switchover:  Yes
  Ready for Failover:    Yes (Primary Running)

  Flashback Database Status:
    ABC1       :  Off
    ABC_standby:  Off

  Capacity Information:
    Database     Instances        Threads
    ABC1         1                1
    ABC_standby  1                1

  Managed by Clusterware:
    ABC1       :  NO
    ABC_standby:  YES
    Validating static connect identifier for the primary database ABC1...
    The static connect identifier allows for a connection to database "ABC1".

  Temporary Tablespace File Information:
    ABC1 TEMP Files:         31
    ABC_standby TEMP Files:  30

  Data file Online Move in Progress:
    ABC1:         No
    ABC_standby:  No

  Standby Apply-Related Information:
    Apply State:      Running
    Apply Lag:        1 second (computed 0 seconds ago)
    Apply Delay:      0 minutes

  Transport-Related Information:
    Transport On:  Yes
    Gap Status:    No Gap
    Transport Lag:  0 seconds (computed 0 seconds ago)
    Transport Status:  Success

  Log Files Cleared:
    ABC1 Standby Redo Log Files:         Cleared
    ABC_standby Online Redo Log Files:   Cleared
    ABC_standby Standby Redo Log Files:  Available

  Current Log File Groups Configuration:
    Thread #  Online Redo Log Groups  Standby Redo Log Groups Status
              (ABC1)                  (ABC_standby)
    1         8                       9                       Sufficient SRLs

  Future Log File Groups Configuration:
    Thread #  Online Redo Log Groups  Standby Redo Log Groups Status
              (ABC_standby)           (ABC1)
    1         8                       9                       Sufficient SRLs

  Current Configuration Log File Sizes:
    Thread #   Smallest Online Redo      Smallest Standby Redo
               Log File Size             Log File Size
               (ABC1)                    (ABC_standby)
    1          3136 MBytes               3136 MBytes

  Future Configuration Log File Sizes:
    Thread #   Smallest Online Redo      Smallest Standby Redo
               Log File Size             Log File Size
               (ABC_standby)             (ABC1)
    1          3136 MBytes               3136 MBytes

  Apply-Related Property Settings:
    Property                        ABC1 Value               ABC_standby Value
    DelayMins                       0                        0
    ApplyParallel                   AUTO                     AUTO
    ApplyInstances                  0                        0

  Transport-Related Property Settings:
    Property                        ABC1 Value               ABC_standby Value
    LogShipping                     ON                       ON
    LogXptMode                      ASYNC                    ASYNC
    Dependency                      <empty>                  <empty>
    DelayMins                       0                        0
    Binding                         optional                 optional
    MaxFailure                      0                        0
    ReopenSecs                      300                      300
    NetTimeout                      30                       30
    RedoCompression                 DISABLE                  DISABLE

DGMGRL> exit
-sh-4.2$
Everything is set up properly now. We are ready to rock and roll standby management using Oracle Data Guard Broker and the system is ready for switchover and failover operations if needed. 

References: 

Happy Brokering!!! 

Wednesday, January 20, 2021

DNS server using BIND9 for Home Lab

Happy New Year to all my readers. This is my first post of this year and I've started my year by building a RAC environment for the lab. 

Most of us who wants to learn building Oracle RAC and its operations use Oracle VirtualBox as the virtualization software as it is free to use. You can also take a look at Workstation Pro which is a very powerful virtualization product (requires license and 60 day trail available) from VMware which is used in many companies as well or their free to use software Workstation Player which is similar to Workstation Pro with a few limitations. 

One main requirement of building the RAC environment (For Oracle database versions 11gR2 or higher) is the availability of a DNS server or Oracle GNS which is used to resolve SCAN name minimum 1 up to 3 or more IP addresses (generally an odd number due high availability requirements) in a round robin fashion. 

Most of the beginners use Windows OS to work on the practices until they get familiar with other OS such as Unix/Linux and hence we in this post look at how can we configure the host Windows OS to server as the DNS server for the Guest OS running on the virtualization software.

Software Installation: 

We will use BIND 9 to create our DNS server on the Windows host. Download the latest version of BIND 9 from the download page and then extract the contents into a folder. I'm using 7zip software to extract and you can use any software as you wish


Once the contents are extracted, go the extracted files folder and start BINDInstall.exe as Run as Administrator


Set the Target Directory, provide service account password and confirm and click on Install. 


The Target Directory provided is the software location or the BIND9 path. Once the installation is complete, click OK and exit the installer. 

Configuration: 

The software is installed just a few clicks. Now let us look into the configuration part. In this post we will configure a very basic DNS server config and you may have to look into the documentation of the particular software version that you have downloaded if you like to configure a sophisticated setup. 

Once the software is installed, you will be able to see bin directory and etc directory under the software installation path, C:\Program Files\BIND9 in my case. We will have to create the named.conf file under etc directory. named.conf is the name server configuration file containing collection of statements using nested options surrounded by opening and closing ellipse characters, { }. 

Sample reference file of my host's named.conf configuration looks like the below

// Listen only on this machine i.e localhost or from 192.168.56.1
options {
  listen-on port 53 { 127.0.0.1; 192.168.56.1; }; 
  directory "C:\Program Files\BIND9\zones";
  allow-transfer { none; };
  recursion no;
  forwarders { 194.168.43.1; };
};

zone "selvapc.com." IN {
  type master;
  file "selvapc.com.zone";
  allow-transfer { none; };
};

zone "56.168.192.in-addr.arpa." IN {
  type master;
  file "56.168.192.in-addr.arpa";
  allow-update { none; };
};
Explanation of the above: 
Line 1: Starts with // is a comment line
Line 3: DNS server is listening only on port 53 and from local host or 192.168.56.1. This ip is the default VirtualBox Host only adapter ip address which is used by the guest OS to communicate with Windows host. You can also mention 192.168.0.0/24 to listen on all ranges of ip in 192.168

Line 4: It is the named working directory
Line 5: Specifies which hosts are allowed to receive zone transfers from the server
Line 6: Prevents new data from being cached as an effect of client queries
Line 7: Specifies a list of IP addresses to which queries are forwarded. We have only limited our DNS to have a specific IP address used for SCAN. If any other name is queried, it will be forwarded to this set of IPs specified. I have provided the host machines DNS server IP provided by ISP which will communicate with internet to resolve names. You can obtain this by checking ipconfig /all in command prompt. Note: This is not the public DNS address from my ISP. You can also provide cloudfare's (1.1.1.1) or Google's (8.8.8.8) DNS as well to query internet if required.

Line 10: Zone statement for selvapc.com zone. If you don't have a domain name defined, you can use localdomain instead of selvapc.com
Line 11 to 13: Zone statement type is master and is instructed to read selvapc.com.zone file which will be present in zones directory under software directory path. Other hosts can't update this file
Line 16: This file will be used to do the reverse lookup. This is optional as RAC will need only the forward lookup to resolve the IP address defined under SCAN name. DNS queries issued under 192.168.56.* will be reverse resolved
Line 17 to 19: type is master, instructed to read 56.168.192.in-addr.arpa in zones directory under software directory path. Other hosts can't update this file

Now as we have defined the named.conf file, we need to create the zones file. Create a directory by name zones under software directory path, C:\Program Files\BIND9\zones in my case. 

The 2 files will look like below. 
$TTL    86400
@               IN SOA  localhost root.localhost (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                IN NS           localhost
localhost       	 IN A            127.0.0.1
12r1-rac1            IN A    192.168.56.101
12r1-rac2            IN A    192.168.56.102
12r1-rac1-priv       IN A    192.168.1.101
12r1-rac2-priv       IN A    192.168.1.102
12r1-rac1-vip        IN A    192.168.56.103
12r1-rac2-vip        IN A    192.168.56.104
scan-12r1        	 IN A    192.168.56.105
scan-12r1        	 IN A    192.168.56.106
scan-12r1        	 IN A    192.168.56.107
You can see here all these IPs can be resolved to their respective names. SCAN name has 3 IPs configured which will resolve in round robin fashion. 
$ORIGIN 56.168.192.in-addr.arpa.
$TTL 1H
@       IN      SOA     selvapc.com.     root.selvapc.com. (      2
                                                3H
                                                1H
                                                1W
                                                1H )
56.168.192.in-addr.arpa.         IN NS      selvapc.com.

101     IN PTR  12r1-rac1.selvapc.com.
102     IN PTR  12r1-rac2.selvapc.com.
103     IN PTR  12r1-rac1-vip.selvapc.com.
104     IN PTR  12r1-rac2-vip.selvapc.com.
105     IN PTR  scan-12r1.selvapc.com.
106     IN PTR  scan-12r1.selvapc.com.
107     IN PTR  scan-12r1.selvapc.com.
Note, the trailing '.' is very important at all the places, else the configuration won't work as expected.

Now the configuration part is completed. We have 1 more step remaining which is adjusting the firewall rule to allow TCP and UDP to port 53. This can be done by following the step below. 
  • Go to Control Panel >> System and Security >> Windows Defender Firewall >> Click Advanced Settings
  • Click Inbound Rules >> New Rule >> Protocol and Ports (Port) >> Next >> TCP >> Specific local ports (53) >> Next >> Allow the connection >> Next >> Check all the check boxes >> Next >> Specify a name for the rule Eg: TCP53 >> Finish
  • Click Inbound Rules >> New Rule >> Protocol and Ports (Port) >> Next >> UDP >> Specific local ports (53) >> Next >> Allow the connection >> Next >> Check all the check boxes >> Next >> Specify a name for the rule Eg: UDP53 >> Finish
We are now on to our final step of the configuration is start or restart of the ISC BIND service under windows. 
  • Windows+R >> Type "services.msc" >> Click OK
  • Search for ISC BIND service. Click Start if it is not running or Restart if it is already running

We have successfully completed the set up of DNS server on our Windows host machine. 

Verification: 

We now have to verify if the setup works as expected. Issue the nslookup command as below. 

We can now see that the SCAN name is able to resolve to 3 IP addresses. As we want this name resolution to happen in the local host or 192.168.56.1 (which serves as the IP address for the host OS in VirtualBox), we pass the third argument as localhost or 192.168.56.1. 

If you install Linux guest OS, the /etc/resolv.conf file should contain 192.168.56.1 as nameserver defined which will then resolve the SCAN name without any issues. Here is an example content and o/p from my lab environment. 
[oracle@12r1-rac1 ~]$
[oracle@12r1-rac1 ~]$ uname -a
Linux 12r1-rac1.selvapc.com 3.8.13-98.4.1.el6uek.x86_64 #2 SMP Wed Sep 23 18:46:01 PDT 2015 x86_64 x86_64 x86_64 GNU/Linux
[oracle@12r1-rac1 ~]$ cat /etc/resolv.conf
# Generated by NetworkManager
search localdomain selvapc.com
nameserver 192.168.56.1
[oracle@12r1-rac1 ~]$ nslookup scan-12r1
Server:         192.168.56.1
Address:        192.168.56.1#53

Name:   scan-12r1.selvapc.com
Address: 192.168.56.107
Name:   scan-12r1.selvapc.com
Address: 192.168.56.106
Name:   scan-12r1.selvapc.com
Address: 192.168.56.105

[oracle@12r1-rac1 ~]$ nslookup 192.168.56.106
Server:         192.168.56.1
Address:        192.168.56.1#53

106.56.168.192.in-addr.arpa     name = 12r1-scan.selvapc.com.

[oracle@12r1-rac1 ~]$

All is good now and we can start building our Oracle RAC databases.. 

References: 
Happy BINDing...!!!