Oracle service in Linux

Source: Internet
Author: User

After several hours, I finally realized why the self-started script could not be successfully executed. It turned out to be a space error. The steps are described as follows:

1. Modify the dbstart and dbshut scripts.

The default dbstart script starts the Oracle service and does not start the listening service. If you want to start the listening service while starting the Oracle service, you must modify the script.

Set the oracle_home_listner value to $ ORACLE_HOME (originally $1)

In the same way as dbshut, if you want to disable the Database Service and disable the listening service, set the oracle_home_listner value in the dbshut file to $ ORACLE_HOME.

2. Create an oracle self-starting script

Because the dbstart and dbshut scripts have been modified, you can directly use this script to enable or disable Oracle services and listeners at the same time, therefore, you only need to call the dbstart or dbshut script to start or close the database. If you do not modify the listener by default, you must add the statement to start or disable the listener in this script.

Su-$ oracle_owner-c "$ ORACLE_HOME/bin/LSNRCTL start" Su-$ oracle_owner-c "$ ORACLE_HOME/bin/LSNRCTL stop"

If you want to enable or disable auto-enable, use the following statement:

Su-$ oracle_owner-c "$ ORACLE_HOME/bin/emctl start dbconsole"

Su-$ oracle_owner-c "$ ORACLE_HOME/bin/emctl stop dbconsole"

 

This script only starts Oracle listening and Oracle services, and has been modified by the dbstart script. The specific script is as follows:

 

#! /Bin/bash

# Whoami

# Root

# Chkconfig: 2345 99 01

#/Etc/init. d/orcl

# Description: starts the Oracle dabase deamons

#

ORACLE_HOME =/oradata/Oracle/112

Oracle_owner = Oracle

Case "$1" in

Start)

Echo-n "Starting orcl :"

Su-$ oracle_owner-c "$ ORACLE_HOME/bin/dbstart"

Touch/var/lock/subsys/orcl

Echo

;;

Stop)

Echo-n "shutting down orcl :"

Su-$ oracle_owner-c "$ ORACLE_HOME/bin/dbshut"

Rm-F/var/lock/subsys/orcl

Echo

;;

Restart)

Echo-n "Restarting orcl :"

$0 stop

$0 start

Echo

;;

*)

Echo "Usage: 'basename $ 0' START | stop | restart"

Esac


Note: The script was copied directly from the Internet, as shown in figure

#! In the/bin/bash statement, there are only two spaces in the front. After copying the sentence directly to the Linux system, it only indicates two spaces (in Linux, there are actually four spaces, in fact, it indicates a line break and a carriage return). Therefore, after copying the space to Linux, remove the Abnormal Space first.

 

3. Grant the execution permission of the self-starting script

Chmod 775/etc/init. d/orcl

4. Add Configuration Service

[Root @ localhost ~] #/Sbin/chkconfig -- add orcl
The orcl service does not support chkconfig.

"The service does not support chkconfig": -- this prompt is because the following two lines must be included before the Oracle self-starting script:
# Chkconfig: 2345 00 01
# Description: Oracle 11G service

If you do not use this command to configure the service, you can also manually create a file link, as shown below:

File Link
Ln-S/etc/init. d/orcl/etc/rc. d/rc2.d/s99orcl
Ln-S/etc/init. d/orcl/etc/rc. d/rc3.d/s99orcl
Ln-S/etc/init. d/orcl/etc/rc. d/rc4.d/s99orcl
Ln-S/etc/init. d/orcl/etc/rc. d/rc5.d/s99orcl
Ln-S/etc/init. d/orcl/etc/rc. d/rc0.d/k01orcl
Ln-S/etc/init. d/orcl/etc/rc. d/rc1.d/k01orcl
Ln-S/etc/init. d/orcl/etc/rc. d/rc6.d/k01orcl

To delete a link, run the following command:

Rm-RF/etc/rc. d/rc2.d/s99orcl
Rm-RF/etc/rc. d/rc3.d/s99orcl
Rm-RF/etc/rc. d/rc4.d/s99orcl
Rm-RF/etc/rc. d/rc5.d/s99orcl
Rm-RF/etc/rc. d/rc0.d/k0orcl
Rm-RF/etc/rc. d/rc1.d/011 orcl
Rm-RF/etc/rc. d/rc6.d/s01orcl

5. Modify the/etc/oratab File

VI/etc/oratab
Oracle_sid: ORACLE_HOME: y -- whether to change the original n to Y

Note: There is no oratab (this file is generated after the following script is executed during Oracle Installation) and the two scripts are re-executed.
/Oradata/orainventory/orainstroot. Sh
/Oradata/Oracle/112/root. Sh

6. test whether the configuration is successful.

Service orcl (Oracle self-launch Script Name) -- used to check whether the configuration is successful. If there is an error, the specific output will be checked and modified according to the output results.

Service orcl start test whether oracle can be started successfully

 

Note:

The second step can be replaced. If you do not create an oracle self-starting script, you can directly add the service statement you want to start in the/etc/rc. d/rc. Local file.

Su-Oracle-c "/oradata/Oracle/112/bin/dbstart"
Su-Oracle-c "/oradata/Oracle/112/bin/emctl start dbconsole"

 

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.