Archive

Archive for March, 2013

Configuring DNS server

March 25, 2013 Leave a comment

1. Installed required libraries for setting up DNS server. Check the link public-yum.oracle.com for configuring yum server

# yum install bind-libs bind bind-utils

If DNS gui editor is required install the following package

# yum install system-config-bind

 

2. Do the following to setup DNS properly

a) edit /etc/named.conf file

Domain name for my server is localdomain and ip address in 10.0.0.31. Also make sure port 53 is open. Add a forwarder to make sure names are resolved on the external network also. Here i’m using google DNS servers (8.8.8.8,8.8.4.4)

options {
 // Set IP address correctly.
 listen-on port 53 { 127.0.0.1; 10.0.0.31; };
//
 // Leave the rest of the config as it is.
 //
// My Additions
 // Forwarder: Anything this DNS can't resolve gets forwarded to my ISPs DNS.
 forwarders { 8.8.8.8;8.8.4.4; };
 // End My Additions
 directory "/var/named/";
};

I’m using localdomain as my domain name, so i need to add a zone for it

zone "localdomain." IN {
 type master;
 file "localdomain.zone";
 allow-update { none; };
};

file parameter above refers to a file in /var/named directory that contains configuration of this zone

The above configuration is enabled only forward lookup, If we want reverse lookup also add below lines also to /etc/named.conf file

zone "0.0.10.in-addr.arpa." IN {
 type master;
 file "0.0.10.in-addr.arpa";
 allow-update { none; };
 };

 

b) Create the zone file and reverse zone file in /var/named directory.

If you are using the “chroot” version of BIND, the location of the following files will be /var/named/chroot/var/named”

$ cd /var/named

Create localdomain.zone file and add the below entries

$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
rac1               IN A   10.0.0.31
rac2               IN A   10.0.0.32
rac1-priv          IN A   10.0.0.33
rac2-priv          IN A   10.0.0.34
rac1-vip           IN A   10.0.0.35
rac2-vip           IN A   10.0.0.36
rac-scan           IN A   10.0.0.37
rac-scan           IN A   10.0.0.38
rac-scan           IN A   10.0.0.39

Now create 0.0.10.in-addr.arpa file and add the below entries

$ORIGIN 0.0.10.in-addr.arpa.
$TTL 1H
@                  IN SOA rac1.localdomain. root.rac1.localdomain. ( 2
                                              3H
                                              1H
                                              1W
                                              1H )
0.0.10.in-addr.arpa. IN  NS         rac1.localdomain.
31                   IN PTR         rac1.localdomain.
32                   IN PTR         rac2.localdomain.
33                   IN PTR         rac1-priv.localdomain.
34                   IN PTR         rac2-priv.localdomain.
35                   IN PTR         rac1-vip.localdomain.
36                   IN PTR         rac2-vip.localdomain.
37                   IN PTR         rac-scan.localdomain.
38                   IN PTR         rac-scan.localdomain.
39                   IN PTR         rac-scan.localdomain.

Make sure zones files are owned by root and group is named

lrwxrwxrwx 1 root named 44 Dec 11 11:34 localdomain.zone -> 
                                 /var/named/chroot/var/named/localdomain.zone
lrwxrwxrwx 1 root named 47 Dec 11 11:34 0.0.10.in-addr.arpa -> 
                                 /var/named/chroot/var/named/0.0.10.in-addr.arpa

 

3. Start the DNS service’

# service named start
Starting named:                                            [  OK  ]

Issue the following command to make sure the “named” service starts automatically after reboots.

# chkconfig named on

 

4. Add below entries to /etc/resolv.conf  –>  tells a Linux machine which DNS server to use when attempting to resolve machine names.

search localdomain
nameserver 10.0.0.31

 

5. Testing the DNS setup

[root@rac1 named]# nslookup rac-scan.localdomain
 Server: 10.0.0.31
 Address: 10.0.0.31#53
Name: rac-scan.localdomain
 Address: 10.0.0.39
 Name: rac-scan.localdomain
 Address: 10.0.0.37
 Name: rac-scan.localdomain
 Address: 10.0.0.38
[root@rac1 named]# nslookup 10.0.0.39
 Server: 10.0.0.31
 Address: 10.0.0.31#53
39.0.0.10.in-addr.arpa name = rac-scan.localdomain.
[root@rac1 named]# nslookup 10.0.0.38
 Server: 10.0.0.31
 Address: 10.0.0.31#53
