1. 程式人生 > >linux下oracle11g R2的啟動與關閉監聽、數據庫

linux下oracle11g R2的啟動與關閉監聽、數據庫

source app var copy time lac started success let

一、啟動監聽與數據庫

1、啟動監聽:

[html] view plain copy
  1. [[email protected] oracle]# su - oracle
  2. bash-4.1$ lsnrctl start

說明:

su後面追加 -,-l,--login,表示切換用戶時,使環境變量(home,shell,user,logname,path等)和欲切換的用戶相同、

結果如下,則啟動成功:

[html] view plain copy
  1. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 04-APR-2014 16:15:25
  2. Copyright (c) 1991, 2009, Oracle. All rights reserved.
  3. Starting /home/oracle/product/11.2/db_1/bin/tnslsnr: please wait...
  4. TNSLSNR for Linux: Version 11.2.0.1.0 - Production
  5. System parameter file is /home/oracle/product/11.2/db_1/network/admin/listener.ora
  6. Log messages written to /home/oracle/diag/tnslsnr/JTWF/listener/alert/log.xml
  7. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=JTWF)(PORT=1521)))
  8. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=JTWF)(PORT=1521)))
  9. STATUS of the LISTENER
  10. ------------------------
  11. Alias LISTENER
  12. Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
  13. Start Date 04-APR-2014 16:15:25
  14. Uptime 0 days 0 hr. 0 min. 0 sec
  15. Trace Level off
  16. Security ON: Local OS Authentication
  17. SNMP OFF
  18. Listener Parameter File /home/oracle/product/11.2/db_1/network/admin/listener.ora
  19. Listener Log File /home/oracle/diag/tnslsnr/JTWF/listener/alert/log.xml
  20. Listening Endpoints Summary...
  21. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=JTWF)(PORT=1521)))
  22. The listener supports no services
  23. The command completed successfully


2、啟動數據庫:

連接到sqlplus

[html] view plain copy
  1. su oracle
  2. bash-4.1$ sqlplus /nolog


結果如下:


[html] view plain copy
  1. SQL*Plus: Release 11.2.0.1.0 Production on Fri Apr 4 16:15:52 2014
  2. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  3. SQL>

以sysdba登陸,並執行命令startup

[html] view plain copy
  1. SQL> conn /as sysdba
  2. Connected to an idle instance.
  3. SQL> startup

結果如下:

[html] view plain copy
  1. ORACLE instance started.
  2. Total System Global Area 839282688 bytes
  3. Fixed Size 2217992 bytes
  4. Variable Size 578815992 bytes
  5. Database Buffers 251658240 bytes
  6. Redo Buffers 6590464 bytes
  7. Database mounted.
  8. Database opened.
  9. SQL>


二、關閉數據庫、監聽

1、關閉數據庫

[html] view plain copy
  1. su - oracle
  2. [[email protected] oracle]# su oracle
  3. bash-4.1$ sqlplus /nolog

登陸sqlplus,結果如下:

[html] view plain copy
  1. SQL*Plus: Release 11.2.0.1.0 Production on Fri Apr 4 15:10:59 2014
  2. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  3. SQL>


sysdba登陸:

[html] view plain copy
  1. SQL>conn /as sysdba
  2. Connected.


關閉數據庫:

[html] view plain copy
  1. SQL> shutdown immediate
  2. Database closed.
  3. Database dismounted.
  4. ORACLE instance shut down.


關閉數據庫後,若執行查詢命令, 則會報如下錯誤:

[html] view plain copy
  1. SQL> select * from vio_business_request;
  2. select * from vio_business_request
  3. *
  4. ERROR at line 1:
  5. ORA-01034: ORACLE not available
  6. Process ID: 14138
  7. Session ID: 75 Serial number: 503
  8. SQL>



退出sqlplus:

[html] view plain copy
  1. SQL> exit
  2. Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
  3. With the Partitioning, OLAP, Data Mining and Real Application Testing options


2、關閉監聽:


[html] view plain copy
    1. bash-4.1$ lsnrctl stop // oracle用戶下執行
    2. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 04-APR-2014 15:17:00
    3. Copyright (c) 1991, 2009, Oracle. All rights reserved.
    4. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=JTWF)(PORT=1521)))
    5. The command completed successfullybash-4.1$ lsnrctl stop
    6. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 04-APR-2014 15:17:00
    7. Copyright (c) 1991, 2009, Oracle. All rights reserved.
    8. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=JTWF)(PORT=1521)))
    9. The command completed successfully

linux下oracle11g R2的啟動與關閉監聽、數據庫