Chinaunix首页 | 论坛 | 博客
  • 博客访问: 103670842
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Oracle

2008-04-06 10:59:05

作者: dwillin  出自:
今天连接数据库时出了错,监听启动正常,/ 下启动数据库也正常,用sys连接时提示出错,

数据库名是oradb,sid是oradb:

$lsnrctl start

提示:成功!

$sqlplus "/ as sysdba"

sql>startup

提示:成功!

sql>conn sys/oracle@oradb as sysdba;

报错:

ORA-12514: TNS:listener could not resolve SERVICE_NAME given in connect

descriptor!

我是这样解决的:以root身份登录,查看/oracle/product/9.2.0.4/network/admin目录

下的

listener.ora和tnsnames.ora两个配置文件的配置是否正确。

$vi tnsnames.ora

oradb =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.101)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl.oradb.localdomain)
)
)
修改SERVICE_NAME = orcl.oradb.localdomain为SERVICE_NAME = oradb

保存退出

$vi listener.ora

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =(PROTOCOL=TCP)(HOST=192.168.0.101)(PORT= 1521))
)
(ADDRESS_LIST =
(ADDRESS =(PROTOCOL=IPC)(KEY=EXTPROC))
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/u01/app/oracle/product/9.2.0.4)
(PROGRAM = extproc)
)
)
在SID_LIST_LISTENER 中增加下列内容:
(SID_DESC =
(GLOBAL_DBNAME = oradb)
(ORACLE_HOME = /opt/u01/app/oracle/product/9.2.0.4)
(SID_NAME = oradb)
)

完整的listener.ora的内容是:

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.101)(PORT = 1521))
)
)
)

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/u01/app/oracle/product/9.2.0.4)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = oradb)
(ORACLE_HOME = /opt/u01/app/oracle/product/9.2.0.4)
(SID_NAME = oradb)
)
)

再以oracle身份登录,启动监听和数据库,连接数据库都正常了。
阅读(216) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~