Skip to content

How Srvctl Relocate VIP

  • by

srvctl relocate vip

We have talked about how virtual IP (VIP) failover to another node. In this post, let's see how we manually relocate a VIP to another node.

Check VIP

[grid@primary01 ~]$ srvctl status vip -i primary01-vip
VIP 192.168.1.111 is enabled
VIP 192.168.1.111 is running on node: primary01
[grid@primary01 ~]$ srvctl status vip -i primary02-vip
VIP 192.168.1.112 is enabled
VIP 192.168.1.112 is running on node: primary02

Relocate VIP

Here we relocate the first VIP to the second node.

[grid@primary01 ~]$ srvctl relocate vip -i primary01-vip -n primary02
[grid@primary01 ~]$ srvctl status vip -i primary01-vip
VIP 192.168.1.111 is enabled
VIP 192.168.1.111 is running on node: primary02

As we can see, the first VIP has been relocated to another node. More specifically, command srvctl relocate vip is to to unregister from the current host node, then register the virtual IP address on another node.

But wait, is it still usable? The answer is no, since we have already known that the failover VIP is useless.

Let's see what we have found.

Check Relocated VIP

A simple command can prove that the relocated VIP is actually moved to node 2.

[grid@primary01 ~]$ ssh primary01-vip hostname
primary02.example.com

Furthermore, we can use tnsping to test the listener.

[grid@primary01 ~]$ tnsping primary01-vip:1521/orclpdb
...
Used EZCONNECT adapter to resolve the alias
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=orclpdb))(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.111)(PORT=1521)))
TNS-12541: TNS:no listener

We saw TNS-12541: TNS:no listener in this test. Which means that there's no listener on the relocated VIP. In other words, the relocated VIP is useless.

Sometimes, the listener status shows that it supports no services.

[grid@primary01 ~]$ lsnrctl status
...
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.11)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.111)(PORT=1521)))
The listener supports no services
The command completed successfully

Relocate VIP Back

To relocate it back to its host node, we have 2 options.

Restart Local Listener

Yes, a restart on the local listener can get the virtual IP back to its own host node.

[grid@primary01 ~]$ srvctl stop listener -n primary02
[grid@primary01 ~]$ srvctl start listener -n primary02

srvctl relocate vip

[grid@primary01 ~]$ srvctl relocate vip -i primary01-vip -n primary01

All statuses get back to normal now.

Leave a Reply

Your email address will not be published. Required fields are marked *