前几天把MediaWiki升级到了1.39.2,虽然小问题还是有一点的,但不影响使用也就没过多留意。直到在控制台中运行runJobs.php脚本时,发现CirrusSearch总会报错,大体上就是error: ElasticaWrite job failed。所以不再像没升级前那样,后台任务完成就会显示Job queue is empty.,而是随时运行脚本都会有任务在执行,而且都是由CirrusSearch引发的(这可能也是为什么某一时刻我的服务器CPU和内存的使用量急剧上升,网站卡到不行的原因之一)。
网上说啥的都有,最终还是官方文档给出了解释,1.39以后需要Elasticsearch 7.10.2的支持,而我还停留在6.8.23(想当初1.35想装7.x它不让,好不容易装上6.x么它又让升级了)。
那就升级吧,具体见《为MediaWiki安装高级搜索(AdvancedSearch)插件》一文,只不过上次是从7.x降到了6.x,这次正好相反。另外要注意升级完毕之后的启动超时问题,如果遇到的话可以参考《Elasticsearch服务超时,启动失败》一文。
接下去就是运行CirrusSearch的维护脚本,找扩展目录下的maintenance目录,运行如下脚本,结果报错:

# php UpdateSearchIndexConfig.php --startOver
Updating cluster ...
indexing namespaces...
        Indexing namespaces...done
content index...
        Fetching Elasticsearch version...7.10.2...ok
        Scanning available plugins...none
        Picking analyzer...default
        Inferring index identifier...error
Looks like the index has more than one identifier. You should delete all
but the one of them currently active. Here is the list: ms_wiki_content_1642941692,ms_wiki_content_1679027462,ms_wiki_content_1679027504,ms_wiki_content_1679027900,ms_wiki_content_1679028046

如果运行另一种方式php updateSearchIndexConfig.php --reindexAndRemoveOk --indexIdentifier now,提示有索引任务正在执行,请取消并移除。
我也不想搞清楚到底是怎么回事了,直接用第一种方式重建吧。首先就是要删除索引,一条一条来吧,把代码中的ms_wiki_content_替换成上面提到的哪些。

# curl -X DELETE "localhost:9200/ms_wiki_content_1642941692?pretty"
{
  "acknowledged" : true
}

全部删除后,重建索引:

# php UpdateSearchIndexConfig.php --startOver
Updating cluster ...
indexing namespaces...
        Indexing namespaces...done
content index...
        Fetching Elasticsearch version...7.10.2...ok
        Scanning available plugins...none
        Picking analyzer...default
        Inferring index identifier...ms_wiki_content_first
        Blowing away index to start over...ok
                Validating number of shards...ok
                Validating replica range...ok
                Validating shard allocation settings...
                        Clearing 'include' allocations...done
                Validating max shards per node...ok
        Validating analyzers...ok
        Validating mappings...
                Validating mapping...different...corrected
        Validating aliases...
                Validating ms_wiki_content alias...alias is free...corrected
                Validating ms_wiki alias...alias not already assigned to this index...corrected
                Updating tracking indexes...done
general index...
        Fetching Elasticsearch version...7.10.2...ok
        Scanning available plugins...none
        Picking analyzer...default
        Inferring index identifier...ms_wiki_general_1642941697
        Blowing away index to start over...ok
                Validating number of shards...ok
                Validating replica range...ok
                Validating shard allocation settings...
                        Clearing 'include' allocations...done
                Validating max shards per node...ok
        Validating analyzers...ok
        Validating mappings...
                Validating mapping...different...corrected
        Validating aliases...
                Validating ms_wiki_general alias...alias is free...corrected
                Validating ms_wiki alias...alias not already assigned to this index...corrected
                Updating tracking indexes...done

再执行php ForceSearchIndex.php命令。
回到系统的维护目录下,执行runJobs.php脚本,终于不再报错了。但是重建过程相当漫长,甚至提示内存耗尽。小网站还行,大站点不清楚会怎样。

注意:如果在执行过程中问题,也可以去设置文件中开启$wgDisableSearchUpdate = true;选项,因为在升级前有可能是被关闭的。

最后修改:2023 年 03 月 17 日
如果觉得我的文章对你有用,请随意赞赏