Dataguard VIP Solution
Dataguard VIP Solution
DATABASE MANAGEMENT
By Franck Pachot
.
When you configure a standby database, you want the application to transparently
connect to the primary database, wherever it is. That’s the role of Transparent
Application Failover, but this requires configuration on the client side. If you can’t
configure TAF, you can use a virtual IP address. But then the question is how to
configure the listener.ora to handle connections to this VIP.
The behaviour is described in How The Listener Binds On TCP Protocol Addresses
(Doc ID 421305.1)
Examples
I have two network interfaces on my system, the loopback (lo) and Ethernet
(enp0s3). This interface has the IP 192.168.78.104 and I have added a virtual IP
192.168.66.102 with:
[oracle@VM104 tmp]$ ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:cc:00:4e:68 brd ff:ff:ff:ff:ff:ff
inet 192.168.78.104/24 brd 192.168.78.255 scope global enp0s3
inet 192.168.66.102/24 scope global enp0s3
inet6 fe80::a00:ccff:fe00:4e68/64 scope link
valid_lft forever preferred_lft forever
Here is the content of my /etc/hosts where I have two names that resolve to my
server IP address 192.168.78.104
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.78.104 VM104 myhost
(HOST=127.0.0.1)
I mentioned the IP address of the loopback interface
With this configuration, I’m able to connect only through the mentioned address,
127.0.0.1
ON=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.78.104)(PORT=6666)
ON=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.66.102)(PORT=6666)
ON=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=6666)))
(HOST=localhost)
I mentioned the loopback interface by a host name
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=6666)))
This is actually the same as above: the host mentioned has been resolved at listener
startup.
(HOST=1192.168.78.104)
I mentioned the IP address of the host interface
With this configuration, I’m able to connect only through the mentioned address,
not the virtual IP, not other interfaces:
(HOST=localhost)
I mentioned the loopback interface by a host name
(HOST=VM104)
I mentioned the host name which resolves to the IP address of the host interface –
this is the default when creating with DBCA, and the recommended configuration.
With this configuration, I’m able to connect through any IP address, including the
virtual IP
(HOST=myhost)
I mentioned another host name which resolves to the IP address of the host
interface (see the /etc/hosts above). It is not the hostname returned by
$(hostname) but it resolve to same IP.
(HOST=0.0.0.0)
Finally, when you want to listen on all interfaces, why not configure the host to
0.0.0.0
We are again in the same situation here and the listener has replaced it with the
hostname. This may be convenient when you want to use the same listener.ora for
different hosts. However, as it finally show the hostname, better to avoid confusion
and have it in the listener.ora
(HOST=VM104)(IP=FIRST)
This is the way to bypass the ‘listen on all interfaces’ rule, even when you resolve to
the hostname.
Conclusion
It is easy to know if the listener listens on one specific IP address, or on all
interfaces. You get the hostname and the listener endpoints
hostname
lsnrctl status
If the ‘HOST=’ matches the hostname, then it listens to all interfaces. If the ‘HOST=’
mentions an IP address, then it listens on this IP only. If it mentions a name which is
not the hostname, then maybe someone has changed the hostname after the
listener was started?
netstat -elpunt
ss -elpunt
If you think that it is a security problem to listen to all interfaces, then you should
understand that the listener is not a firewall. It is just a convenient way to route
connections by service name to the right instance. But remember that you can even
connect to the database without the listener (read
https://amitzil.wordpress.com/2015/10/19/bypassing-the-listener/ ), just
connecting to the dispatcher:
Security is done by firewall rules. Listener is there only to help, so keep it simple.
by
Oracle Team
BE SHARING
Delémont Nyon
Basel Bern
Zürich
1958
Trees planted