如何为思考sphinx指定MySQL sock文件位置?

时间:2009-09-07 14:08:36

标签: mysql thinking-sphinx

我的套接字文件位于:

/var/run/mysqld/mysqld.sock

当我这样做时:

rake thinking_sphinx:start

我明白了:

rake aborted!
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

我想告诉think_sphinx我的套接字文件在哪里。这怎么可能?在Slicehost上执行我的切片硬重启后出现此问题。

4 个答案:

答案 0 :(得分:5)

编辑(希望)更清楚:

您可以通过sphinx.conf指定要在sphinx搜索的配置文件sql_sock中使用的mysql套接字:

sql_sock = /var/run/mysqld/mysqld.sock

(请注意,这取决于sql_host设置是否实际使用此值)

您还可以使用thinking_sphinx'配置文件RAILS_ROOT/config/sphinx.yml来设置(覆盖)这些值:

sql_sock: /var/run/mysqld/mysqld.sock

答案 1 :(得分:1)

在版本1.3.20中,套接字路径可以通过database.yml定义,例如

# database.yml
development:
  adapter: mysql
  database: app_name_development
  username: root
  password: 
  socket: /tmp/mysql.sock

现在,thinking-sphinx将使用套接字路径=> /tmp/mysql.sock

答案 2 :(得分:1)

来自边缘sphinx的一些有趣的代码片段,其中指出sphinx 需要 TCP连接。

来自thinking_sphinx / configuration.rb:

def connection
# If you use localhost, MySQL insists on a socket connection, but Sphinx
# requires a TCP connection. Using 127.0.0.1 fixes that.
address = searchd.address || '127.0.0.1'
address = '127.0.0.1' if address == 'localhost'

Mysql2::Client.new(
  :host  => address,
  :port  => searchd.mysql41,
  :flags => Mysql2::Client::MULTI_STATEMENTS
)
end

答案 3 :(得分:0)

ax的答案不起作用。

你可以从提交49f467b25075666104a46b190139dd1bdbb1452f看到有人在SphinxHelper中添加了支持来设置套接字。我没有使用过这种方法,也没有太多时间为你测试它,所以你可以自己使用这种方法。

另外,奇怪的是,在commit http://github.com/freelancing-god/thinking-sphinx/commit/a12dbd55ed9046faf6369a3d0aa452b75a31b5b6中,看起来他们通过database.yml添加了对套接字的支持,但是如果你查看当前的边缘代码,这似乎已被删除了?

简短回答:将你的实际mysqld.sock符号链接到sphinx正在寻找它的位置。

相关问题