sexta-feira, 23 de novembro de 2018

Oracle RAC: Migrate SCAN from /etc/hosts to DNS

Introdution


Oracle SCAN Listener and SCAN name resolution is not a new feature in Oracle World, It was introduced in Oracle 11g R2 and since then is one of the most important feature for high availability service. With Scan name we can resolve one single name for the entire cluster and we don't need to wory in mainten a long list of available VIPs for every single application client.

One requisite for use Scan-name is to have 3 IPs resolving one single name in Round Robin at your DNS Service, as we can confirm at this Oracle White Paper, then we can deal with load balance and high availability property.

Problem


Unfurtenly there is a workaround for the three IPs recomendation, you can use the /etc/hosts with one single IP, install Oracle Clusterware and work with just one IP for the Scan, and in a near future another DBA has the duty to change this, so the DBA who installed the Clusterware doesn't need to wait the DNS guy do his job to install Oracle.

The problem is, oneday you will need to fix this, I already faced few environment running like this, even in 2018 I faced this. In this article I'll show how to fix and what you need to care and plan before executing.

Solution


It's very simple to change from /etc/hosts to DNS, you need first to ensure that the DNS Guy input tree entries on the DNS resolving one single name with 3 ip in round robin as we can see bellow:

[root@srv-ora-rac01 ~]# nslookup scan-ora-rac
Server: 192.168.1.101
Address: 192.168.1.101#53

Name: scan-ora-rac
Address: 192.168.1.72
Name: scan-ora-rac
Address: 192.168.1.73
Name: scan-ora-rac
Address: 192.168.1.71

[root@srv-ora-rac01 ~]# nslookup scan-ora-rac
Server: 192.168.1.101
Address: 192.168.1.101#53

Name: scan-ora-rac
Address: 192.168.1.73
Name: scan-ora-rac
Address: 192.168.1.71
Name: scan-ora-rac
Address: 192.168.1.72

[root@srv-ora-rac01 ~]# nslookup scan-ora-rac
Server: 192.168.1.101
Address: 192.168.1.101#53

Name: scan-ora-rac
Address: 192.168.1.71
Name: scan-ora-rac
Address: 192.168.1.72
Name: scan-ora-rac
Address: 192.168.1.73

[root@srv-ora-rac01 ~]# 


The main problem of this is that we still doesn't have all scan listener up and running, so in the mean time between the DNS configuration and the listener configuration user can have time-out, so I recomend to do this out of bussiness hour.

[root@srv-ora-rac01 ~]# ping scan-ora-rac
PING scan-ora-rac (192.168.1.72) 56(84) bytes of data.
^C
--- scan-ora-rac ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2033ms

[root@srv-ora-rac01 ~]# 



First lets confirm the status and the number of scans

[root@srv-ora-rac01 ~]# srvctl config scan
SCAN name: scan-ora-rac, Network: 1
Subnet IPv4: 192.168.1.0/255.255.255.0/enp0s3, static
Subnet IPv6: 
SCAN 0 IPv4 VIP: 192.168.1.71
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes: 
SCAN VIP is individually disabled on nodes: 
[root@srv-ora-rac01 ~]# srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node srv-ora-rac01
[root@srv-ora-rac01 ~]# 


So before continue we need to comment the scan name resolution from the /etc/hosts

[root@srv-ora-rac01 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

##################
# ORACLE RAC IP  #
##################

# SCAN
# 192.168.1.71    scan-ora-rac

# PUBLIC NETWORK
192.168.1.74    srv-ora-rac01
192.168.1.75    srv-ora-rac02

# VIP
192.168.1.76    srv-ora-rac01-vip
192.168.1.77    srv-ora-rac02-vip

# PRIVATE
192.168.0.74    srv-ora-rac01-priv
192.168.0.75    srv-ora-rac02-priv

[root@srv-ora-rac01 ~]# 


So at this point we need to stop the listener and the scan

[root@srv-ora-rac01 ~]# srvctl stop scan_listener
[root@srv-ora-rac01 ~]# srvctl stop scan
[root@srv-ora-rac01 ~]# srvctl status scan_listener
SCAN Listener LISTENER_SCAN1 is enabled
SCAN listener LISTENER_SCAN1 is not running
[root@srv-ora-rac01 ~]# srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is not running
[root@srv-ora-rac01 ~]# 


After the listener stoped we can modify the number of scan listener and scan, for the modify Oracle will query the DNS and resolve the name and create the number of listener according to the number of ip resolved.

[root@srv-ora-rac01 ~]# srvctl modify scan -n scan-ora-rac
[root@srv-ora-rac01 ~]# srvctl modify scan_listener -u

We can check the result as:

[root@srv-ora-rac01 ~]# srvctl config scan
SCAN name: scan-ora-rac, Network: 1
Subnet IPv4: 192.168.1.0/255.255.255.0/enp0s3, static
Subnet IPv6: 
SCAN 0 IPv4 VIP: 192.168.1.73
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes: 
SCAN VIP is individually disabled on nodes: 
SCAN 1 IPv4 VIP: 192.168.1.72
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes: 
SCAN VIP is individually disabled on nodes: 
SCAN 2 IPv4 VIP: 192.168.1.71
SCAN VIP is enabled.
SCAN VIP is individually enabled on nodes: 
SCAN VIP is individually disabled on nodes: 
[root@srv-ora-rac01 ~]# 

[root@srv-ora-rac01 ~]# srvctl start scan
[root@srv-ora-rac01 ~]# srvctl status scan
SCAN VIP scan1 is enabled
SCAN VIP scan1 is running on node srv-ora-rac02
SCAN VIP scan2 is enabled
SCAN VIP scan2 is running on node srv-ora-rac01
SCAN VIP scan3 is enabled
SCAN VIP scan3 is running on node srv-ora-rac01
[root@srv-ora-rac01 ~]# 


That's all, hope you enjoy!


Other Examples


Nenhum comentário: