项目实训 : Solr 使用中遇到的问题


title: Solr 使用中遇到的问题
tags: [Sdudoc, solr, linux]
categories: 技术


前言

笔者使用的Solr版本是solr-8.11.0

正文

启动时警告

*** [WARN] *** Your open file limit is currently 1024.
It should be set to 65000 to avoid operational disruption.
If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh

*** [WARN] *** Your Max Processes Limit is currently 4096.
It should be set to 65000 to avoid operational disruption.
If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh

NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.

可以看到这里有两个警告和一个提示。

其中第一个警告是说当前最大打开文件数为1024,为了防止操作终端,应该设置为65000

笔者首先检查了本机的限制:

ulimit -a
----
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 63405
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
----

可以清楚的看到 open files 的限制为 1024

修改限制至65000 (记得切换至root用户,否则没有权限修改)

ulimit -n 65000

为了保证每次系统启动时,都可以设置ulimit值至65000,笔者将ulimit指令加到了 /etc/profile 中

echo ulimit -n 65000 >> /etc/profile
----
source /etc/profile

利用上面的方法,我们也可以将最大用户进程数设置为65000

注意,这里设置的是当前用户的最大进程数,所以应当切换至对应的用户执行以下操作

echo ulimit -u 65000 >> /etc/profile
----
source /etc/profile

最后一个,安装lsof,在root用户下执行:

yum install lsof

使用中遇到问题

插入数据时报错

test代码片段如下:

TestDocument testDocument = new TestDocument();
UpdateResponse response = solrClient.addBean(TEST_CORE_NAME, testDocument);
response = solrClient.commit(TEST_CORE_NAME);

在测试插入文档到solr的core中时报错:

org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://211.87.232.198:8983/solr: Expected mime type application/octet-stream but got text/html. Sorry, Page Not Found

观察后发现,报错的位置在于commit处,查看源码发现,如果在url中没有指明core,则需要在add的时候和commit的时候都需要指明core

...
response = solrClient.commit(TEST_CORE_NAME);
中文分词不理想

笔者使用时发现solr对于中文的分词不够理想,故决定使用其他的分词器,这里笔者采用的是IK-Analyzer 链接:下载链接

将 jar 包添加至solr目录下的 server/solr-webapp/webapp/WEB-INF/lib 中

再向 server/solr/[core_name]/conf 下的 managed-schema 配置文件中添加配置:

<fieldType name="text_ik" class="solr.TextField">  
    <analyzer type="index" class="org.wltea.analyzer.lucene.IKAnalyzer" useSmart="false"/>  
    <analyzer type="query" class="org.wltea.analyzer.lucene.IKAnalyzer" useSmart="false"/>  
</fieldType>  

重启solr服务即可。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值