查看oracle是否启动

如何查看Oracle是否启动?

Oracle数据库系统是业界知名的关系型数据库管理系统。它具有高性能、高可靠、高安全等特点。在生产环境中,Oracle数据库是企业级应用的重要组成部分,因此,必须确认Oracle数据库是否启动。下面,我们将详细介绍如何检查Oracle是否启动。

1.使用SQL*Plus工具检查Oracle启动状态

Oracle提供了一个命令行工具SQL*Plus,可以使用它来检查Oracle启动状态。该工具在Oracle的客户端安装包中,可以在命令行中输入以下命令来启动SQL*Plus:

sqlplus / as sysdba

这条命令中,/ 表示以本机认证方式连接数据库,as sysdba 表示以 SYS 连接,以 SYSDBA 角色登录。当然,如果你知道其他用户的用户名和密码,也可以使用其他用户来登录。

如果Oracle已启动,将会出现以下提示:

SQL*Plus: Release 11.2.0.2.0 Production on Wed May 12 14:58:17 2021

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

如果Oracle未启动,将会出现以下提示:

SQL*Plus: Release 11.2.0.2.0 Production on Wed May 12 14:59:09 2021

Copyright (c) 1982, 2010, Oracle. All rights reserved.

ERROR:

ORA-01034: ORACLE not available

ORA-27101: shared memory realm does not exist

Linux-x86_64 Error: 2: No such file or directory

Process ID: 0

Session ID: 0 Serial number: 0

在提示符下,可以执行各种SQL命令,并查看Oracle数据库的状态。例如,可以查询Oracle实例的状态:

SELECT instance_name, status, database_status FROM v$instance;

执行以上语句,如果Oracle已启动,将会输出类似以下结果:

INSTANCE_NAME STATUS DATABASE_STATUS

---------------- ------------ -----------------

orcl OPEN ACTIVE

其中,INSTANCE_NAME 表示实例名,STATUS 表示实例状态,DATABASE_STATUS 表示数据库状态。

如果Oracle未启动,则会出现以下提示:

SQL> SELECT instance_name, status, database_status FROM v$instance;

SELECT instance_name, status, database_status FROM v$instance

*

ERROR at line 1:

ORA-01034: ORACLE not available

Process ID: 0

Session ID: 0 Serial number: 0

2.查看Oracle后台进程

Oracle在启动时,会启动多个进程。这些进程可以通过操作系统的进程管理器进行查看。例如,在Linux系统下,可以使用 ps 命令查看Oracle进程:

ps -ef | grep ora_

如果Oracle已启动,将会输出一组以 ora_ 开头的进程:

oracle 2652 1 0 16:07 ? 00:00:32 ora_dbw0_orcl

oracle 2654 1 0 16:07 ? 00:00:00 ora_psp0_orcl

oracle 2656 1 0 16:07 ? 00:00:03 ora_lgwr_orcl

oracle 2658 1 0 16:07 ? 00:00:49 ora_ckpt_orcl

oracle 2660 1 0 16:07 ? 00:00:00 ora_smon_orcl

oracle 2662 1 0 16:07 ? 00:00:00 ora_reco_orcl

oracle 2664 1 0 16:07 ? 00:00:02 ora_mmon_orcl

oracle 2666 1 0 16:07 ? 00:00:00 ora_mmnl_orcl

oracle 2668 1 0 16:07 ? 00:00:00 ora_d000_orcl

oracle 2670 1 0 16:07 ? 00:00:00 ora_s000_orcl

oracle 2672 1 0 16:07 ? 00:00:00 ora_s001_orcl

oracle 2674 1 0 16:07 ? 00:00:00 ora_s002_orcl

oracle 2676 1 0 16:07 ? 00:00:00 ora_s003_orcl

oracle 2678 1 0 16:07 ? 00:00:00 ora_s004_orcl

oracle 2680 1 0 16:07 ? 00:00:00 ora_s005_orcl

oracle 2682 1 0 16:07 ? 00:00:00 ora_qmnc_orcl

oracle 2684 1 0 16:07 ? 00:00:01 ora_cjq0_orcl

oracle 2686 1 0 16:07 ? 00:00:00 ora_dbrm_orcl

oracle 2688 1 0 16:07 ? 00:00:00 ora_p000_orcl

oracle 2690 1 0 16:07 ? 00:00:00 ora_p001_orcl

oracle 2692 1 0 16:07 ? 00:00:00 ora_p002_orcl

