Linux下oracle的启动与关闭(2012-05-20 21:45:39)
一、启动
启动数据库实例,分为两步:第一步,启动监听;第二步,启动数据库实例。
1.进入到sqlplus启动实例
[root@oracle ~]# su - oracle 切换到oracle用户
-bash-3.2$ lsnrctl start 启动监听
LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 20-MAY-2012 15:19:02
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Starting /u01/oracle/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.1.0.6.0 - Production
System parameter file is /u01/oracle/network/admin/listener.ora
Log messages written to /u01/diag/tnslsnr/oracle/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.1.0.6.0 - Production
Start Date 20-MAY-2012 15:19:02
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/network/admin/listener.ora
Listener Log File /u01/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
-bash-3.2$ sqlplus /nolog 进入sqlplus
SQL*Plus: Release 11.1.0.6.0 - Production on Sun May 20 15:20:24 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
SQL> conn /as sysdba 连接到sysdba
Connected to an idle instance.
SQL> startup 启动数据库实例
ORACLE instance started.
Total System Global Area 594251776 bytes
Fixed Size 1301504 bytes
Variable Size 360711168 bytes
Database Buffers 226492416 bytes
Redo Buffers 5746688 bytes
Database mounted.
Database opened.
说明:
数据库启动使用startup命令,有三种情况:
第一种:不带参数,启动数据库实例并打开数据库,以便用户使用数据库,在多数情况下,使用这种方式!
第二种:带nomount参数,只启动数据库实例,但不打开数据库,在你希望创建一个新的数据库时使用,或者在你需要这样的时候使用!
第三种:带mount参数,在进行数据库更名的时候采用。这个时候数据库就打开并可以使用了!
二、关闭
SQL> shutdown immediate 关闭数据库实例
Database closed.
Database dismounted.
ORACLE instance shut down.
说明:
shutdown有四个参数,四个参数的含义如下:
Normal 需要在所有连接用户断开后才执行关闭数据库任务,所以有的时候看起来好象命令没有运行一样!在执行这个命令后不允许新的连接
Immediate 等待用户完成当前的语句,在用户执行完正在执行的语句后就断开用户连接,并不允许新用户连接。
Transactional 等待用户完成当前的事务,在拥护执行完当前事物后断开连接,并不允许新的用户连接数据库。
Abort 不做任何等待,直接关闭数据库,执行强行断开连接并直接关闭数据库。
SQL > exit 退出sqlplus
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-bash-3.2$ lsnrctl stop 关闭监听
LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 20-MAY-2012 15:46:21
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle)(PORT=1521)))
The command completed successfully