linux下启停oracle


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

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

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

[oracle@tqxs ~]$ 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
[oracle@tqxs ~]$

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" 会忽略事务造成数据丢失 。关闭命令的时候需要等待点时间,成功后会有如下的提示。

[oracle@tqxs ~]$ 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
[oracle@tqxs ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 19-OCT-2018 10:42:05

Copyright (c) 1991, 2013, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/tqxs/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.23.1.127)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                19-OCT-2018 10:42:05
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/tqxs/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.23.1.127)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@tqxs ~]$

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

[oracle@tqxs ~]$ 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 4.0086E+10 bytes
Fixed Size            2261848 bytes
Variable Size         4160752808 bytes
Database Buffers     3.5836E+10 bytes
Redo Buffers           86405120 bytes
Database mounted.
Database opened.
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
[oracle@tqxs ~]$

 

注意事项 

  • 注意命令不要输入错误。

  •  在关闭数据库的时候要耐心等待一下。

  •  一定要先杀掉所有session哦。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM