Ruby on Rails Rake命令导致Oracle TNS错误
我正尝试使用Ruby on Rails Rake命令迁移到Oracle数据库。我database.yml
文件包含以下内容:Ruby on Rails Rake命令导致Oracle TNS错误
development:
adapter: oracle
database: album_development
sid: orc1
username: system
password: root
在我的电脑我已经设置ORACLE_SID=orcl.
当我运行耙,迁移,我得到以下错误:
rake aborted!
The driver encountered an error: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
你能告诉我,如果我需要修改我的listener.ora
文件才能使其工作?我listener.ora
文件如下:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = Lenovo-PC)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
的LSNRCTL status命令的输出如下:
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 32-bit Windows: Version 11.2.0.2.0 - Production
Start Date 21-APR-2016 11:14:15
Uptime 0 days 0 hr. 7 min. 43 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service XE
Listener Parameter File C:\oraclexe\app\oracle\product\11.2.0\server\network\admin\listener.ora
Listener Log File C:\oraclexe\app\oracle\diag\tnslsnr\Lenovo-PC\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lenovo-PC)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=Lenovo-PC)(PORT=8080))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
Instance "xe", status READY, has 1 handler(s) for this service...
Service "xe" has 1 instance(s).
Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully
谁能帮助/提个建议吗?
首先你可以检查数据库是通过使用TNSPING
命令访问
e.g:TNSPING xe
它可能是你用了一个,而不是一个L SID:ORC1应该是SID:ORCL吧?
Kevin, 感谢您的回复。我跑了命令,结果如下;适用于32位Windows的TNS Ping实用程序:版本11.2.0.2.0 - 2016年4月21日的生产时间13:04:16 版权所有(c)1997,2010,Oracle。版权所有。 使用参数文件: C:\ oraclexe \应用\ ORACLE \产品\ 11.2.0 \服务器\网络\管理员\ SQLNET.ORA 用于TNSNAMES适配器来解析别名 试图联系(DESCRIPTION =(ADDRESS =(PROTOCOL = TCP)(HOST = Lenovo-PC)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = XE))) OK(10毫秒) – Sean
如果将database.yml更改为指向xe而不是orcl做到了吗? –
Kevin,
感谢您的帮助。我改变了我的database.yml
到:
development:
adapter: oracle
database: xe
username: system
password: root
这让我连接到数据库。我现在有另一个问题,但我想我可以解决这个问题。亲切的问候,肖恩
你有没有尝试连接到xe而不是orcl例如sid:xe –
是的,我尝试过使用sid:xe它也行不通 – Sean
typo orc1 \ orcl ??? –