修改MyIndex.php后运行Solr任务出现401未授权错误如何修复?
修复SilverStripe Solr搜索401未授权错误
问题背景
测试服务器此前基于silverstripe-solr-search模块实现的Solr搜索功能运行正常。尝试添加文件搜索功能时,新增了Search/MyIndex.php文件,并在mysite.yml中添加如下配置:
Firesphere\SolrSearch\Indexes\BaseIndex: class: MyIndex
之后运行以下任一命令,或直接使用搜索功能,都会触发401未授权错误:
vendor/bin/sake dev/tasks/SolrConfigureTask flush=all
vendor/bin/sake dev/tasks/SolrIndexTask
错误信息如下:
GuzzleHttp\Exception\ClientException: Client error: `GET http://localhost:8983/solr/admin/info/logging?since=0&wt=json` resulted in a `401 Unauthorized` response:
即使撤销上述添加文件搜索的修改,错误依然存在。
已完成的排查操作
确认Solr服务处于运行状态:
执行命令service solr status,输出如下:● solr.service - LSB: Controls Apache Solr as a Service Loaded: loaded (/etc/init.d/solr; generated) Active: active (exited) since Fri 2023-07-21 14:46:03 UTC; 16min ago Docs: man:systemd-sysv-generator(8) Process: 1493118 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS) Jul 21 14:45:50 site-stage systemd[1]: Starting LSB: Controls Apache Solr as a Service... Jul 21 14:45:50 site-stage su[1493125]: (to solr) root on none Jul 21 14:45:50 site-stage su[1493125]: pam_unix(su-l:session): session opened for user solr by (uid=0) Jul 21 14:46:03 site-stage systemd[1]: Started LSB: Controls Apache Solr as a Service.已在
search.yml中配置模块参数:--- Name: MySolrSearch After: SolrSearch --- Firesphere\SolrSearch\Services\SolrCoreService: config: endpoint: localhost: host: localhost port: 8983 timeout: 10 # set up timeouts index_timeout: 10 optimize_timeout: 100 finalize_timeout: 300 http_method: 'AUTO' # commit within 60ms commit_within: 60 store: mode: 'file' path: '/var/solr/data' cpucores: 2已在
.env文件中设置SOLR_PASSWORD和SS_SOLR_INDEX环境变量。尝试过重新设置权限(修正了原命令中的
sermod拼写错误为usermod):usermod -a -G www-data solr groups solr usermod -a -G solr www-data groups www-data chown -R solr:www-data /var/solr chmod -R u+rwxs,g+rwxs /var/solr
求助
如何修复该401未授权错误,恢复Solr搜索功能?
内容的提问来源于stack exchange,提问作者Will
相关产品推荐
相关产品推荐

