You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CKAN实例报500错误,Solr连接异常(404/超时)求助

问题分析与解决方案

你的CKAN实例报500错误,根源是Solr返回404且主页访问超时——虽然Solr进程显示运行,但实际服务未正常提供,或配置路径不匹配。以下是分步排查方案:

1. 确认Solr实际监听状态

先检查Solr是否真的在localhost:8983端口监听:

netstat -tulpn | grep 8983
# 或者用ss命令
ss -tulpn | grep 8983
  • 若无输出,说明Solr是僵尸进程,实际未启动。前往Solr日志目录(通常为/opt/solr/server/logs或对应安装路径)查看solr.log,排查启动失败原因(如内存不足、配置文件语法错误)。
  • 若监听其他地址(如0.0.0.0)但本地访问超时,可能是防火墙拦截8983端口,临时关闭防火墙测试:systemctl stop firewalld(CentOS)或ufw disable(Ubuntu)。

2. 检查CKAN所需的Solr Core是否存在

CKAN依赖名为ckan的Solr Core,若Core未创建,访问/solr/select会返回404:

  • 用curl访问Solr Core状态API:
curl http://localhost:8983/solr/admin/cores?action=STATUS
  • 若超时,回到第一步排查Solr启动问题;
  • 若返回JSON,检查是否包含ckan Core。若无,按以下步骤创建:
    1. 复制CKAN自带的Solr配置文件到Solr cores目录:
      cp -r /usr/lib/ckan/default/src/ckan/ckan/config/solr/schema.xml /opt/solr/server/solr/ckan/conf/
      
    2. 通过命令创建Core:
      /opt/solr/bin/solr create -c ckan
      

3. 核对CKAN的Solr地址配置

打开CKAN生产配置文件(通常为/etc/ckan/default/production.ini),找到solr_url项:

# 正确格式需包含Core名称
solr_url = http://localhost:8983/solr/ckan
# 以下写法会导致404
# solr_url = http://localhost:8983/solr/

修正后重启CKAN服务:

systemctl restart ckan

4. 强制重启Solr进程

若Solr进程存在但无响应,强制杀死后重启:

# 查找Solr进程ID
ps aux | grep solr | grep -v grep
# 杀死进程
kill -9 <进程ID>
# 重启Solr
/opt/solr/bin/solr start

附错误日志

[Wed Oct 05 08:14:56.690889 2022] [wsgi:error] [pid 32062] 2022-10-05 08:14:56,690 ERROR [pysolr] Solr responded with an error (HTTP 404): [Reason: HTTP Status 404 - /solr/select/]
[Wed Oct 05 08:14:56.692439 2022] [wsgi:error] [pid 32062] 2022-10-05 08:14:56,691 ERROR [ckan.lib.search.common] Solr responded with an error (HTTP 404): [Reason: HTTP Status 404 - /solr/select/]
[Wed Oct 05 08:14:56.692465 2022] [wsgi:error] [pid 32062] Traceback (most recent call last):
[Wed Oct 05 08:14:56.692475 2022] [wsgi:error] [pid 32062]   File "\/usr/lib/ckan/default/src/ckan/ckan/lib/search/common.py", line 57, in is_available
[Wed Oct 05 08:14:56.692485 2022] [wsgi:error] [pid 32062]     conn.search(q="\*:\*", rows=1)
[Wed Oct 05 08:14:56.692495 2022] [wsgi:error] [pid 32062]   File "\/usr/lib/ckan/default/lib/python2.7/site-packages/pysolr.py", line 720, in search
[Wed Oct 05 08:14:56.692505 2022] [wsgi:error] [pid 32062]     response = self._select(params, handler=search_handler)
[Wed Oct 05 08:14:56.692515 2022] [wsgi:error] [pid 32062]   File "\/usr/lib/ckan/default/lib/python2.7/site-packages/pysolr.py", line 418, in _select
[Wed Oct 05 08:14:56.692525 2022] [wsgi:error] [pid 32062]     return self._send_request('get', path)
[Wed Oct 05 08:14:56.692534 2022] [wsgi:error] [pid 32062]   File "\/usr/lib/ckan/default/lib/python2.7/site-packages/pysolr.py", line 393, in _send_request
[Wed Oct 05 08:14:56.692544 2022] [wsgi:error] [pid 32062]     raise SolrError(error_message % (resp.status_code, solr_message))
[Wed Oct 05 08:14:56.692553 2022] [wsgi:error] [pid 32062] SolrError: Solr responded with an error (HTTP 404): [Reason: HTTP Status 404 - /solr/select/]
[Wed Oct 05 08:14:56.692851 2022] [wsgi:error] [pid 32062] 2022-10-05 08:14:56,692 WARNI [ckan.lib.search] Problems were found while connecting to the SOLR server
[Wed Oct 05 08:14:57.344418 2022] [wsgi:error] [pid 32062] 2022-10-05 08:14:57,344 ERROR [pysolr] Solr responded with an error (HTTP 404): [Reason: HTTP Status 404 - /solr/select/]

内容的提问来源于stack exchange,提问作者CoderOj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 09:50:25