38.0.0.10.in-addr.arpa name = rac-scan.localdomain.
[root@rac1 named]# nslookup 10.0.0.37
 Server: 10.0.0.31
 Address: 10.0.0.31#53
37.0.0.10.in-addr.arpa name = rac-scan.localdomain.
Advertisements
Categories: Miscellaneous Tags: ,

Configuring TNS entries for failover – Standby databases

March 24, 2013 Leave a comment

1. Configure a service name on the primary database

SQL > exec DBMS_SERVICE.CREATE_SERVICE (-
service_name => ' bharat-ha',-
network_name => 'bharat-ha',-
failover_method => 'BASIC',-
failover_type => 'SELECT',-
failover_retries => 180,-
failover_delay => 1);
PL/SQL procedure successfully completed.

or

sql> alter system set service_names='bharat-ha' scope=both;

2. Start the service . Here we are creating a trigger which will start the service once the instance is detected as primary

SQL > CREATE OR REPLACE TRIGGER manage_dgservice
after startup on database
DECLARE
role VARCHAR(30);
BEGIN
SELECT DATABASE_ROLE INTO role FROM V$DATABASE;
IF role = 'PRIMARY' THEN
DBMS_SERVICE.START_SERVICE('fsfo');
END IF;
END;

3. Add the following line to sqlnet.ora at the client side

SQLNET.OUTBOUND_CONNECT_TIMEOUT = 3

Above statement will assure that the failed connections will not wait for TCP timeout but will immediately proceed to the next host if the primary is unavailable

4. Add the below tns entry to tnsnames.ora

bharat-ha =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.31)(PORT = 1533))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.32)(PORT = 1533))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bharat-ha)
)
)

or add below if service_names is set in spfile

bharat-ha =
 (DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.31)(PORT = 1533))
 (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.32)(PORT = 1533))
 (LOAD_BALANCE = yes)
 (CONNECT_DATA =
 (SERVER = DEDICATED)
 (SERVICE_NAME = bharat-ha)
 (FAILOVER_MODE =
 (TYPE = SELECT) # (TYPE = SESSION) 
 (METHOD = BASIC)
 (RETRIES = 180)
 (DELAY = 5)
 )
 )
 )

Testing Failover Connection

1. Connect from a client server using the ‘bharat-ha’ service, check the instance names

SQL> sho parameter unique
NAME            TYPE      VALUE
-------------- --------  -----------
db_unique_name string     bharat_pri

2. From the client server, connected through the ‘bharat-ha’ service start a long running query and check how long it takes to complete

SQL> select 1,2,3 from dba_source
1 2 3
1 2 3
...
...
1 2 3
1 2 3
140829 rows selected.
Elapsed: 00:0:30.12

3. From the client server, connected through the ‘bharat-ha’ service issue again the same long running query, and in another session kill the primary database

SQL> select 1,2,3 from dba_source 
1 2 3
1 2 3
... 
... 

<< db process was killed at this point>>

[oracle@rac1 ~]$ ps -ef | grep pmon
oracle 3120 1 0 16:28 ? 00:00:00 ora_pmon_bharat
oracle 3255 3082 0 16:32 pts/1 00:00:00 grep pmon
[oracle@rac1 ~]$ kill -9 3120

This will trigger a fast start failover. Check the observer log

[W000 03/24 12:53:44.12] Observer started.
13:14:59.76 Sunday, March 24, 2013
Initiating Fast-Start Failover to database "bharat_stby"...
Performing failover NOW, please wait...
Failover succeeded, new primary is "bharat_stby"
13:15:10.77 Sunday, March 24, 2013

At the client screen you will notice that the output from ‘select 1,2,3 from dba_source’ stops and then continues until finished

...
...
 <<<<<< Database process killed here
...
1 2 3
1 2 3
140829 rows selected
Elapsed: 00:01:23.23 <<<<<< the select took longer but finished

4. Check the instance name now

SQL> select instance_name from v$instance;
INSTANCE_NAME
—————-
bharat_stby
Elapsed: 00:00:00.07

 

 

Oracle database internals by Riyaj

Discussions about Oracle performance tuning, RAC, Oracle internal & E-business suite.

StartupForce

Where all the Action Is !!!!

Pavan DBA's Blog

The DBA Knowledge Store

ORACLE-BASE - Latest Articles

Where all the Action Is !!!!