Sql加不能连接到oracle

时间:2014-08-23 19:57:22

标签: sql oracle oracle11g

我在Windows7操作系统上安装了Oracle 11g。 这工作正常,但突然间我从Sqlplus连接oracle时遇到错误。

C:\>sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Sun Aug 24 00:14:32 2014

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

Enter user-name: system
Enter password:

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Process ID: 0
Session ID: 0 Serial number: 0

我已将ORACLE_HOME = C:\ app \ product \ 11.2.0 \ dbhome_1和ORACLE_SID设置为orcl。

listener.ora

#Network Configuration File: C:\app\product\11.2.0\dbhome_1\network\admin\listener.ora
#Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = C:\app\product\11.2.0\dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:C:\app\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = C:\app

的tnsnames.ora

# tnsnames.ora Network Configuration File: C:\app\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

UPDATE1

我的init.ora文件:

# Example INIT.ORA file
#
# This file is provided by Oracle Corporation to help you start by providing
# a starting point to customize your RDBMS installation for your site. 
# 
# NOTE: The values that are used in this file are only intended to be used
# as a starting point. You may want to adjust/tune those values to your
# specific hardware and needs. You may also consider using Database
# Configuration Assistant tool (DBCA) to create INIT file and to size your
# initial set of tablespaces based on the user input.
###############################################################################

# Change '<ORACLE_BASE>' to point to the oracle base (the one you specify at
# install time)

db_name='ORCL'
memory_target=1G
processes = 150
audit_file_dest='<ORACLE_BASE>/admin/orcl/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='<ORACLE_BASE>/flash_recovery_area'
db_recovery_file_dest_size=2G
diagnostic_dest='<ORACLE_BASE>'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300 
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files = (ora_control1, ora_control2)
compatible ='11.2.0'

仍然收到错误:

C:\>sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Thu Sep 4 23:17:00 2014

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

SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 1670221824 bytes
Fixed Size                  2176328 bytes
Variable Size            1157630648 bytes
Database Buffers          503316480 bytes
Redo Buffers                7098368 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 1916
Session ID: 5 Serial number: 5


SQL> conn shah
Enter password:
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Process ID: 0
Session ID: 0 Serial number: 0

我感谢有人可以提供帮助。谢谢。

3 个答案:

答案 0 :(得分:0)

C:\> sqlplus /nolog

SQL> conn / as sysdba

SQL> startup

**Database starts**

SQL> conn <<your_user>>

如果数据库没有启动,则init.ora文件出现问题。

祝你好运。

答案 1 :(得分:0)

它有用且知识渊博,希望这在这里也很有用:

http://ora-data.blogspot.com/2016/11/sqlplus-not-connecting-in-oracle.html

[oracle@ebs sqlplus]$ echo $PATH
/usr/lib64/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin

[oracle@ebs sqlplus]$ pwd
/u01/StageR122/oracle/product/11.2.0/dbhome_1/sqlplus

[oracle@ebs sqlplus]$ export PATH=$PATH:/u01/StageR122/oracle/product/11.2.0/dbhome_1/bin/

[oracle@ebs sqlplus]$ sqlplus '/as sysdba'

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jul 11 12:52:30 2016

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

Connected to an idle instance.

SQL&GT;

谢谢,

答案 2 :(得分:0)

确保Windows服务OracleOraDB18Home1TNSListener正在运行。如果它已经在运行,请重新启动OracleOraDB18Home1TNSListener服务。

运行以下shell命令:

sqlplus sys as sysdba
startup

您也可以运行此命令进行检查

sqlplus myUsername/myPassword@localhost

enter image description here