oracle启停

linux下启停oracle
1.打开ssh工具,连接到数据库所在的linux机器。若用户为root,请输入命令“su - oracle”并回车,若要密码,输入密码后并回车,就切换到了oracle用户下。(下为已切换到oracle用户下了)

[root@tqxs tqxs]# su - oracle
上一次登录:一 10月 15 09:56:08 CST 2018pts/0 上
[jddr-ocs@oracle]$

2.关掉oracle的监听进程:命令为“lsnrctl stop”并回车,这时外部没法连接到数据库了。如下有提示关闭成功信息。

[jddr-ocs@oracle]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-OCT-2018 10:32:29
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[jddr-ocs@oracle]$

3.先杀掉所有session,小编用的是命令:“ps -ef|grep $ORACLE_SID|grep -v ora_|grep LOCAL=NO|awk '{print $2}'|xargs kill”也可以用其他办法。然后用sqlplus登录到数据库。命令依次为:“sqlplus /nolog”-“connect / as sysdba” ,最后用命令关闭oracle数据库"shutdown immediate",强制关闭"shutdown abort" 会忽略事务造成数据丢失 。关闭命令的时候需要等待点时间,成功后会有如下的提示。

[jddr-ocs@oracle]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 19 10:34:21 2018
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

4.用命令"exit"退出sqlplus。
然后用命令“lsnrctl start”启动数据库的监听进程。如下提示语句表明启动成功。

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[jddr-ocs@oracle]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 07-APR-2021 09:16:04
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Starting /oracle/product/112/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /oracle/product/112/network/admin/listener.ora
Log messages written to /oracle/diag/tnslsnr/jddr-ocs/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=jddr-ocs)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=jddr-ocs)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date                07-APR-2021 09:16:04
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/product/112/network/admin/listener.ora
Listener Log File         /oracle/diag/tnslsnr/jddr-ocs/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=jddr-ocs)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "issu" has 1 instance(s).
  Instance "issu", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[jddr-ocs@oracle]$

5.和第三步一样,先用sqlplus登录到数据库。
命令依次为:“sqlplus /nolog”-“connect / as sysdba”。然后输入命令“startup”并回车。等待几分钟会出现如下提示信息。
最后用命令“exit”退出sqlplus。

[jddr-ocs@oracle]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 19 10:43:17 2018
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 2.4987E+10 bytes
Fixed Size                  2239936 bytes
Variable Size            9126806080 bytes
Database Buffers         1.5771E+10 bytes
Redo Buffers               87027712 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
[jddr-ocs@oracle]$

注意事项
注意命令不要输入错误。
在关闭数据库的时候要耐心等待一下。
一定要先杀掉所有session哦。

posted @ 2022-07-07 15:16  laity_guan  阅读(461)  评论(0编辑  收藏  举报