{"id":81,"date":"2014-02-02T10:07:00","date_gmt":"2014-02-02T12:07:00","guid":{"rendered":"http:\/\/maxoracle.com\/2014\/02\/02\/automatically-startup-the-database-when-oracle-linux-starts\/"},"modified":"2014-02-02T10:07:00","modified_gmt":"2014-02-02T12:07:00","slug":"automatically-startup-the-database-when-oracle-linux-starts","status":"publish","type":"post","link":"https:\/\/www.soudba.com.br\/?p=81","title":{"rendered":"Automatically startup the database when Oracle Linux Starts"},"content":{"rendered":"<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">To make a startup of Oracle database automatically please follow these steps.<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">1. First of all we\u2019ve to change our&nbsp;<strong>\/etc\/oratab<\/strong>&nbsp;file. This file have some hints like, database name, Oracle home, and start or not &#8211; N\/Y<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\"><em style=\"font-size:10.944000244141px;line-height:1.5em;\">orcl:\/home\/oracle\/product\/10.2.0\/Db_1:N<\/em><\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">The first field is the name of my database (<strong>orcl<\/strong>), the second one is my home directory (<strong>\/home\/oracle\/product\/10.2.0\/Db_1<\/strong><em>)<\/em>, and the third indicates to the dbstart utility whether the database should, or should not be brough up at the system boot time with \u201cY\u201d or \u201cN\u201d parameters respectively<br \/>As a root user, we\u2019ll change last field of this line from \u201cN\u201d to \u201cY\u201d to let dbstart utility start this database when it runs<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">2. This need to put one file dbora in&nbsp;<strong>\/etc\/init.d\/<\/strong>&nbsp;directory. In this script, we\u2019ll define two variables,&nbsp;<em>ORA_OWNER<\/em>and&nbsp;<em>ORACLE_HOME<\/em>&nbsp;and then, we\u2019ll start (or shutdown) our database by connecting with oracle user and running lsnrctl (Listener utility), dbstart (utility which starts the database) and dbshut (utility which shutdowns the database) utilities depending on our OS state.<br \/>This is the source of our dbora file:<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\"><strong><span style=\"color:red;\">ORACLE_HOME=\/home\/oracle\/product\/10.2.0\/Db_1<br \/>ORA_OWNER=oracle<\/span><\/strong><\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\"><strong><span style=\"color:red;\">case \u201c$1\u2033 in<br \/>&nbsp;\u2019start\u2019)&nbsp; #If the system is starting, then \u2026<br \/>su \u2013 $ORA_OWNER -c \u201c$ORACLE_HOME\/bin\/lsnrctl start\u201d #Start the listener<br \/>su \u2013 $ORA_OWNER -c \u201c$ORACLE_HOME\/bin\/dbstart #Start the database<br \/>&nbsp; ;;<\/span><\/strong><\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\"><strong><span style=\"color:red;\">\u2018stop\u2019)&nbsp;&nbsp; #If the system is stops, that is we\u2019re shutting down our OS, then \u2026<br \/>&nbsp; su -$ORA_OWNER -c $ORACLE_HOME\/bin\/dbshut<br \/>&nbsp; su -$ORA_OWNER -c \u201c$ORACLE_HOME\/bin\/lsnrctl stop\u201d<br \/>&nbsp; ;;<br \/>esac<\/span><\/strong><\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">3. Once you\u2019ve saved your file into this directory, make sure that it\u2019s executable by running:<br \/>chmod 750 &nbsp;<span style=\"font-size:10.944000244141px;line-height:16.416000366211px;\">dbora<\/span><\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">4. Then you need to add the appropriate symbolic links to cause the script to be executed when the system goes down, or comes up. Create it with ln -s command.<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\"><strong># ln -s \/etc\/init.d\/dbora \/etc\/rc.d\/rc3.d\/K01dbora<br \/># ln -s \/etc\/init.d\/<\/strong><strong style=\"font-size:10.944000244141px;line-height:16.416000366211px;\">dbora<\/strong><strong>&nbsp;\/etc\/rc.d\/rc3.d\/S99<\/strong><strong style=\"font-size:10.944000244141px;line-height:16.416000366211px;\">dbora<\/strong><strong><br \/># ln -s \/etc\/init.d\/<\/strong><strong style=\"font-size:10.944000244141px;line-height:16.416000366211px;\">dbora<\/strong><strong>&nbsp;\/etc\/rc.d\/rc5.d\/K01<\/strong><strong style=\"font-size:10.944000244141px;line-height:16.416000366211px;\">dbora<\/strong><strong><br \/># ln -s \/etc\/init.d\/<\/strong><strong style=\"font-size:10.944000244141px;line-height:16.416000366211px;\">dbora<\/strong><strong>&nbsp;\/etc\/rc.d\/rc5.d\/S99<\/strong><strong style=\"background-color:transparent;font-size:10.944000244141px;line-height:16.416000366211px;\">dbora<\/strong><\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">Let\u2019s analyze these commands:<br \/>The first line creates symbolic link of our script in rc3.d directory. At startup, Linux runs \/etc\/rc.d\/rc script at the current level (normally 3 or 5). rc3.d indicates 3rd runlevel, \u201cK\u201d indicates OS\u2019s shutdown (on servers shutdown, Linux calls the scripts in \/etc\/rc.d\/rc3\/K* in order)<br \/>The second line creates another symbolic link of our script, to be run at startup of our OS, indicating \u201cS99\u2033 and the name of our script<br \/>Another two lines creates symoblic links for 5th runlevel.<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">That\u2019s all. Your script and your service is ready for use. Just restart your OS and upon startup you\u2019ll see your newly created service running. Then open new terminal, enter you database and issue :<br \/>SQL&gt;SELECT status FROM v$instance;<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">You\u2019ll see your database\u2019s status is OPEN<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">P.S<br \/>In some releases, even when we create a new service, it doesn\u2019t work. When we issue dbstart command manually from OS, we\u2019re getting an error:<br \/>cat: \/var\/opt\/oracle\/oratab: No such file or directory<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">It has simple reason and solution<br \/>If the directory \/var\/opt\/oracle exists during the Oracle installation the dbhome script will have the parameter ORATAB set to \u201c\/var\/opt\/oracle\/oratab\u201d instead of \u201c\/etc\/oratab\u201d. The normal DBCA process during a default installation will still add the instance entry to \/etc\/oratab.<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">It has two solutions:<br \/>1. You can either copy the original oratab file to this directory :<br \/>cp \/etc\/oratab \/var\/opt\/oracle\/<\/div>\n<div style=\"background-color:#fafcff;color:#2a2a2a;font-family:Verdana, Tahoma, Arial, sans-serif;font-size:10.944000244141px;line-height:1.5em;margin-bottom:15px;padding:0;\">2. Or you can edit dbstart and dbshut scripts, find the variable ORATAB, and you\u2019ll find that it\u2019s addressing to&nbsp; \/var\/opt\/oracle\/oratab file. Jus<br \/>\nt change it to \/etc\/oratab<\/div>\n","protected":false},"excerpt":{"rendered":"<p>To make a startup of Oracle database automatically please follow these steps. 1. First of all we\u2019ve to change our&nbsp;\/etc\/oratab&nbsp;file. This file have some hints like, database name, Oracle home, and start or not &#8211; N\/Y orcl:\/home\/oracle\/product\/10.2.0\/Db_1:N The first field &hellip; <a href=\"https:\/\/www.soudba.com.br\/?p=81\">Continue lendo <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-sem-categoria"],"_links":{"self":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=81"}],"version-history":[{"count":0,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.soudba.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}