ORACLE Automatic startup in LINUX

Source: Internet
Author: User
This article uses the python script to start the oracle database (mainly to start listening and database, excluding dbconsole): Step 1: Close the database, disable listening to preprenamecodeclasssql [oracle @ REDHAT6 ~] $ LsnrctlstopSQLshutdownimmediateSTEP2: Check whether there is any

This article uses the python script to start the oracle database (mainly to start listening and database, excluding dbconsole): Step 1: Close the database, disable listening/prepre name = code class = SQL [oracle @ REDHAT6 ~] $ Lsnrctl stopSQL shutdown immediate STEP2: Check whether there is any

This article uses the python script to start the oracle database (mainly to start the listener and database, excluding the dbconsole ):

Step 1: Disable the database and listener

 
[oracle@REDHAT6 ~]$ lsnrctl stopSQL> shutdown immediate

Step 2: Check whether python-related packages have been installed. (if not, install the packages)

[root@REDHAT6 ~]# which python/usr/bin/python

Step 3: compile a python script to start Related Services

-- Create two files first. One is a python script and the other is a log record [oracle @ REDHAT6 ~] $ Touch oracle. py [oracle @ REDHAT6 ~] $ Touch oracle. log [oracle @ REDHAT6 ~] $ Chmod-r 755 oracle. py

Python script

import commands;import sys;import time;dtime=time.strftime('%Y-%m-%d %H:%I:%M:%S',time.localtime(time.time()));file_append=open('/home/oracle/oracle.log','a+')print>>file_append,dtime,'\n'print>>file_append,'============START LISTENER================\n'(status,output)=commands.getstatusoutput("su - oracle -c '/u01/app/oracle/bin/lsnrctl start' ")print>>file_append,output+'\n'if(status==0):print>>file_append,'============OK: LISTENER START OK=============\n'else:print>>file_append,'============ERROR: LISTENER START ERROR=============\n'print>>file_append,'============START DATABASE================\n'(status,output)=commands.getstatusoutput("su - oracle -c '/u01/app/oracle/bin/dbstart' ")print>>file_append,output,'\n'if(status==0):print>>file_append,'============OK: DATABASE START OK=============\n'else:print>>file_append,'============ERROR: DATABASE START ERROR=======\n'print>>file_append,'\n','\n'file_append.close()

The script starts lsnrctl and then dbstart. lsnrctl is automatically started when dbstart is started. Because I have not configured the environment variable, the listener cannot start when dbstart is started, so I started the listener in python.


Step 4: add the script execution command to startup

[oracle@REDHAT6 ~]$ vi /etc/rc.d/rc.local
Add a line in this file: su-root-c "python/home/oracle. py "some people say they want to change su-root to an oracle user. There is no need to change it here, because I have specified an oracle user in the python script.


The next time you start the machine, you will find that the listener and database programs have been started.


Finally, let's look at the log file.

[oracle@REDHAT6 ~]$ tail -200 /home/oracle/oracle.log

The following is the log for starting the database. A listener error will be reported in it, but we have started the listener first, so ignore it. You can also configure environment variables to start



Reference URL:

Http://blog.csdn.net/my2010sam/article/details/18315785

Http://biancheng.dnbcw.info/python/242105.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.