Search code examples
oraclesphinxunixodbc

Sphinx + Oracle : Data source name not found error


I want to connect to remote oracle database server and index some data from there with sphinx search engine. My OS is ubuntu 16.04 and I havc installed sphinx on it and tested it with local mysql database and everthing was ok (All the data indexed and I could search and results was correct) . I also have installed unixODBC and tested it with isql tool to remote access to oracle database server and every thing was ok, but when I want to index data with indexer command of sphinx this error occure:

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

Here is source block of my sphinx.conf file:

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

}

And odbc.ini file:

[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

and odbcinst.ini file :

[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

Solution

  • Try

    odbc_dsn    = DSN=mydsn;
    

    i.e. w/o spaces around = after the DSN and since you have everything else specified in the ini file just the DNS should be enough. You also need only sql_query out of the rest sql_*. Like this:

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