Wednesday, February 8, 2012

Booting Oracle 11g R2 Database Server on CentOS 6.2

This is a how to autostart the Oracle 11g R2 Database Server on CentOS 6.2. I assume you have done the following:

  1. Install an Oracle-ready CentOS 6.2 Linux box
  2. Install the Oracle 11g R2 Database Server on the CentOS 6.2 Linux box
  3. Configure a network listener for Oracle 11g R2 Database Server on the CentOS 6.2 Linux box
  4. Create a fresh Oracle 11g R2 database on the CentOS 6.2 Linux box 

So, it's time to run the three installed components as Linux daemons. These components are: listener, database and enterprise manager. The main programs concerning the start and stop tasks for these components can be found at $ORACLE_HOME/bin, and they are:

  • listener: lsnrctl {start|stop|...}
  • database: dbstart / dbshut
  • ent. manager: emctl {start|stop|...}


  1. Login as the bozz user (a sudoer)  in the server and create the archive /etc/init.d/oracle with the following content:
  2. #!/bin/bash
    
    # oracle: Start/Stop Oracle Database 11g R2
    #
    # chkconfig: 345 90 10
    # description: The Oracle Database Server is an RDBMS created by Oracle Corporation
    #
    # processname: oracle
    
    . /etc/rc.d/init.d/functions
    
    LOCKFILE=/var/lock/subsys/oracle
    ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1/
    ORACLE_USER=oracle
    
    case "$1" in
    'start')
       if [ -f $LOCKFILE ]; then
          echo $0 already running.
          exit 1
       fi
       echo -n $"Starting Oracle Database:"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
       touch $LOCKFILE
       ;;
    'stop')
       if [ ! -f $LOCKFILE ]; then
          echo $0 already stopping.
          exit 1
       fi
       echo -n $"Stopping Oracle Database:"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
       rm -f $LOCKFILE
       ;;
    'restart')
       $0 stop
       $0 start
       ;;
    'status')
       if [ -f $LOCKFILE ]; then
          echo $0 started.
          else
          echo $0 stopped.
       fi
       ;;
    *)
       echo "Usage: $0 [start|stop|status]"
       exit 1
    esac
    
    exit 0
    
    
  3. First, ensure that the init.d script can be executed manually:
  4. $ sudo chmod +x /etc/init.d/oracle
    $ sudo /etc/init.d/oracle start 
    
    if so, then stop it:
    $ sudo /etc/init.d/oracle stop
    
  5. Use chkconfig to register the init.d script on runlevels 3, 4 and 5:
    $ sudo chkconfig --add oracle
    
    then verify if is marked as on in the runleves 3, 4 and 5:
    $ chkconfig --list oracle
    oracle             0:off    1:off    2:off    3:on    4:on    5:on    6:off
    
  6. Reboot and enjoy!

34 comments:

  1. Dear Eduardo,

    Thank you so much for the articles about installing Oracle!
    It is really helpful tutorial.
    Thanks again!

    ReplyDelete
    Replies
    1. Thanks! Any kind of feedback is appreciated!

      Delete
  2. This worked really well for me too. I appreciate your good work.

    ReplyDelete
    Replies
    1. Thak you very much! Any kind of feedback will be appreciated!

      Delete
  3. Dear Eduardo,

    This is really wonderful. It helped me a lot...I've been struggling on bringing up Oracle, Weblogic in one Linux machine for a while but always got some problems.

    I really appreciate your great work.

    Thanks.

    ReplyDelete
    Replies
    1. I really appreciate all the feedback. Feel free to send any suggestion and/or improvement.
      Regards
      Ed

      Delete
  4. is there a need to modify oratab as well so that this works?
    db01:/usr/oracle/app/product/11.2.0/dbhome_1:Y

    ReplyDelete
    Replies
    1. si es necesario, buena acotaciĆ³n, en el script tampoco es necesario levantar el listener pues este lo hace solo

      Delete
  5. Once again Great instruction thank you so much
    Afshin

    ReplyDelete
  6. this was exactly what I needed! Many thanks for the post.

    ReplyDelete
  7. Hi friends, This is Chandrika from Chennai. Your technical information is really useful for me. Keep update your blog.
    Regards..
    Oracle Training in Chennai

    ReplyDelete
  8. Thanks for sharing your innovative ideas..Its really useful and interesting...

    Regards...

    Salesforce Developer Training in Chennai

    ReplyDelete
  9. I get a lot of great information from this blog. Thank you for your sharing this informative blog. Recently I did PHP course at a leading academy. If you are looking for best PHP Training Institute in Chennai visit FITA IT training academy which offer real timePHP Course in Chennai.

    ReplyDelete
  10. Your blog is really awesome and I got some useful information from your blog. This is really useful for me. Thanks for sharing such a informative blog. Keep posting.

    Regards..
    Cloud Computing Training in Chennai

    ReplyDelete
  11. Java is one of the popular technologies with improved job opportunity for hopeful professionals. Java Training in Chennai helps you to study this technology in details.If you are looking for best Java Training Institutes in Chennai reach Fita academy.

    ReplyDelete
  12. Really awesome blog. Software testing is a method of executing the application or program with the intent of searching the software errors. Testing Training in Chennai offering this course at reasonable cost.





    ReplyDelete
  13. There are lots of information about latest technology and how to get trained in them, like Big Data Training in Chennai have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies(Big Data Training Chennai). By the way you are running a great blog. Thanks for sharing this.

    ReplyDelete
  14. Hi this is Yasmin from Chennai. I am regular contributor of
    your blog. You have done really great job. Thanks for sharing this informative
    post. Keep blogging.
    Regards

    Oracle Apps Training in Chennai | Oracle Apps Training in Chennai

    ReplyDelete
  15. I have finally found a Worth able content to read. The way you have presented information here is quite impressive. I have bookmarked this page for future use. Thanks for sharing content like this once again. Keep sharing content like this.

    Software testing training in chennai | Software testing training | Software testing institute in chennai

    ReplyDelete
  16. Best Java Training Institute In ChennaiThis information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic..

    ReplyDelete
  17. Thanku for sharing sharing about oracle booting..
    SAS Institute introduced the SAS Certified Professional Program,training proper understanding of how the SAS software works. Among the five certification programs that SAS Institute has come up with, SAS training can be considered as the entry point into the big data and the data analytics industry.
    SAS online training in hyderabad

    ReplyDelete
  18. This comment has been removed by the author.

    ReplyDelete
  19. This comment has been removed by the author.

    ReplyDelete
  20. It's beneficial blogs article, and I've never browser on this subject relevant topics content is really well.
    Selenium Training in Chennai
    Selenium Training Course in Chennai

    ReplyDelete
  21. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete