下载解压solr
下载solr,地址如下:
https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr
我下载的是8.11.3版本,文件“solr-8.11.3.zip”。
解压solr压缩包“solr-8.11.3.zip”
unzip solr-8.11.3.zip
启动solr
solr启动脚本放置在solr-8.11.3/bin目录下。
切换到解压目录并启动:
./solr start
出现如下结果,则启动成功(默认启动端口是8983):
:/var/www/data/solr/solr-8.11.3/bin$ ./solr start
*** [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 7538.
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
Warning: Available entropy is low. As a result, use of the UUIDField, SSL, or any other features that require
RNG might not work properly. To check for the amount of available entropy, use 'cat /proc/sys/kernel/random/entropy_avail'.
Waiting up to 180 seconds to see Solr running on port 8983 [|]
Started Solr server on port 8983 (pid=10983). Happy searching!
solr相关命令如下:
bin/solr stop -all 关闭solr服务
bin/solr start -force 开启solr服务
bin/solr restart -force 重启solr服务
bin/solr status 查看solr服务状态
访问solr,访问地址“http://ip:端口/solr”,如下:
http://192.168.2.121:8983/solr
当我们修改了配置或者添加了jar或者其他资源之后,必须重启服务才能生效。
配置solr
进入solr管理界面,我这里的地址是:
http://192.168.2.121:8983/solr
左侧菜单点击“Core Admin”,点击右侧“Add Core”,name 一栏输入 “test”,instanceDir一栏输入”test”,点“Add Core”后报错如下:
Error CREATEing SolrCore 'test': Unable to create core [test] Caused by: Can't find resource 'solrconfig.xml' in classpath or '/var/www/data/solr/solr-8.11.3/server/solr/test'
我们将”solr-8.11.3/server/solr/configsets/_default/conf”目录下的所有文件拷贝到”solr-8.11.3/server/solr/test”目录下即可。
进入目录“solr-8.11.3/server/solr”,执行如下命令:
cp -r configsets/_default/conf test/.
刷新页面后如果出现“SolrCore Initialization Failures”,则重启下solr,进入solr-8.11.3/bin目录,执行如下命令:
./solr restart -force
再”Add Core”,name 一栏输入 “test”,instanceDir一栏输入”test”,即可添加成功。
成功后如下图所示: