Guenadi N Jilevski's Oracle BLOG

Oracle RAC, DG, EBS, DR and HA DBA BLOG

Substitution Variables in Oracle 11g RMAN scripts

 

Substitution Variables in Oracle 11g RMAN scripts

Starting with Oracle 11g substitution variables can be used in RMAN scripts similarly to what sqlplus used to offer in earlier releases.

Let’s create a scripts e:\backup.cmd with the following content.

CONNECT TARGET /

BACKUP TAG &1 COPIES &2 &3;

EXIT;

Let’s create e:\backup.bat file with the following content.

set ORACLE_HOME=E:\oracle11gr2\app\User\product\11.2.0\dbhome_1

echo %1

echo %2

echo %3

rman @’e:\backup.cmd’ using %1 %2 %3

  1. We can invoke the script without substitution variables and will be prompted for values.

 

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>rman @e:\backup.cmd

Recovery Manager: Release 11.2.0.1.0 – Production on Mon Sep 6 17:05:28 2010

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

RMAN> CONNECT TARGET *

2> BACKUP TAG

Enter value for 1: ‘FULL’

‘FULL’ COPIES

Enter value for 2: 1

1

Enter value for 3: database

database;

3> EXIT;

connected to target database: ORCL11GR (DBID=702742010)

Starting backup at 06-SEP-10

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=6 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

SYSTEM01.DBF

input datafile file number=00002 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

SYSAUX01.DBF

input datafile file number=00005 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

EXAMPLE01.DBF

input datafile file number=00003 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

UNDOTBS01.DBF

input datafile file number=00004 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

USERS01.DBF

channel ORA_DISK_1: starting piece 1 at 06-SEP-10

channel ORA_DISK_1: finished piece 1 at 06-SEP-10

piece handle=E:\ORACLE11GR2\APP\USER\FLASH_RECOVERY_AREA\ORCL11GR2\BACKUPSET\201

0_09_06\O1_MF_NNNDF_FULL_689X9PC2_.BKP tag=FULL comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 06-SEP-10

channel ORA_DISK_1: finished piece 1 at 06-SEP-10

piece handle=E:\ORACLE11GR2\APP\USER\FLASH_RECOVERY_AREA\ORCL11GR2\BACKUPSET\201

0_09_06\O1_MF_NCSNF_FULL_689XF9M9_.BKP tag=FULL comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-SEP-10

Recovery Manager complete.

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>

  1. We can pass the parameters directly to the rman

 

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>rman @e:\backup.cmd ‘TEST1’ 1 ‘

database’

Recovery Manager: Release 11.2.0.1.0 – Production on Mon Sep 6 16:55:58 2010

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

RMAN> CONNECT TARGET *

2> BACKUP TAG TEST1 COPIES 1 database;

3> EXIT;

connected to target database: ORCL11GR (DBID=702742010)

Starting backup at 06-SEP-10

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=65 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

SYSTEM01.DBF

input datafile file number=00002 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

SYSAUX01.DBF

input datafile file number=00005 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

EXAMPLE01.DBF

input datafile file number=00003 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

UNDOTBS01.DBF

input datafile file number=00004 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

USERS01.DBF

channel ORA_DISK_1: starting piece 1 at 06-SEP-10

channel ORA_DISK_1: finished piece 1 at 06-SEP-10

piece handle=E:\ORACLE11GR2\APP\USER\FLASH_RECOVERY_AREA\ORCL11GR2\BACKUPSET\201

0_09_06\O1_MF_NNNDF_TEST1_689WQJ6Q_.BKP tag=TEST1 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 06-SEP-10

channel ORA_DISK_1: finished piece 1 at 06-SEP-10

piece handle=E:\ORACLE11GR2\APP\USER\FLASH_RECOVERY_AREA\ORCL11GR2\BACKUPSET\201

0_09_06\O1_MF_NCSNF_TEST1_689WV4CP_.BKP tag=TEST1 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-SEP-10

Recovery Manager complete.

  1. We can pass the parameters directly to rman specifying using option

 

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>rman @e:\backup.cmd using ‘TEST

1′ 1 ‘database’

Recovery Manager: Release 11.2.0.1.0 – Production on Mon Sep 6 16:58:14 2010

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

RMAN> CONNECT TARGET *

2> BACKUP TAG TEST1 COPIES 1 database;

3> EXIT;

connected to target database: ORCL11GR (DBID=702742010)

Starting backup at 06-SEP-10

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=6 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

SYSTEM01.DBF

input datafile file number=00002 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

SYSAUX01.DBF

input datafile file number=00005 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

EXAMPLE01.DBF

input datafile file number=00003 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

UNDOTBS01.DBF

input datafile file number=00004 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

USERS01.DBF

channel ORA_DISK_1: starting piece 1 at 06-SEP-10

channel ORA_DISK_1: finished piece 1 at 06-SEP-10

piece handle=E:\ORACLE11GR2\APP\USER\FLASH_RECOVERY_AREA\ORCL11GR2\BACKUPSET\201

0_09_06\O1_MF_NNNDF_TEST1_689WVQRH_.BKP tag=TEST1 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 06-SEP-10

channel ORA_DISK_1: finished piece 1 at 06-SEP-10

piece handle=E:\ORACLE11GR2\APP\USER\FLASH_RECOVERY_AREA\ORCL11GR2\BACKUPSET\201

0_09_06\O1_MF_NCSNF_TEST1_689WZ226_.BKP tag=TEST1 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-SEP-10

Recovery Manager complete.

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>

  1. We can invoke the e:\backup.bat passing the values at command line.

 

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>E:\backup.bat ‘TEST1’ 1 ‘databas

e’

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>set ORACLE_HOME=E:\oracle11gr2\a

pp\User\product\11.2.0\dbhome_1

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>echo ‘TEST1’

‘TEST1’

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>echo 1

1

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>echo ‘database’

‘database’

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>rman @’e:\backup.cmd’ using ‘TES

T1’ 1 ‘database’

Recovery Manager: Release 11.2.0.1.0 – Production on Mon Sep 6 17:22:55 2010

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

RMAN> CONNECT TARGET *

2> BACKUP TAG TEST1 COPIES 1 database;

3> EXIT;

connected to target database: ORCL11GR (DBID=702742010)

Starting backup at 06-SEP-10

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=65 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

SYSTEM01.DBF

input datafile file number=00002 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

SYSAUX01.DBF

input datafile file number=00005 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

EXAMPLE01.DBF

input datafile file number=00003 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

UNDOTBS01.DBF

input datafile file number=00004 name=E:\ORACLE11GR2\APP\USER\ORADATA\ORCL11GR2\

USERS01.DBF

channel ORA_DISK_1: starting piece 1 at 06-SEP-10

channel ORA_DISK_1: finished piece 1 at 06-SEP-10

piece handle=E:\ORACLE11GR2\APP\USER\FLASH_RECOVERY_AREA\ORCL11GR2\BACKUPSET\201

0_09_06\O1_MF_NNNDF_TEST1_689YB1N3_.BKP tag=TEST1 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 06-SEP-10

channel ORA_DISK_1: finished piece 1 at 06-SEP-10

piece handle=E:\ORACLE11GR2\APP\USER\FLASH_RECOVERY_AREA\ORCL11GR2\BACKUPSET\201

0_09_06\O1_MF_NCSNF_TEST1_689YFOYO_.BKP tag=TEST1 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02

Finished backup at 06-SEP-10

Recovery Manager complete.

E:\oracle11gR2\app\User\product\11.2.0\dbhome_1>

September 6, 2010 Posted by | oracle | Leave a comment

GNS configuration for Oracle 11gR2 in DNS using DHCP

GNS configuration for Oracle 11gR2 in DNS using DHCP

Oracle 11gR2 introduces a new concept of a Single Client Access Name (SCAN). Prior to Oracle 11gR2 adding or removing nodes from the cluster required changes in the tnsnames.ora for the node VIP addresses. With SCAN Oracle eliminated the need to change tnsnames.ora entries. SCAN is required for Oracle 11gR2 Grid Infrastructure installation and OUI cannot complete install unless SCAN is defined since the SCAN concept is an essential part during the creation of Oracle RAC 11gR2 database.

SCAN can be defined in following ways:

  • In the DNS – a single name that resolves to three IP addresses must be created in DNS. The IP should not be assigned to a NIC as the Oracle Grid Infrastructure will
  • Using GNS – instead of listing SCAN static addresses in DNS a sub-domain must be created in DNS for GNS to run that is, we will create a static virtual IP address in DNS for GNS. The node VIP and the SCAN VIP are obtained from the DHCP server when using GNS.
  • In /etc/hosts on each node of the cluster – a single IP for the whole cluster. Helps bypass the OUI installer limitation of DNS defined SCAN.

Here in the article we will look at how to configure a GNS entry in the DNS resolvable to a GNS VIP using Oracle Enterprise Linux (OEL) 5.5. For grid.gj.com a “delegation” is made, so that every request to a machine in the domain .grid.gj.com is delegated to the GNS. (with the GNS VIP).The BIND DNS server is used in the exercise. We have a RAC cluster on nodes raclinux1, raclinux2 and raclinux3. The public addresses of the cluster nodes, the GNS VIP address and DNS server IP will be added to a new domain with reverse lookup enabled. The setup is performed on a separate DNS server dnsoel55 acting as NS. The DNS will contain the following mappings.

raclinux1     192.168.20.10

raclinux2     192.168.20.20

raclinux3     192.168.20.30

dnsoel55     192.168.20.50

gns.grid.gj.com        192.168.20.52

Note: the cluster node VIPs and SCANs are obtained via DHCP.

Install BIND – Make sure the following rpms are installed

[root@dnsoel55 named]# rpm -qa | grep bind

bind-9.3.6-4.P1.el5_4.2

bind-libs-9.3.6-4.P1.el5_4.2

system-config-bind-4.0.3-4.0.1.el5

bind-chroot-9.3.6-4.P1.el5_4.2

bind-utils-9.3.6-4.P1.el5_4.2

[root@dnsoel55 named]#

Install DHCP –Make sure the following rpms are installed

[root@dnsoel55 named]# rpm -qa | grep dhcp-3

dhcp-3.0.5-23.el5

[root@dnsoel55 named]#

Make sure DNS information is set while configuring Network Devices.


Configure BIND

We will create a new custom zone gj.com and will list the public nodes of the cluster in the domain in order to map a hostname to an address. We will create a new custom zone grid.gj.com for the GNS virtual IP (VIP). We will add a reverse DNS lookup for the entries as well by adding a zone “20.168.192.in-addr.arpa” in order to identify a hostname by the address. In the /etc/named.conf file we will add the following entries.

zone “20.168.192.in-addr.arpa” IN {

type master;

file “gj1.com.reverse”;

allow-update { none; };

};

zone “gj.com.” IN {

type master;

file “gj1.zone”;

allow-update { none; };

};

zone “grid.gj.com.” IN {
type forward;
forward only;
forwarders { 192.168.20.52 ;};
};

The custom zone, for the public IP, definition is in the gj.zone file as shown in the Appendix. The reverse lookup is in the gj.com.reverse file as shown in the Appendix. The custom zone, for GNS VIP, definition is in the grid.gj.zone file as shown in the Appendix. Both zone files are in /var/named directory. For each entry that is added in the /etc/named.conf make sure the respective zone files are updated.

Configure DHCP

For GNS resolution we will configure DHCL by editing the /etc/dhcpd.conf file and specifying the domain, IP range for the nodes VIP, SCANS etc. In this example the gj.com domin is used and an IP range 192.168.20.100 to 192.168.20.120 is provided.


[root@dnsoel55 named]# cat /etc/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

subnet 192.168.20.0 netmask 255.255.255.0 {

# --- default gateway

option routers                  192.168.30.254;

option subnet-mask              255.255.255.0;

#       option nis-domain               "gj.com";

option domain-name              "gj.com";

option domain-name-servers      192.168.30.50;

option time-offset              -18000; # Eastern Standard Time

#       option ntp-servers              192.168.1.1;

#       option netbios-name-servers     192.168.1.1;

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

#       option netbios-node-type 2;

range 192.168.20.100 192.168.20.120;

default-lease-time 21600;

max-lease-time 43200;

}

[root@dnsoel55 named]#

Edit the file /etc/resolv.conf to specify the IP of the DNS server and the domain name on each node. The Appendix contains a sample.

Edit /etc/nsswitch.conf to specify lookup order.

hosts: dns files

Start/Stop/Restart the named

[root@dnsoel55 named]# service named stop

Stopping named: [ OK ]

[root@dnsoel55 named]# service named start

Starting named: [ OK ]

[root@dnsoel55 named]#

[root@dnsoel55 named]# service named restart

Stopping named: [ OK ]

Starting named: [ OK ]

[root@dnsoel55 named]#

To start up the named service on boot execute the following command.

[root@dnsoel55 named]# chkconfig named on

[root@dnsoel55 named]#

Start/Stop/Restart the dhcpd

[root@dnsoel55 named]# service dhcpd start

[root@dnsoel55 named]# service dhcpd stop

Shutting down dhcpd: [ OK ]

[root@dnsoel55 named]# service dhcpd restart

Starting dhcpd: [ OK ]

[root@dnsoel55 named]# service dhcpd restart

Shutting down dhcpd: [ OK ]

Starting dhcpd: [ OK ]

[root@dnsoel55 named]#

Optionally use system-config-bind to look at the setup

The gj.com zone appears as show below.


The zone grid.gj.com appears as below


The zone 20.168.192.in-addr.arpa for the reverse lookup appears as show below.


Disable iptable service for the external hosts to be able to connect to DNS server.

[root@dnsoel55 named]# service iptables stop

Flushing firewall rules: [ OK ]

Setting chains to policy ACCEPT: nat filter [ OK ]

Unloading iptables modules: [ OK ]

Test

[root@dnsoel55 named]# nslookup raclinux1
Server:         192.168.30.50
Address:        192.168.30.50#53

Name:   raclinux1.gj.com
Address: 192.168.20.10

[root@dnsoel55 named]# nslookup 192.168.20.10
Server:         192.168.30.50
Address:        192.168.30.50#53

10.20.168.192.in-addr.arpa      name = raclinux1.gj.com.

[root@dnsoel55 named]# nslookup raclinux2
Server:         192.168.30.50
Address:        192.168.30.50#53

Name:   raclinux2.gj.com
Address: 192.168.20.20

[root@dnsoel55 named]# nslookup 192.168.20.20
Server:         192.168.30.50
Address:        192.168.30.50#53

20.20.168.192.in-addr.arpa      name = raclinux2.gj.com.

[root@dnsoel55 named]# nslookup dnsoel55
Server:         192.168.30.50
Address:        192.168.30.50#53

Name:   dnsoel55.gj.com
Address: 192.168.20.50

[root@dnsoel55 named]# nslookup 192.168.20.50
Server:         192.168.30.50
Address:        192.168.30.50#53

50.20.168.192.in-addr.arpa      name = dnsoel55.gj.com.
[root@dnsoel55 named]# nslookup gns.grid.gj.com
Server:         192.168.30.50
Address:        192.168.30.50#53

Name:   gns.grid.gj.com
Address: 192.168.20.52
[root@dnsoel55 named]# nslookup 192.168.20.52
Server:         192.168.30.50
Address:        192.168.30.50#53

52.20.168.192.in-addr.arpa      name = gns.grid.gj.com.

[root@dnsoel55 named]#

Summary

We looked at the rpms required to install BIND and DHCP on OEL. We created a custom and reverse lookup zone for the cluster public nodes and for the GNS VIP. The configuration files required for DNS setup were described. We tested the forward and reverse DNS resolution. The above DNS setup will ensure that we have GNS VIP for the Oracle 11gR2 Grid Infrastructure installation.

After the Oracle GI installation the nslookup output will be something like:

[root@dnsoel55 named]# nslookup scan.grid.gj.com

Server: 192.168.20.50

Address: 192.168.20.50#53

Non-authoritative answer:

Name: scan.grid.gj.com

Address: 192.168.20.107

Name: scan.grid.gj.com

Address: 192.168.20.108

Name: scan.grid.gj.com

Address: 192.168.20.109

[root@dnsoel55 named]#

Appendix:


[root@dnsoel55 etc]# cat named.conf

// Enterprise Linux BIND Configuration Tool

//

// Default initial "Caching Only" name server configuration

//

options {

directory "/var/named";

dump-file "/var/named/data/cache_dump.db";

statistics-file "/var/named/data/named_stats.txt";

/*

* If there is a firewall between you and nameservers you want

* to talk to, you might need to uncomment the query-source

* directive below.  Previous versions of BIND always asked

* questions using port 53, but BIND 8.1 uses an unprivileged

* port by default.

*/

// query-source address * port 53;

};

zone "20.168.192.in-addr.arpa" IN {

type master;

file "gj1.com.reverse";

allow-update { none; };

};

zone "30.168.192.in-addr.arpa" IN {

type master;

file "gj.reverse";

allow-update { none; };

};

zone "gj.com." IN {

type master;

file "gj1.zone";

allow-update { none; };

};

zone "grid.gj.com." IN {

type forward;
forward only;
forwarders { 192.168.2.61 ;}
};

zone "." IN {

type hint;

file "named.root";

};

zone "localdomain." IN {

type master;

file "localdomain.zone";

allow-update { none; };

};

zone "localhost." IN {

type master;

file "localhost.zone";

allow-update { none; };

};

zone "0.0.127.in-addr.arpa." IN {

type master;

file "named.local";

allow-update { none; };

};

zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." IN {

type master;

file "named.ip6.local";

allow-update { none; };

};

zone "255.in-addr.arpa." IN {

type master;

file "named.broadcast";

allow-update { none; };

};

zone "0.in-addr.arpa." IN {

type master;

file "named.zero";

allow-update { none; };

};

include "/etc/rndc.key";

[root@dnsoel55 etc]#

[root@dnsoel55 named]# cat gj1.com.reverse

$ORIGIN 20.168.192.in-addr.arpa.

$TTL 1H

@       IN      SOA     dnsoel55.gj.com.     root.dnsoel55.gj.com. (      2

3H

1H

1W

1H )

20.168.192.in-addr.arpa.         IN NS      dnsoel55.gj.com.

IN NS      dnsoel55.gj.com.

10              IN PTR  raclinux1.gj.com.

20              IN PTR  raclinux2.gj.com.

30              IN PTR  raclinux3.gj.com.

50              IN PTR  dnsoel55.gj.com.

52              IN PTR  gns.grid.gj.com.

[root@dnsoel55 named]# cat gj1.zone

$TTL    86400

@               IN SOA  dnsoel55 root (

43              ; serial (d. adams)

3H              ; refresh

15M             ; retry

1W              ; expiry

1D )            ; minimum

IN NS           dnsoel55

raclinux1           IN A        192.168.20.10

raclinux2           IN A        192.168.20.20

raclinux3           IN A        192.168.20.30

dnsoel55        IN A            192.168.20.50
gns.grid.gj.com.        IN      A        192.168.20.52

[root@dnsoel55 named]# cat grid.gj.zone

$TTL    86400

@               IN SOA  dnsoel55 root (

43              ; serial (d. adams)

3H              ; refresh

15M             ; retry

1W              ; expiry

1D )            ; minimum

IN NS           dnsoel55

IN      NS     gns.grid.gj.com.

IN      NS     dnsoel55.gj.com.

gns           IN      A      192.168.20.52

dnsoel55        IN A            192.168.20.50

[root@dnsoel55 named]#

[root@dnsoel55 named]# cat /etc/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

subnet 192.168.20.0 netmask 255.255.255.0 {

# --- default gateway

option routers                  192.168.30.254;

option subnet-mask              255.255.255.0;

#       option nis-domain               "gj.com";

option domain-name              "gj.com";

option domain-name-servers      192.168.30.50;

option time-offset              -18000; # Eastern Standard Time

#       option ntp-servers              192.168.1.1;

#       option netbios-name-servers     192.168.1.1;

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

#       option netbios-node-type 2;

range 192.168.20.100 192.168.20.120;

default-lease-time 21600;

max-lease-time 43200;

}

[root@dnsoel55 named]#

[root@dnsoel55 named]# cat /etc/resolv.conf

options attempts: 2

options timeout: 1

options attempts: 2

; generated by /sbin/dhclient-script

search gj.com

nameserver 192.168.30.50

[root@dnsoel55 named]#

[root@dnsoel55 named]# cat /etc/nsswitch.conf

#

# /etc/nsswitch.conf

#

# An example Name Service Switch config file. This file should be

# sorted with the most-used services at the beginning.

#

# The entry '[NOTFOUND=return]' means that the search for an

# entry should stop if the search in the previous entry turned

# up nothing. Note that if the search failed due to some other reason

# (like no NIS server responding) then the search continues with the

# next entry.

#

# Legal entries are:

#

#       nisplus or nis+         Use NIS+ (NIS version 3)

#       nis or yp               Use NIS (NIS version 2), also called YP

#       dns                     Use DNS (Domain Name Service)

#       files                   Use the local files

#       db                      Use the local database (.db) files

#       compat                  Use NIS on compat mode

#       hesiod                  Use Hesiod for user lookups

#       [NOTFOUND=return]       Stop searching if not found so far

#

# To use db, put the "db" in front of "files" for entries you want to be

# looked up first in the databases

#

# Example:

#passwd:    db files nisplus nis

#shadow:    db files nisplus nis

#group:     db files nisplus nis

passwd:     files

shadow:     files

group:      files

#hosts:     db files nisplus nis dns

hosts:      dns files

# Example - obey only what nisplus tells us...

#services:   nisplus [NOTFOUND=return] files

#networks:   nisplus [NOTFOUND=return] files

#protocols:  nisplus [NOTFOUND=return] files

#rpc:        nisplus [NOTFOUND=return] files

#ethers:     nisplus [NOTFOUND=return] files

#netmasks:   nisplus [NOTFOUND=return] files

bootparams: nisplus [NOTFOUND=return] files

ethers:     files

netmasks:   files

networks:   files

protocols:  files

rpc:        files

services:   files

netgroup:   nisplus

publickey:  nisplus

automount:  files nisplus

aliases:    files nisplus

[root@dnsoel55 named]#

 Pro DNS and Bind

September 5, 2010 Posted by | oracle | 23 Comments

DNS configuration for Oracle 11gR2 SCAN listeners

DNS configuration for Oracle 11gR2 SCAN listeners

Oracle 11gR2 introduces a new concept of a Single Client Access Name (SCAN). Prior to Oracle 11gR2 adding or removing nodes from the cluster required changes in the tnsnames.ora for the node VIP addresses. With SCAN Oracle eliminated the need to change tnsnames.ora entries. SCAN is required for Oracle 11gR2 Grid Infrastructure installation and OUI cannot complete install unless SCAN is defined since the SCAN concept is an essential part during the creation of Oracle RAC 11gR2 database.

SCAN can be defined in following ways:

  • In the DNS – a single name that resolves to three IP addresses must be created in DNS. The IP should not be assigned to a NIC as the Oracle Grid Infrastructure will
  • Using GNS – instead of listing SCAN static addresses in DNS a sub-domain must be created in DNS for GNS to run that is, we create a static virtual IP address in DNS for GNS. The node VIP and the SCAN VIP are obtained from the DHCP server when using GNS.
  • In /etc/hosts on each node of the cluster – a single IP for the whole cluster. Helps bypass the OUI installer limitation of DNS defined SCAN.

 

Here in the article we will look at how to configure a SCAN entry in the DNS resolvable to three IP addresses instead of GNS using Oracle Enterprise Linux (OEL) 5.5. The BIND DNS server is used in the exercise. We have a RAC cluster on nodes raclinux1, raclinux2 and raclinux3. The public and VIP addresses of the cluster nodes, the SCAN addresses and DNS server IP will be added to a new domain with reverse lookup enabled. The setup is performed on a separate DNS server dnsoel55 acting as NS. The DNS will contain the following mappings.

raclinux1 192.168.20.10

raclinux1-vip 192.168.20.11

raclinux2 192.168.20.20

raclinux2-vip 192.168.20.21

raclinux3 192.168.20.30

raclinux3-vip 192.168.20.31

dnsoel55 192.168.20.50

scan-cluster 192.168.20.100

scan-cluster 192.168.20.101

scan-cluster 192.168.20.102

Install BIND – Make sure the following rpms are installed

[root@dnsoel55 named]# rpm -qa | grep bind

bind-9.3.6-4.P1.el5_4.2

bind-libs-9.3.6-4.P1.el5_4.2

system-config-bind-4.0.3-4.0.1.el5

bind-chroot-9.3.6-4.P1.el5_4.2

bind-utils-9.3.6-4.P1.el5_4.2

[root@dnsoel55 named]#

Make sure DNS information is set while configuring Network Devices.


Configure BIND

We will create a new custom zone gj.com and will list the SCAN, public and VIP nodes of the cluster in the domain in order to map a hostname to an address. We will add a reverse DNS lookup for the entries as well by adding a zone “20.168.192.in-addr.arpa” in order to identify a hostname by the address. In the /etc/named.conf file we will add the following entries.

zone “20.168.192.in-addr.arpa” IN {

type master;

file “gj.com.reverse”;

allow-update { none; };

};

zone “gj.com” IN {

type master;

file “gj.zone”;

allow-update { none; };

};

The custom zone definition is in the gj.zone file as shown in the Appendix. The reverse lookup is in the gj.com.reverse file as shown in the Appendix. Both zone files are in /var/named directory. For each entry that is added in the /etc/named.conf make sure the respective zone files are updated.

Edit the file /etc/resolv.conf to specify the IP of the DNS server and the domain name on each node. The Appendix contains a sample.

Edit /etc/nsswitch.conf to specify lookup order.

hosts: dns files

Start/Stop/Restart the named

[root@dnsoel55 named]# service named stop

Stopping named: [ OK ]

[root@dnsoel55 named]# service named start

Starting named: [ OK ]

[root@dnsoel55 named]#

[root@dnsoel55 named]# service named restart

Stopping named: [ OK ]

Starting named: [ OK ]

[root@dnsoel55 named]#

To start up the named service on boot execute the following command.

[root@dnsoel55 named]# chkconfig named on

[root@dnsoel55 named]#

Optionally use system-config-bind to look at the setup

The gj.com zone appears as show below.


The zone 20.168.192.in-addr.arpa for the reverse lookup appears as show below.


Test


[root@dnsoel55 named]# nslookup dnsoel55

Server:         192.168.30.50

Address:        192.168.30.50#53

Name:   dnsoel55.gj.com

Address: 192.168.20.50

[root@dnsoel55 named]# nslookup 192.168.20.50

Server:         192.168.30.50

Address:        192.168.30.50#53

50.20.168.192.in-addr.arpa      name = dnsoel55.gj.com.

[root@dnsoel55 named]# nslookup scan-cluster

Server:         192.168.30.50

Address:        192.168.30.50#53

Name:   scan-cluster.gj.com

Address: 192.168.20.100

Name:   scan-cluster.gj.com

Address: 192.168.20.101

Name:   scan-cluster.gj.com

Address: 192.168.20.102

[root@dnsoel55 named]# nslookup 192.168.20.100

Server:         192.168.30.50

Address:        192.168.30.50#53

100.20.168.192.in-addr.arpa     name = scan-cluster.gj.com.

[root@dnsoel55 named]# nslookup 192.168.20.101

Server:         192.168.30.50

Address:        192.168.30.50#53

101.20.168.192.in-addr.arpa     name = scan-cluster.gj.com.

[root@dnsoel55 named]# nslookup 192.168.20.102

Server:         192.168.30.50

Address:        192.168.30.50#53

102.20.168.192.in-addr.arpa     name = scan-cluster.gj.com.

[root@dnsoel55 named]#

[root@dnsoel55 named]# dig gj.com

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_4.2 <<>> gj.com

;; global options:  printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31152

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:

;gj.com.                                IN      A

;; AUTHORITY SECTION:

gj.com.                 86400   IN      SOA     dnsoel55.gj.com. root.gj.com. 43 10800 900 604800 86400

;; Query time: 1 msec

;; SERVER: 192.168.30.50#53(192.168.30.50)

;; WHEN: Sat Sep  4 05:39:49 2010

;; MSG SIZE  rcvd: 74

[root@dnsoel55 named]#

[root@dnsoel55 named]# dig -x 192.168.20.100

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-4.P1.el5_4.2 <<>> -x 192.168.20.100

;; global options:  printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15707

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:

;100.20.168.192.in-addr.arpa.   IN      PTR

;; ANSWER SECTION:

100.20.168.192.in-addr.arpa. 3600 IN    PTR     scan-cluster.gj.com.

;; AUTHORITY SECTION:

20.168.192.in-addr.arpa. 3600   IN      NS      dnsoel55.gj.com.

;; ADDITIONAL SECTION:

dnsoel55.gj.com.        86400   IN      A       192.168.20.50

;; Query time: 0 msec

;; SERVER: 192.168.30.50#53(192.168.30.50)

;; WHEN: Sat Sep  4 07:01:34 2010

;; MSG SIZE  rcvd: 117

[root@dnsoel55 named]#

Summary

We looked at the rpms required to install BIND on OEL. We created a custom and reverse lookup zone for the cluster nodes and for the SCAN. The configuration files required for DNS setup were described. We tested the forward and reverse DNS resolution. The above DNS setup will ensure that we have three SCAN IPs for the Oracle 11gR2 Grid Infrastructure installation.

Appendix:


 [root@dnsoel55 named]# rpm -qa | grep bind

bind-9.3.6-4.P1.el5_4.2

bind-libs-9.3.6-4.P1.el5_4.2

system-config-bind-4.0.3-4.0.1.el5

bind-chroot-9.3.6-4.P1.el5_4.2

bind-utils-9.3.6-4.P1.el5_4.2

[root@dnsoel55 named]#

[root@dnsoel55 etc]# cat named.conf

options {

        directory "/var/named";

        dump-file "/var/named/data/cache_dump.db";

        statistics-file "/var/named/data/named_stats.txt";

        /*

         * If there is a firewall between you and nameservers you want

         * to talk to, you might need to uncomment the query-source

         * directive below.  Previous versions of BIND always asked

         * questions using port 53, but BIND 8.1 uses an unprivileged

         * port by default.

         */

         // query-source address * port 53;

};

zone "20.168.192.in-addr.arpa" IN {

 type master;

 file "gj.com.reverse";

 allow-update { none; };

};

zone "gj.com" IN {

 type master;

 file "gj.zone";

 allow-update { none; };

};

zone "." IN {

        type hint;

        file "named.root";

};

zone "localdomain." IN {

        type master;

        file "localdomain.zone";

        allow-update { none; };

};

zone "localhost." IN {

        type master;

        file "localhost.zone";

        allow-update { none; };

};

zone "0.0.127.in-addr.arpa." IN {

        type master;

        file "named.local";

        allow-update { none; };

};

zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." IN {

        type master;

        file "named.ip6.local";

        allow-update { none; };

};

zone "255.in-addr.arpa." IN {

        type master;

        file "named.broadcast";

        allow-update { none; };

};

zone "0.in-addr.arpa." IN {

        type master;

        file "named.zero";

        allow-update { none; };

};

include "/etc/rndc.key";

[root@dnsoel55 etc]#

[root@dnsoel55 named]# cat gj.zone

$ORIGIN gj.com.

$TTL    86400

@               IN SOA  dnsoel55 root (

                                        43              ; serial (d. adams)

                                        3H              ; refresh

                                        15M             ; retry

                                        1W              ; expiry

                                        1D )            ; minimum

                        IN NS           dnsoel55

raclinux1           IN A        192.168.20.10

raclinux1-vip          IN A     192.168.20.11

raclinux2           IN A        192.168.20.20

raclinux2-vip          IN A     192.168.20.21

raclinux3           IN A        192.168.20.30

raclinux3-vip          IN A     192.168.20.31

dnsoel55        IN A            192.168.20.50

scan-cluster    IN A            192.168.20.100

scan-cluster    IN A            192.168.20.101

scan-cluster    IN A            192.168.20.102

scan-cluster    IN A            192.168.20.102

[root@dnsoel55 named]#

[root@dnsoel55 named]# cat gj.com.reverse

$ORIGIN 20.168.192.in-addr.arpa.

$TTL 1H

@       IN      SOA     dnsoel55.gj.com.     root.dnsoel55.gj.com. (      2

                                                3H

                                                1H

                                                1W

                                                1H )

;;30.168.192.in-addr.arpa.         IN NS      dnsoel55.gj.com.

        IN NS      dnsoel55.gj.com.

10              IN PTR  raclinux1.gj.com.

11              IN PTR  raclinux1-vip.gj.com.

20              IN PTR  raclinux2.gj.com.

21              IN PTR  raclinux2-vip.gj.com.

30              IN PTR  raclinux3.gj.com.

31              IN PTR  raclinux3-vip.gj.com.

50              IN PTR  dnsoel55.gj.com.

100             IN PTR  scan-cluster.gj.com.

101             IN PTR  scan-cluster.gj.com.

102             IN PTR  scan-cluster.gj.com.

[root@dnsoel55 named]#

[root@dnsoel55 named]# cat /etc/resolv.conf

options attempts: 2

options timeout: 1

options attempts: 2

; generated by /sbin/dhclient-script

search gj.com

nameserver 192.168.30.50

[root@dnsoel55 named]#

 

September 3, 2010 Posted by | oracle | 9 Comments