我的套接字文件位于此处:
/var/run/mysqld/mysqld.sock
当我做:
rake thinking_sphinx:start
我得到:
rake aborted!
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
我想告诉 thinking_sphinx 我的套接字文件在哪里。这怎么可能?在 Slicehost 上对我的切片执行硬重启后出现此问题。
我的套接字文件位于此处:
/var/run/mysqld/mysqld.sock
当我做:
rake thinking_sphinx:start
我得到:
rake aborted!
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
我想告诉 thinking_sphinx 我的套接字文件在哪里。这怎么可能?在 Slicehost 上对我的切片执行硬重启后出现此问题。
编辑为(希望)更清晰:
您可以通过以下方式指定要在 sphinx 搜索的配置文件中使用的 mysqlsphinx.conf
套接字sql_sock
:
sql_sock = /var/run/mysqld/mysqld.sock
sql_host
(请注意,是否实际使用此值取决于设置)
您还可以使用 thinking_sphinx 的配置文件 ,RAILS_ROOT/config/sphinx.yml
来设置(覆盖)这些值:
sql_sock: /var/run/mysqld/mysqld.sock
在该版本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
。
来自边缘 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
斧头的答案不起作用。
您可以从提交 49f467b25075666104a46b190139dd1bdbb1452f 中看到有人在 SphinxHelper 中添加了对设置套接字的支持。这个方法我没用过,也没有太多时间给你测试,所以你自己用这个方法。
此外,奇怪的是,在提交http://github.com/freelancing-god/thinking-sphinx/commit/a12dbd55ed9046faf6369a3d0aa452b75a31b5b6中,看起来他们通过您的 database.yml 添加了对套接字的支持,但是如果您查看当前的边缘代码,这好像被删了?
简短的回答:将您的实际 mysqld.sock 符号链接到 sphinx 正在寻找的位置。