oracle 2694 1 0 16:07 ? 00:00:00 ora_p003_orcl

oracle 2696 1 0 16:07 ? 00:00:00 ora_p004_orcl

oracle 2698 1 0 16:07 ? 00:00:00 ora_p005_orcl

oracle 2700 1 0 16:07 ? 00:00:00 ora_p006_orcl

oracle 2702 1 0 16:07 ? 00:00:00 ora_p007_orcl

oracle 2704 1 0 16:07 ? 00:00:00 ora_p008_orcl

oracle 2706 1 0 16:07 ? 00:00:00 ora_p009_orcl

oracle 2708 1 0 16:07 ? 00:00:00 ora_p010_orcl

oracle 2710 1 0 16:07 ? 00:00:00 ora_p011_orcl

oracle 2712 1 0 16:07 ? 00:00:00 ora_p012_orcl

oracle 2714 1 0 16:07 ? 00:00:00 ora_p013_orcl

oracle 2716 1 0 16:07 ? 00:00:00 ora_p014_orcl

oracle 2718 1 0 16:07 ? 00:00:00 ora_p015_orcl

oracle 2720 1 0 16:07 ? 00:00:00 ora_p016_orcl

oracle 2722 1 0 16:07 ? 00:00:00 ora_p017_orcl

oracle 2724 1 0 16:07 ? 00:00:00 ora_p018_orcl

oracle 2726 1 0 16:07 ? 00:00:00 ora_p019_orcl

oracle 2728 1 0 16:07 ? 00:00:00 ora_p020_orcl

oracle 2730 1 0 16:07 ? 00:00:00 ora_p021_orcl

oracle 2732 1 0 16:07 ? 00:00:00 ora_p022_orcl

oracle 2734 1 0 16:07 ? 00:00:00 ora_p023_orcl

oracle 2736 1 0 16:07 ? 00:00:00 ora_p024_orcl

oracle 2738 1 0 16:07 ? 00:00:00 ora_p025_orcl

oracle 2740 1 0 16:07 ? 00:00:00 ora_p026_orcl

oracle 2742 1 0 16:07 ? 00:00:00 ora_p027_orcl

oracle 2744 1 0 16:07 ? 00:00:00 ora_p028_orcl

oracle 2746 1 0 16:07 ? 00:00:00 ora_p029_orcl

如果Oracle未启动,则不会输出任何进程。

3.查看Oracle监听器状态

Oracle监听器是一个网络服务,用于管理Oracle客户端和服务器之间的通信。在Oracle未启动时,监听器服务将无法启动。因此,我们可以通过检查监听器状态来了解Oracle是否已启动。可以使用 lsnrctl 工具来管理监听器。以下是一个检查监听器状态的例子:

lsnrctl status

如果Oracle已启动,将会输出以下信息:

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 12-MAY-2021 14:05:29

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production

Start Date 12-MAY-2021 13:49:37

Uptime 0 days 0 hr. 15 min. 52 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

Listener Log File /u01/app/oracle/diag/tnslsnr/db11g/listener/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))

Services Summary...

Service "orcl" has 1 instance(s).

Instance "orcl", status READY, has 1 handler(s) for this service...

Service "orclXDB" has 1 instance(s).

Instance "orcl", status READY, has 1 handler(s) for this service...

The command completed successfully

如果Oracle未启动,则会提示无法连接到监听器:

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 12-MAY-2021 14:22:01

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

TNS-12541: TNS:no listener

TNS-12560: TNS:protocol adapter error

TNS-00511: No listener

Linux Error: 111: Connection refused

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))

TNS-12541: TNS:no listener

TNS-12560: TNS:protocol adapter error

TNS-00511: No listener

Linux Error: 111: Connection refused

总结

通过以上介绍,我们可以了解如何检查Oracle是否启动。可以使用SQL*Plus工具、查看Oracle后台进程、查看Oracle监听器状态等方法来验证Oracle的状态。在实际使用中,我们需要及时检查Oracle的状态,以确保其可以正常工作。

免责声明:本文来自互联网,本站所有信息(包括但不限于文字、视频、音频、数据及图表),不保证该信息的准确性、真实性、完整性、有效性、及时性、原创性等,版权归属于原作者,如无意侵犯媒体或个人知识产权,请来电或致函告之,本站将在第一时间处理。猿码集站发布此文目的在于促进信息交流,此文观点与本站立场无关,不承担任何责任。

数据库标签