Oracle设置(1)设置Oracle数据库为Linux系统服务
将Oracle数据库设为Linux系统服务,并使其能随系统启动和关闭数据库。 1. vi /etc/oratab 将最后一行改为Y. 只有改为Y,Oracle自带的dbstart与dbshut才能起作用。 如: xcldb:/u01/app/oracle/product/11.2.0/db_1:Y 2. 启动脚本文件 vi /etc/rc.d/init.d/orac
将Oracle数据库设为Linux系统服务,并使其能随系统启动和关闭数据库。
1. vi /etc/oratab
将最后一行改为Y. 只有改为Y,Oracle自带的dbstart与dbshut才能起作用。
如:
xcldb:/u01/app/oracle/product/11.2.0/db_1:Y
2. 启动脚本文件
vi /etc/rc.d/init.d/oracle
#!/bin/bash #chkconfig: 2345 20 80 #description: Oracle dbstart/dbshut #/etc/rc.d/init.d/oracle export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 ORACLE_OWNER=oracle LOGFILE=/var/log/oracle.log DATE=`date +%Y-%m-%d` echo "################################">>${LOGFILE} echo "## Run Oracle "${DATE} >> ${LOGFILE} if [! -f ${ORACLE_HOME}"/bin/dbstart" ] || [ ! -f ${ORACLE_HOME}"/bin/dbshut" ]; then echo "ERROR: Missing the script file "${ORACLE_HOME}"/bin/dbstart or "${ORACLE_HOME}"/bin/dbshut!">>${LOGFILE} echo "################################">>${LOGFILE} exit fi start(){ touch /var/lock/subsys/oracle echo "###Startup oracle....." su - ${ORACLE_OWNER} -c ${ORACLE_HOME}"/bin/lsnrctl start" su - ${ORACLE_OWNER} -c ${ORACLE_HOME}"/bin/dbstart "${ORACLE_HOME} echo "###Done" #echo "###Run database control......" #su - ${ORACLE_OWNER} -c ${ORACLE_HOME}"/bin/emctl start dbconsole" echo "###Done" echo "###startup oracle successful....." } stop(){ #echo "###Stop database control......" #su - ${ORACLE_OWNER} -c ${ORACLE_HOME}"/bin/emctl stop dbconsole" echo "###Done" echo "###Shutdown oracle------" su - ${ORACLE_OWNER} -c ${ORACLE_HOME}"/bin/lsnrctl stop" su - ${ORACLE_OWNER} -c ${ORACLE_HOME}"/bin/dbshut "${ORACLE_HOME} echo "###Done" rm -f /var/lock/subsys/oracle echo "###Shutdown oracle successful-------" } case "$1" in 'start') start >> ${LOGFILE} ;; 'stop') stop >> ${LOGFILE} ;; 'restart') stop >> ${LOGFILE} start >> ${LOGFILE} ;; *) echo "Usage:`basename $0` start|stop|restart" exit 1 esac echo "###Finished.">>${LOGFILE} echo "################################">>${LOGFILE} exit 0
3. 将脚本设置为可执行
chmod a+x /etc/rc.d/init.d/oracle
授权后,可手工用下面命令测试前面脚本的正确性:
a. 启动
/etc/rc.d/init.d/oracle start
b. 停止
/etc/rc.d/init.d/oracle stop
c. 重启
/etc/rc.d/init.d/oracle restart
4. 手工添加服务
a.手工添加到chkconfig
chkconfig --add /etc/rc.d/init.d/oracle
b.查看oracle服务的开机启动级别
chkconfig --list oracle 或
chkconfig | grep oracle
#c.修改oracle服务的开机启动级别
#chkconfig --level 24 oracle off
#chkconfig --level 35 oracle on
注意:
如果在启动脚本前不加下面两行,会出现"服务不支持 chkconfig"
#chkconfig: 2345 20 80
#description: Oracle dbstart/dbshut
5. 手工测试服务
service oracle start
service oracle stop
service oracle restart
6.建立连接
a.关机执行
ln -s /etc/init.d/oracle /etc/rc.d/rc0.d/K01oracle
b.重启执行
ln -s /etc/init.d/oracle /etc/rc.d/rc6.d/K01oracle
c.开机执行(Oracle10g以后能自启动了,可以省掉这步)
ln -s /etc/init.d/oracle /etc/rc.d/rc3.d/S99oracle
ln -s /etc/init.d/oracle /etc/rc.d/rc5.d/S99oracle
7.重启测试下
reboot
cat /var/log/oracle.log
备注:
脚本中可以看到,start与stop时,弄了个/var/lock/subsys/oracle。
如果不增加这个文件的处理,在系统关闭时,你会发现stop并没有执行。
原因可以看看>
BLOG: http://blog.csdn.net/xcl168

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)

Installing Git software includes the following steps: Download the installation package and run the installation package to verify the installation configuration Git installation Git Bash (Windows only)
