Oracle service start and stop scripts and power-on self-boot _linux Linux

Source: Internet
Author: User
Tags reserved stop script centos file permissions sqlplus

After installing Oracle 10g R2 under CentOS 6.3, you will find that Oracle does not start on its own, which is normal, because installing Oracle under Linux does not start on its own, you have to set the relevant parameters yourself, First, let's begin by describing how to launch Oracle in general.

First, start Oracle under Linux

Log on to CentOS, switch to Oracle user rights

# su–oracle

Then enter:

$ sqlplus "/as sysdba"

The original picture will become
Sql>

Next, enter
Sql> Startup

You can start the database normally.

In addition, the instructions for stopping the database are as follows:

sql> shutdown Immediate

Second, check the Oracle DB Listener is normal

Back to Terminal mode, enter:

$ LSNRCTL Status

Check to see if the listener has started

If it is not started, you can enter:

$ lsnrctl Start

Start the Listener

Sql> Conn SYS@ORCL as Sysdba

Then enter the password, sys to log into the database as SYSDBA.

Third, start Emctl

In addition, it can be found that Http://localhost.localdomain:1158/em is currently not responding, this side to start another, start the instructions are as follows:

$ emctl Start Dbconsole

This instruction runs for a long time and finishes the screen as follows:

When you start the Oracle database manually, create a script that starts the system to launch Oracle yourself.

Iv. Oracle Start & Stop Scripts

1. Modify Oracle System Configuration file:/etc/oratab, only in this way, Oracle Dbstart and Dbshut can play a role.

# vi/etc/oratab
orcl:/opt/oracle/102:y

# Entries are of the form:
#  $ORACLE _sid: $ORACLE _home:<n| Y>:

2. Create a file Oracle under/etc/init.d/, which reads as follows:

#!/bin/sh # chkconfig:35 Description:oracle Auto start-stop script.
# Set Ora_home to is 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" E xit fi case "$" in ' Start ') # Start the Oracle Databases:echo ' starting Oracle databases ... "Echo"-------------------------------------------------">>/var/log/oracle date +"%T%a%d:starting Oracle Dat Abases as part of the 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 the system up. ">>/var/log/oracle echo"-------------------------------------------------&G t;>/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/orac

Le 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 List Ener 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/subsy S/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 ') $ stop $ start;;

 Esac

3. Change file permissions

# chmod 755/etc/init.d/oracle

4. Add Service

# chkconfig--level Oracle on

5. Need to stop the database before shutting down or restarting the machine, do the operation

# ln-s/etc/init.d/oracle/etc/rc0.d/k01oracle  //Shutdown
# ln-s/etc/init.d/oracle/etc/rc6.d/k01oracle  

6. How to use

# service Oracle Start//    start Oracle
 # Service Oracle Stop    //close Oracle
 # service Oracle Restart   // Restart Oracle

7. Test

A. Power-on self-starter

Last Login:mon Nov 19:57:06 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 20:07:33 Copyright (c) 1982,%, Oracle.


All rights reserved. Connected to: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-------------------------------------------------------    -----------------------SMITH clerk 7902 17-dec-80 ALLEN salesman 7698 20-feb-81 1600          WARD salesman 7698 22-feb-81 1250 JONES MANAGER 7839 02-apr-81 2975 MARTIN salesman 7698 28-sep-81 1250 1400 BLAKE MANAGER 7839 01-may-81 2850-Clar  K MANAGER 7839 09-jun-81 2450        SCOTT ANALYST 7566 19-apr-87 3000 KING PRESIDENT 17-nov-81 5000-TUR      NER salesman 7698 08-sep-81 1500 0 ADAMS clerk 7788 23-may-87 1100 JAMES Clerk 7698 03-dec-81 950 FORD ANALYST 7566 03-dec-81 3000 MILLER clerk 7782 23-

JAN-82 1300 rows selected.

 Sql>

B. Service Oracle Stop

Sql> disconnected from Oracle Database 10g Enterprise Edition release 10.2.0.1.0-production with the
partitioning , OLAP and Data Mining options
[oracle@ors ~]$ logout
[root@ors ~]# service Oracle Stop
stoping Oracle Listene Rs ... 
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 N OV 20:17:20

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

Connected to a idle instance.

Sql> set linesize;
Sql> set pagesize;
Sql> select * from Scott.emp;
SELECT * FROM scott.emp
*
ERROR in line 1:
ora-01034:oracle not available


sql>

C. Service Oracle Start

Sql> disconnected
[oracle@ors ~]$ logout
[root@ors ~]# service Oracle start
starting Oracle Databases ... 
done
Starting Oracle Listeners 
... Done.
[Root@ors ~]#

D. Service Oracle Restart

[Root@ors ~]# Service Oracle Restart
stoping Oracle Listeners 
... Done.
stoping Oracle Databases 
... Done.

Starting Oracle Databases 
... Done
starting Oracle Listeners 
... Done.
[Root@ors ~]#

At this point, the Oracle service startup & Stop scripts and power-on self boot settings are complete.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

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.