Linux Oracle service startup & stop script and Automatic startup

Source: Internet
Author: User
Tags stop script

After installing Oracle 10g R2 in centos 6.3 and restarting it, you will find that Oracle is not started on your own. This is normal because Oracle Installation in Linux does not start on your own, you must set relevant parameters. First, we will introduce how to start oracle.

1. Start oracle in Linux

Log on to centos and switch to Oracle user permissions.

# Su-Oracle

Enter:

$ Sqlplus "/As sysdba"

The original image will become
SQL>

Enter
SQL> startup

You can start the database normally.

In addition, the command to stop the database is as follows:
SQL> shutdown immediate

2. Check whether the Oracle DB listener is normal

Return to Terminal Mode and enter:

$ LSNRCTL status

Check to see if the listener is started

If it is not started, enter:

$ LSNRCTL start

Start listener

SQL> conn sys @ orcl as sysdba

Then enter the password and SYS will log on to the database as sysdba.

Iii. Start emctl

In addition, we can also find that http://localhost.localdomain: 1158/EM is currently no response, here to start another, the startup command is as follows:

$ Emctl start dbconsole

The command runs for a long time. The execution result is as follows:

After you manually start the Oracle database, create a script for the system to start oracle.

4. Oracle startup and stop scripts

1. Modify the Oracle system configuration file:/etc/oratab. Only in this way can dbstart and dbshut of Oracle be used.

# Vi/etc/oratab
Orcl:/opt/Oracle/102: Y

# Entries are of the form:
# $ Oracle_sid: $ ORACLE_HOME: <n | Y>:

2. Create the file Oracle under/etc/init. d/. The content is as follows:

#! /Bin/ Sh  # Chkconfig:  35   80   10  # Description: Oracle Auto Start - Stop script. # Set ora_home to be equivalent to the $ ORACLE_HOME # From  Which  You wish to execute dbstart and dbshut; # Set ora_owner to the user  ID Of the owner of the # Oracle Database  In  Ora_home.ora_home = /Opt/Oracle/  102  Ora_owner = Oracle  If [! -F $ ora_home/bin/ Dbstart]  Then      Echo   "  Oracle startup: cannot start  "  Exit Fi  Case   "  $1  "   In  '  Start  '  ) # Start the Oracle databases:  Echo   "  Starting Oracle databases...  "  Echo   " -------------------------------------------------  " >/Var/log/ Oracle  Date + "  % T % A % d: Starting Oracle databases as part of system up.  " >/Var/log/ Oracle  Echo   "  -------------------------------------------------  " >/Var/log/ Oracle Su -$ Ora_owner-C "  $ Ora_home/bin/dbstart  " >/Var/log/ Oracle  Echo   "  Done  "  # Start the listener:  Echo   "  Starting Oracle listeners...  "  Echo   " -------------------------------------------------  " >/Var/log/ Oracle  Date + "  % T % A % d: Starting Oracle listeners as part of system up.  " >/Var/log/ Oracle  Echo   "  -------------------------------------------------  " >/Var/log/ Oracle Su -$ Ora_owner-C "  $ Ora_home/bin/LSNRCTL start  " >/Var/log/ Oracle  Echo   "  Done.  "  Echo   "  -------------------------------------------------  " >/Var/log/ Oracle  Date +"  % T % A % d: finished.  " >/Var/log/ Oracle  Echo   "  -------------------------------------------------  " >/Var/log/ Oracle  Touch /Var/lock/subsys/ Oracle ;;  '  Stop  ' ) # Stop the Oracle listener:  Echo   "  Stoping Oracle listeners...  "  Echo   "  -------------------------------------------------  " >/Var/log/ Oracle  Date + "  % T % A % d: stoping Oracle listener as part of system down.  " >/Var/log/Oracle  Echo   "  -------------------------------------------------  " >/Var/log/ Oracle  Su -$ Ora_owner-C "  $ Ora_home/bin/LSNRCTL stop  " >/Var/log/ Oracle  Echo   "  Done.  " Rm -F/var/lock/subsys/ Oracle # Stop the Oracle database:  Echo   "  Stoping Oracle databases...  "  Echo   "  -------------------------------------------------  " >/Var/log/ Oracle  Date + "  % T % A % d: stoping Oracle databases as part of system down. " >/Var/log/ Oracle  Echo   "  -------------------------------------------------  " >/Var/log/ Oracle  Su -$ Ora_owner-C "  $ Ora_home/bin/dbshut  " >/Var/log/ Oracle  Echo   " Done.  "  Echo   ""  Echo   "  -------------------------------------------------  " >/Var/log/ Oracle  Date + "  % T % A % d: finished.  " >/Var/log/ Oracle  Echo  "  -------------------------------------------------  " >/Var/log/ Oracle ;;  '  Restart  '  ) $  0  Stop $  0  Start ;;  Esac 

