Home Database Mysql Tutorial Oracle 11g 安装成功后在Linux开机利用chkconfig自动启动设置

Oracle 11g 安装成功后在Linux开机利用chkconfig自动启动设置

Jun 07, 2016 pm 05:25 PM

指出3,4,5级别启动这个服务,99是在相应的/etc/rc.d/rcN.d(N为前面指定的级别, 这里是345)目录下生成的链接文件的序号(启动优

注:开始首先需要修改Oracle与root用户的环境变量
 
vi ~/.bash_profle
 
添加如下内容:
 
umask 022
 
export ORACLE_BASE=/home/oracle/app
 
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
 
export ORACLE_SID=orcl
 
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
 
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
 
 
 
一、使用root用户修改/etc/oratab 文件:
$ vi /etc/oratab
orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_1:N
 改为:
orcl:/home/oracle/app/oracle/product/11.2.0/dbhome_1:Y
 
也就是将最后的N改为Y
 

二、使用oracle用户修改$ORACLE_HOME/bin/dbstart文件:
# su - oracle
$ cd $ORACLE_HOME/bin
$ vi dbstart
找到 ORACLE_HOME_LISTNER=.....这行, 修改成
ORACLE_HOME_LISTNER=$ORACLE_HOME 
 同样修改dbshut
 
vi dbshut
 
ORACLE_HOME_LISTNER=$ORACLE_HOME
 

注意:是修改,,不是增加,可是使用vi的查找功能查找:
ORACLE_HOME_LISTNER,然后进行修改,修改后保存
 

三、测试运行 dbshut, dbstart 看能否启动oracle 服务及listener服务:
 
关闭,或者启动时可能会报错,提示dbstart或dbshut权限不足.
 1.修改dbstart和dbshut的日志文件的权限:
$su - root
#cd $ORACLE_HOME
#chown oracle:oinstall $ORACLE_HOME/startup.log
#chown oracle:oinstall $ORACLE_HOME/shutdown.log
#chown oracle:oinstall $ORACLE_HOME/listener.log
 

2.执行相应的脚本进行测试 (可选)
 #su - oracle
$cd $ORACLE_HOME/bin
$./dbstart (./dbshut)
$ ps -efw | grep ora_
$ lsnrctl status
$ ps -efw | grep LISTEN | grep -v grep
 

四:创建服务
$su - root
# cd /etc/rc.d/init.d/
# vi oracle
 
-----脚本-----
 


#!/bin/bash
 


# chkconfig: 345 99 10
 


# description: Startup Script for Oracle Databases   
 


 
 


# /etc/rc.d/init.d/oracle
 


export ORACLE_BASE=/home/oracle/app
 


export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
 
export ORACLE_SID=orcl
 
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
 
ORA_OWNR="oracle"
 
# if the executables do not exist -- display error
 
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
 
then
 
echo "Oracle startup: cannot start"
 
exit 1
 
fi
 
# depending on parameter -- startup, shutdown, restart
 
# of the instance and listener or usage display
 
case "$1" in
 
start)
 
# Oracle listener and instance startup
 
echo -n "Starting Oracle: "
 
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"
 
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
 
touch /var/lock/Oracle
 
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
 
#su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl start"
 
echo "OK"
 
;;
 
stop)
 
# Oracle listener and instance shutdown
 
echo -n "Shutdown Oracle: "
 
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"
 
#su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl stop"
 
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"
 
su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
 
rm -f /var/lock/Oracle
 
echo "OK"
 
;;
 
reload|restart)
 
$0 stop
 
$0 start
 
;;
 
*)
 
echo "Usage: `basename $0` start|stop|restart|reload"
 
exit 1
 
esac
 
exit 0
 
 
 
----若启动成功以下可以略过----
 
五.检查:

根据上面的运行结果,当相应的运行级别为on时(例如:5:on),在对应的/etc/rc.d/rcN.d(例如:和5:on对应的是:/etc /rc.d/rc5.d)下面会生成一个文件:S99oradbstart,使用vi S99oradbstart打开该文件,可以看到该文件的内容和/etc/rc.d/init.d/oradbstart内容相同,表示配置成功,其实,S99oradbstart是一个到/etc/rc.d/init.d/oradbstart的链接,我们可以使用file命令来查看:

$file /etc/rc.d/rc5.d/S99oradbstart

S99oradbstart:symbolic link to '../init.d/oradbstart

六.一点说明:
 
脚本文件中的:# chkconfig: 345 99 10
 
指出3,4,5级别启动这个服务,99是在相应的/etc/rc.d/rcN.d(N为前面指定的级别, 这里是345)目录下生成的链接文件的序号(启动优先级别)S99oradbstart, 10为在除前面指出的级别对应的/etc/rc.d/rcN.d(N为除345之外的级别) 目录生成的链接文件的序号(服务停止的优先级别)K10oradbstart。

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles