{"id":1445,"date":"2016-01-12T10:56:22","date_gmt":"2016-01-12T07:56:22","guid":{"rendered":"http:\/\/www.fatihacar.com\/blog\/?p=1445"},"modified":"2016-01-14T10:05:31","modified_gmt":"2016-01-14T07:05:31","slug":"oracle-11g-data-guard-failover-with-python-script","status":"publish","type":"post","link":"http:\/\/www.fatihacar.com\/blog\/oracle-11g-data-guard-failover-with-python-script\/","title":{"rendered":"Oracle 11g Data Guard Failover With Python Script"},"content":{"rendered":"<p>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.<\/p>\n<p>I made test when data guard was\u00a0archivelog apply type, script could run correctly.<\/p>\n<p><strong>Systems<\/strong><\/p>\n<blockquote><p><strong>Product Database :<\/strong> Oracle 11g R2 (11.2.0.3) RAC<br \/>\n<strong>Data Guard :<\/strong> Oracle 11g R2 (11.2.0.3) Single Instance With Grid Infrastructure<br \/>\n<strong>Operating System :<\/strong> Oracle Linux 6.6<br \/>\n<strong>Data Guard Type :<\/strong> Real Time Apply From Redo Logs<br \/>\n<strong>Script Name :<\/strong> <a href=\"http:\/\/www.fatihacar.com\/blog\/resimler\/failover.rar\" rel=\"\">failover.py<\/a><\/p><\/blockquote>\n<p>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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1447\" src=\"http:\/\/www.fatihacar.com\/blog\/resimler\/failover_parameters.png\" alt=\"failover_parameters\" width=\"794\" height=\"277\" srcset=\"http:\/\/www.fatihacar.com\/blog\/resimler\/failover_parameters.png 794w, http:\/\/www.fatihacar.com\/blog\/resimler\/failover_parameters-300x105.png 300w, http:\/\/www.fatihacar.com\/blog\/resimler\/failover_parameters-768x268.png 768w\" sizes=\"auto, (max-width: 794px) 100vw, 794px\" \/><\/p>\n<p>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.<\/p>\n<p>The product database is fail. We have to run data guard database like product database. We can use failover.py script.<\/p>\n<p><strong>Run failover.py<\/strong><\/p>\n<blockquote><p>[root@dg scripts]# python failover.py<\/p><\/blockquote>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1448\" src=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover.png\" alt=\"runfailover\" width=\"778\" height=\"358\" srcset=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover.png 778w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover-300x138.png 300w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover-768x353.png 768w\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" \/><\/p>\n<p>If all parameters are correct, you can write &#8220;evet&#8221; and push enter.<\/p>\n<p><!--more--><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1449\" src=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover2.png\" alt=\"runfailover2\" width=\"747\" height=\"39\" srcset=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover2.png 747w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover2-300x16.png 300w\" sizes=\"auto, (max-width: 747px) 100vw, 747px\" \/><\/p>\n<p>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.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1450\" src=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover3.png\" alt=\"runfailover3\" width=\"784\" height=\"117\" srcset=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover3.png 784w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover3-300x45.png 300w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover3-768x115.png 768w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/p>\n<p>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.<\/p>\n<p>When you choose 1 and enter, you can see like below if processes\u00a0are\u00a0smooth.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1451\" src=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover4.png\" alt=\"runfailover4\" width=\"983\" height=\"826\" srcset=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover4.png 983w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover4-300x252.png 300w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover4-768x645.png 768w\" sizes=\"auto, (max-width: 983px) 100vw, 983px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1452\" src=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover5.png\" alt=\"runfailover5\" width=\"1042\" height=\"716\" srcset=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover5.png 1042w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover5-300x206.png 300w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover5-768x528.png 768w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover5-1024x704.png 1024w\" sizes=\"auto, (max-width: 1042px) 100vw, 1042px\" \/><\/p>\n<p><strong>Control Database<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1453\" src=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover6.png\" alt=\"runfailover6\" width=\"708\" height=\"322\" srcset=\"http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover6.png 708w, http:\/\/www.fatihacar.com\/blog\/resimler\/runfailover6-300x136.png 300w\" sizes=\"auto, (max-width: 708px) 100vw, 708px\" \/><\/p>\n<p><strong>Control IP Address<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1454\" src=\"http:\/\/www.fatihacar.com\/blog\/resimler\/ifconfig.png\" alt=\"ifconfig\" width=\"646\" height=\"642\" srcset=\"http:\/\/www.fatihacar.com\/blog\/resimler\/ifconfig.png 646w, http:\/\/www.fatihacar.com\/blog\/resimler\/ifconfig-150x150.png 150w, http:\/\/www.fatihacar.com\/blog\/resimler\/ifconfig-300x298.png 300w\" sizes=\"auto, (max-width: 646px) 100vw, 646px\" \/><\/p>\n<p>If everything is okey, you can control your database and client connections.<\/p>\n<p>This failover.py script can not comply with your system. You have to make test on your test environment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":37,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9,20,18,97],"tags":[14,32,49,105,104],"class_list":["post-1445","post","type-post","status-publish","format-standard","hentry","category-administration","category-oracle-backup-and-recovery","category-linux-unix","category-python","tag-database-administration","tag-oracle-administration","tag-oracle-backup-and-restore","tag-oracle-data-guard-failover","tag-oracle-failover"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p39NFI-nj","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/1445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/users\/37"}],"replies":[{"embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/comments?post=1445"}],"version-history":[{"count":13,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/1445\/revisions"}],"predecessor-version":[{"id":1469,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/1445\/revisions\/1469"}],"wp:attachment":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/media?parent=1445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/categories?post=1445"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/tags?post=1445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}