如何正确地重新索引 Sphinx 搜索服务器?
我有一个网站,它使用 Sphinx 搜索服务器来搜索 MySQL 数据库。这工作得很好,但问题是当新项目添加到数据库时。我的问题是何时是执行重新索引的最佳时间以及如何正确执行。目前我正在做一个“indexer --all --rotate”,但这似乎不起作用。更新索引的唯一方法是停止 sphinx,然后执行索引器 --all,然后重新启动服务。这在现场站点上显然并不理想。如果有人有任何关于如何正确执行此操作的信息,我将非常感激。
谢谢
I have a website that is using Sphinx search server to search through a MySQL database. This is working perfectly but the issue is when new items are added to the database. My question is when is the best time to perform a reindex as well as how to do it correctly. Currently I am doing a "indexer --all --rotate" but this doesn't seem to be working. The only way to update the indexes is to stop sphinx then perform a indexer --all and then restart the service. This is obviously not ideal on a live site. If anyone has any information on how to do this correctly I would really appreciate it.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确的话,应该不需要重新启动。
-all
选项告诉索引器更新每个索引。-rotate
旋转索引,即创建每个索引的临时副本并在完成后替换旧索引。根据Sphinx手册旋转工作如下:“它创建了第二个索引,与第一个并行(在同一位置,只需在文件名中包含 .new)。完成后,索引器通过发送 SIGHUP 信号通知 searchd,searchd 将尝试重命名索引(重命名现有索引)。包含 .old 并重命名 .new 以替换它们),然后从较新的文件开始提供服务,具体取决于 Seamless_rotate 的设置,搜索较新的索引可能会略有延迟。”无缝旋转和“中断”旋转之间存在差异。可以使用 Sphinx 配置文件中的 Seamless_rotate 参数来控制类型。 无缝轮换的代价是轮换期间内存使用峰值更高,但不间断地发生。
Sphinx 版本也很重要。在以前的版本中 a更新索引需要重新启动,在最新版本中似乎不再需要。
If I understand it correctly, a restart should not be necessary. The
-all
option tells indexer to update every index.-rotate
rotates the index, i.e. create a temporary copy of each index and replace the old ones when finished. According to the Sphinx manual rotating works as follows: "it creates a second index, parallel to the first (in the same place, simply including .new in the filenames). Once complete, indexer notifies searchd via sending the SIGHUP signal, and searchd will attempt to rename the indexes (renaming the existing ones to include .old and renaming the .new to replace them), and then start serving from the newer files. Depending on the setting of seamless_rotate, there may be a slight delay in being able to search the newer indexes."There are differences between seamless and "interrupted" rotates. The type can be controlled using the
seamless_rotate
parameter in the Sphinx config file. Seamless rotates come at the cost of higher peak memory usage during the rotation, but happen without interruption.The Sphinx version also matters. In former versions a restart was required to update the index, in the newest version this seems to be no longer necessary.
“--rotate”选项旋转索引,即创建每个索引的临时副本并在完成后替换旧索引。它创建第二个索引,与第一个索引并行(在同一位置,只需在文件名中包含 .new )。完成后,索引器通过发送 SIGHUP 信号通知 searchd,searchd 将从具有 .new 扩展名的较新文件开始提供服务。如果系统中已存在 .new 文件,则只需在使用“--rotate”选项后更新它们即可。
“--all”选项告诉索引器更新每个索引,但不更新使用“--rotate”选项创建的扩展名为 .new 的第二个索引器文件
The '--rotate' option rotates the index, i.e. create a temporary copy of each index and replace the old ones when finished. It creates a second index, parallel to the first(in the same place, simply including .new in the filenames). Once complete, indexer notifies searchd via sending the SIGHUP signal, and searchd will start serving from the newer files having .new extention. If .new files are already present in the system, it just update them after using '--rotate' option.
The '--all' option tells indexer to update every index but not the second indexer files having extension .new which are created using '--rotate' option