Sphinx + Oracle:未找到数据源名称错误

时间:2018-04-23 06:58:48

标签: oracle sphinx unixodbc

我想连接到远程oracle数据库服务器并使用sphinx搜索引擎从那里索引一些数据。我的操作系统是ubuntu 16.04,我已经安装了sphinx并使用本地mysql数据库进行了测试,并且 everthing还可以(所有数据都已编入索引,我可以搜索并且结果是正确的)。我还安装了unixODBC,并使用isql工具对其进行远程访问oracle数据库服务器和一切正常进行测试,但是当我想用sphinx的 indexer 命令对数据进行索引时发生此错误:

sql_connect: [unixODBC][Driver Manager]Data source name not found, and no default driver specified

这是我的sphinx.conf文件的源块:

source src2
{
  type  = odbc
  sql_host = hostName
  sql_user = user
  sql_pass = pass
  sql_db  = dbname
  sql_port = 1521
  odbc_dsn    = DSN = mydsn; Driver={Oracle};Dbq=hostname:1521/dbname;Uid=user;Pwd=pass
  sql_query     = \
  SELECT tableId, Name \
  FROM sampleTable

}

和odbc.ini文件:

[mydsn]
Application Attributes = T
Attributes = W
BatchAutocommitMode = IfAllSuccessful
BindAsFLOAT = F
CloseCursor = F
DisableDPM = F
DisableMTS = T
Driver = Oracle
DSN = mydsn
EXECSchemaOpt =
EXECSyntax = T
Failover = T
FailoverDelay = 10
FailoverRetryCount = 10
FetchBufferSize = 64000
ForceWCHAR = F
Lobs = T
Longs = T
MaxLargeData = 0
MetadataIdDefault = F
QueryTimeout = T
ResultSets = T
ServerName = MYDATABASE
SQLGetData extensions = F
Translation DLL =
Translation Option = 0
DisableRULEHint = T
UserID = user
Password = pass
StatementCache=F
CacheBufferSize=20
UseOCIDescribeAny=F
SQLTranslateErrors=F
MaxTokenSize=8192
AggregateSQLType=FLOAT

和odbcinst.ini文件:

[Oracle]
Description= ODBC for Oracle
Driver  = /opt/oracle/instantclient_12_2/libsqora.so.12.1
Setup  =
FileUsage = 1
CPTimeout =
CPReuse = /usr/local/etc/odbcinst.ini

1 个答案:

答案 0 :(得分:2)

尝试

odbc_dsn    = DSN=mydsn;

即。没有在DSN之后的空间=并且由于你在ini文件中指定了其他所有内容,因此DNS就足够了。其他sql_ *中也只需要sql_query。像这样:

source src2
{
  type = odbc
  odbc_dsn    = DSN=mydsn;
  sql_query     = \
  SELECT tableId, Name \
  FROM sampleTable
}