Jan 12 2016

Oracle 11g Data Guard Failover With Python Script

Category: Administration,Backup And Recovery,Linux & Unix,PythonFatih Acar @ 10:56

I wrote a python script to perform failover steps and to take product database IP addresses when product database is down. If you dont use data guard broker or other application for failover operations, you can use this script for failover. My scenario is that I have Oracle 11gR2 2 nodes RAC product database and 1 node standby real time apply type data guard database. When the product database is fail, the data guard database can run as product database with take product database IP addresses and service name. Python script will do all steps that take product IP address, take product service name, perform failover steps.

I made test when data guard was archivelog apply type, script could run correctly.


Product Database : Oracle 11g R2 ( RAC
Data Guard : Oracle 11g R2 ( Single Instance With Grid Infrastructure
Operating System : Oracle Linux 6.6
Data Guard Type : Real Time Apply From Redo Logs
Script Name : failover.py

Python script file is failover.py .Firstly, we have to change parameters in script. You can use vi editor. I generally create python files under /opt/scripts directory.


Script has 3 types take virtual IP process. If you can not see product virtual IP address when you run ifconfig command after run failover.py script, you can use other type virtual IP process.

The product database is fail. We have to run data guard database like product database. We can use failover.py script.

Run failover.py

[root@dg scripts]# python failover.py


If all parameters are correct, you can write “evet” and push enter.


You can choose 1 or 2. If you choose 1, you can do only IP operations. If you choose 2, you can do both IP operations and failover steps. Firstly, you should choose 2 because of the fact that you have to take IP addresses and perform failover steps.


You can choose 1,2 or 3. I recommend 1. If you dont see IP address when you run ifconfig command after run failover.py, you can use others.

When you choose 1 and enter, you can see like below if processes are smooth.



Control Database


Control IP Address


If everything is okey, you can control your database and client connections.

This failover.py script can not comply with your system. You have to make test on your test environment.

14,771 total views, 2 views today

Tags: Database Administration, Oracle Administration, Oracle Backup and Restore, Oracle Data Guard Failover, Oracle Failover

facebook comments:

One Response to “Oracle 11g Data Guard Failover With Python Script”

  1. Oracle 11g Data Guard Failover With Python Script – 一站 says:

    […] Source : https://www.fatihacar.com/blog/oracle-11g-data-guard-failover-with-python-script/ […]

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.