一、Oracle数据库启动过程
1. 检查系统环境变量是否正确设置,可以使用export命令或source命令进行环境变量的设置。
2. 检查Oracle数据库实例的监听程序是否启动,在Linux系统中使用lsnrctl status命令检查,如果没有启动需要手动启动监听程序(lsnrctl start)。
3. 使用oracle用户登录数据库,可以使用su命令切换到oracle用户,然后使用sqlplus命令登录数据库,例如:sqlplus [username]/[password]@[database].
4. 在数据库中执行启动脚本,可以使用startup命令启动Oracle数据库实例,例如:startup.
5. 检查Oracle数据库是否成功启动,可以使用ps命令或者检查alert日志文件,例如:查看pmon进程是否存在,或查看alert日志文件是否在数据库启动后有输出。
示例1:启动Oracle数据库实例命令及结果展示
$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 02-DEC-2021 16:20:36
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 02-DEC-2021 15:48:31
Uptime 0 days 0 hr. 32 min. 4 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost)(PORT=5500))(Security=(my_wallet_directory=/opt/oracle/admin/ORCL/xdb_wallet))(Presentation=HTTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost)(PORT=5500))(Security=(my_wallet_directory=/opt/oracle/admin/ORCL/xdb_wallet))(Presentation=FTP)(Session=RAW))
Services Summary...
Service "ORCLCDB" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
Service "ORCLPDDB" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
Service "ORCLPDB1" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
Service "ORCLPDB2" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
The command completed successfully.
$ sqlplus system/password@ORCLCDB
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Dec 2 16:24:00 2021
Version 19.8.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Thu Dec 02 2021 16:22:39 +08:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.8.0.0.0
SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 9177184 bytes
Variable Size 105696720 bytes
Database Buffers 58720256 bytes
Redo Buffers 7872512 bytes
Database mounted.
Database opened.
SQL> exit
二、Oracle数据库关闭过程
1. 使用oracle用户登录数据库,可以使用su命令切换到oracle用户,然后使用sqlplus命令登录数据库,例如:sqlplus [username]/[password]@[database].
2. 如果连接了多个实例,需要先关闭非当前会话的实例,可以使用alter system命令关闭非当前会话实例,例如:alter system kill session ‘sid,serial#’ immediate.
3. 使用shutdown命令关闭Oracle数据库实例,可以使用shutdown命令,例如:shutdown immediate.
4. 检查Oracle数据库是否成功关闭,可以使用ps命令或者检查alert日志文件,例如:查看pmon进程是否存在,或查看alert日志文件是否在数据库关闭后有输出。
示例2:关闭Oracle数据库实例命令及结果展示
$ sqlplus system/password@ORCLCDB
SQL*Plus: Release 19.0.0.0.0 - Production on Thu Dec 2 16:24:00 2021
Version 19.8.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Last Successful login time: Thu Dec 02 2021 16:22:39 +08:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.8.0.0.0
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
总结:
以上是Oracle数据库的启动和关闭过程,这里提供了基本命令的使用方法,包括展示了两个示例供学习参考。在实际操作中应根据实际情况来选择合适的命令和操作方式,以保证数据库的正常启动和关闭。
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:深刻理解Oracle数据库的启动和关闭 - Python技术站