报错:
[oracle@localhost ~]$ sqlplus sys/password
SQL*Plus: Release 12.1.0.2.0 Production on Tue Mar 3 09:59:53 2020
Copyright (c) 1982, 2014, 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
Additional information: 3640
Additional information: 1371676159
Process ID: 0
Session ID: 0 Serial number: 0
1.查询得知,由于Oracle服务未启动导致,
但启动服务后继续报错
SQL> startup
SP2-0640: Not connected
2.首先查看监听服务已经启动成功
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 03-MAR-2020 10:20:44
Uptime 0 days 0 hr. 1 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
3.检查环境变量配置,发现~/.bash_profile和listener.ora里的ORACLE_SID不一样,修改一致后重启监听继续无效,后来发现需要先source ~/.bash_profile
文件使之生效;
再次重启监听后,访问成功
[oracle@localhost ~]$ sqlplus /nolog
SQL*Plus: Release 12.1.0.2.0 Production on Tue Mar 3 10:21:54 2020
Copyright (c) 1982, 2014, Oracle. All rights reserved.
SQL> conn sys/password as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 511705088 bytes
Fixed Size 2926176 bytes
Variable Size 377489824 bytes
Database Buffers 125829120 bytes
Redo Buffers 5459968 bytes
Database mounted.
Database opened.