3. Change File Permissions
# Chmod 755/etc/init. d/Oracle

4. Add a service
# Chkconfig -- level 35 oracle on

5. You need to stop the database before shutting down or restarting the machine.
# Ln-S/etc/init. d/Oracle/etc/rc0.d/k01oracle // Shutdown
# Ln-S/etc/init. d/Oracle/etc/rc6.d/k01oracle // restart

6. Usage
# Service Oracle start // start Oracle
# Service Oracle stop // close Oracle
# Service Oracle restart // restart Oracle

7. Test

A. Auto Start

Last login: Mon Nov 26 19:57:06 2012 from 10.0.0.145
[Root @ ors ~] # Su-Oracle
[Oracle @ ors ~] $ Sqlplus "/As sysdba"

SQL * Plus: Release 10.2.0.1.0-production on Mon Nov 26 20:07:33 2012

Copyright (c) 1982,200 5, Oracle. All rights reserved.


Connected:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-Production
With the partitioning, OLAP and Data Mining options

SQL> set linesize 300;
SQL> set pagesize 30;
SQL> select * from Scott. EMP;

Empno ename job Mgr hiredate Sal comm deptno
------------------------------------------------------------------------------
7369 Smith clerk 7902 17-dec-80 800 20
7499 Allen salesman 7698 20-feb-81 1600 300 30
7521 ward salesman 7698 22-feb-81 1250 500 30
7566 Jones manager 7839 02-apr-81 2975 20
7654 Martin salesman 7698 28-sep-81 1250 1400 30
7698 Blake manager 7839 01-may-81 2850 30
7782 Clark manager 7839 09-jun-81 2450 10
7788 Scott analyst 7566 19-apr-87 3000 20
7839 King President 17-nov-81 5000 10
7844 Turner salesman 7698 08-sep-81 1500 0 30
7876 Adams clerk 7788 23-may-87 1100 20
7900 James Clerk 7698 03-dec-81 950 30
7902 Ford analyst 7566 03-dec-81 3000 20
7934 Miller clerk 7782 23-Jan-82 1300 10

14 rows selected.

SQL>

B. Service Oracle stop

SQL> disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-productionwith the partitioning, OLAP and Data Mining options [Oracle @ ors ~] $ Logout [root @ ors ~] # Service Oracle stopstopstoping Oracle listeners... done. stoping Oracle databases... done. [root @ ors ~] # Su-Oracle [Oracle @ ors ~] $ Sqlplus "/As sysdba" SQL * Plus: Release 10.2.0.1.0-production on Mon Nov 26 20:17:20 2012 copyright (c) 1982,200 5, Oracle. all rights reserved. connected to an idle instance. SQL> set linesize 300; SQL> set pagesize 30; SQL> select * from Scott. EMP; select * from Scott. EMP * error at line 1: ORA-01034: Oracle not availablesql>

C. Service Oracle start

SQL> disconnected [Oracle @ ors ~] $ Logout [root @ ors ~] # Service Oracle startstarting Oracle databases... donestarting Oracle listeners... done. [root @ ors ~] #

D. Service Oracle restart

 
[Root @ ors ~] # Service Oracle restartstoping Oracle listeners... done. stoping Oracle databases... done. Starting Oracle databases... donestarting Oracle listeners... done. [root @ ors ~] #

Now, the script for starting and stopping the Oracle service and the auto-starting setting for starting the Oracle service are complete.

 

Install Oracle 10g R2 in centos 6.3 (x32)

Http://www.cnblogs.com/mchina/archive/2012/11/06/2737472.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.