前提准备
序号 | 软件 |
---|---|
1 | jdk-8u192-linux-x64.rpm |
2 | solr-8.11.1.tgz |
安装说明
内容 | 描述 |
---|---|
服务器IP | 192.168.16.128 |
安装位置 | /usr/local/solr |
数据目录 | /usr/local/solr/data |
端口 | 8389 |
安装步骤
解压
$ tar -zxvf solr-8.11.1.tgz
$ mkdir -p /usr/local/solr/data
安装
说明:生产环境不建议使用root用户
$ cd solr-8.11.1/bin
$ ./install_solr_service.sh /usr/local/src/solr-8.11.1.tgz -i /usr/local/solr -d /usr/local/solr/data -s solr -p 8389
参数解释:
-i /usr/local/solr 指定solr的安装目录
-d /usr/local/solr/data 指定数据文件目录,包括索引、日志等
-u solr 指定solr文件和运行进程的所属用户, 默认为solr(安装脚本自动创建solr账号)
-s solr solr服务的名称, 默认为solr
-p 8389 solr服务的监听端口,默认为8983
配置用户名/密码
$ cd /usr/local/solr/solr-8.11.1/server/etc
$ vim user.properties
# 格式:用户名:密码,权限
admin:123456,admin
$ vim /usr/local/solr/solr-8.11.1/server/contexts/solr-jetty-context.xml
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath"><Property name="hostContext" default="/solr"/></Set>
<Set name="war"><Property name="jetty.base"/>/solr-webapp/webapp</Set>
<Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml</Set>
<Set name="extractWAR">false</Set>
<!--添加配置权限认证-->
<Get name="securityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">verify—name</Set>
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/user.properties</Set>
</New>
</Set>
</Get>
</Configure>
$ vim /usr/local/solr/solr-8.11.1/server/solr-webapp/webapp/WEB-INF/web.xml
# 新增配置
<security-constraint>
<web-resource-collection>
<web-resource-name>Solr</web-resource-name>
<url-pattern>/</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>verify-name</realm-name>
</login-config>
服务启停
service solr status
service solr start
service solr stop
service solr restart