Oracle restart, start, stop script under Linux

Source: Internet
Author: User
Tags stop script sqlplus

The site's services were interrupted, the restart found that the Oralce service does not exist, and do not want to restart the machine, restart the next oralce, and then restart the service, buttoned.

Operation of the Oracle9i: (other should also be used to record the following) statement: The firm (should understand oh, the information can not be sent out, you know, use this)

Manual operation

The code is as follows Copy Code

(1) Login to the database as Oracle, command: su–oracle
(2) Enter Sqlplus console, command: Sqlplus/nolog
(3) With the system administrator login, command: Connect/as sysdba
(4) Start database, command: Startup
(5) If the database is closed, command: Shutdown immediate
(6) Exit Sqlplus Console, command: Exit
(7) Enter the firm console, command: LSNRCTL
(8) Start a strong device, (if it has been started without a pipe) command: Start
(9) Exit the firm console, command: Exit
(10) Restart the end of the database

Or

Log on to Linux with root, open the terminal and enter the following command:

CD $ORACLE _home #进入到oracle的安装目录
Dbstart #重启服务器
Lsnrctl Start #重启监听器
CD $ORACLE _home #进入到oracle的安装目录
Dbstart #重启服务器
Lsnrctl Start #重启监听器


You can also use a script to start regularly

Linux boot automatically start Oracle script

#注意: The Oralce command in the example is in the/u01/app/oracle/product/10.2.0/db_1/bin/directory.
#修改ORA_HOME的值为ORACLE的目录.

The code is as follows Copy Code

1.#!/bin/bash
2. #root
3. #chkconfig: 345 51 49
4. #description: Starts the Oracle dabase deamons
5.#
6.ora_home=/u01/app/oracle/product/10.2.0/db_1
7.ora_owner=oracle
8.case "$" in
9. ' Start ')
10.echo-ne "Starting Oracle 11g ... n"
11.su-$ORA _owner-c "$ORA _home/bin/dbstart"
12.echo-e "DONE.N"
13.echo-e "Starting Oracle Listeners ... n"
14.su-$ORA _owner-c "$ORA _home/bin/lsnrctl start"
15.echo-e "DONE.N"
16.su-$ORA _owner-c "$ORA _home/bin/emctl start Dbconsole" #启动web管理界面: Http://host_ip_address:1158/em
17.echo-ne "Input root PASSWORD......N"
18.su-root-c "touch/var/lock/subsys/oracle11g"
19.ECHO-E "n"
20.;;
' Stop ')
22.echo-ne "shutting down Oracle 11g ... n"
23.su-$ORA _owner-c "$ORA _home/bin/dbshut"
24.echo-ne "Dbshut OK!n"
25.su-$ORA _owner-c "$ORA _home/bin/lsnrctl Stop"
26.echo-ne "Lsnrctl stop OK!n"
27.su-$ORA _owner-c "$ORA _home/bin/emctl stop Dbconsole"
#su-root-c "/home/oracle/ufsoft/stop.sh"
29.echo-ne "Input root PASSWORD......N"
30.su-root-c "Rm-f/var/lock/subsys/oracle11g"
31.echo
32.;;
' Restart ')
34.echo-ne "Restarting Oracle 11g ... n"
35.$0 stop
36.$0 start
37.echo
38.;;
39.*)
40.echo "Usage:oracle {Start|stop|restart}"
41.exit 1
42.

43.esac
44.exit 0


============ Create a script called oralce10g ==========

The code is as follows Copy Code
[Root@cwserver ~]# gedit/etc/rc.d/init.d/oracle10g
#复制粘贴本文开头的脚本. Or use the oracle10g file in the attachment directly
#给予执行权限
[Root@cwserver ~]# chmod 755/etc/rc.d/init.d/oracle10g

#注意: The Oralce command in the example is in the/home/oracle/oracle/product/10.2.0/db_1/bin directory.
You can modify your own directory.


============ Add to startup, shutdown, restart service sequence = = =

The code is as follows Copy Code
$ ln-s/etc/rc.d/init.d/oracle10g/etc/rc.d/rc2.d/s99oracle10g
$ ln-s/etc/rc.d/init.d/oracle10g/etc/rc.d/rc3.d/s99oracle10g
$ ln-s/etc/rc.d/init.d/oracle10g/etc/rc.d/rc5.d/s99oracle10g
$ ln-s/etc/rc.d/init.d/oracle10g/etc/rc.d/rc0.d/k01oracle10g
$ ln-s/etc/rc.d/init.d/oracle10g/etc/rc.d/rc6.d/k01oracle10g


============ Add and start viewing services =============================

The code is as follows Copy Code
$/sbin/chkconfig--add/etc/rc.d/init.d/oracle10g
$/sbin/chkconfig--list/etc/rc.d/init.d/oracle10g


============ Modify Oracle System configuration file/etc/oratab=====

  code is as follows copy code
$ gedit/etc/ Oratab
last line changed to:
orcl:/home/oracle/oracle/product/10.2.0/db_1:y
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.