Solr5权限配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Solr5权限配置相关的知识,希望对你有一定的参考价值。
参考技术A 1. solr-webapp中的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>solr_admin</role-name>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Test Realm</realm-name>
</login-config>
2. solr-jetty-context.xml
<Get name="securityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.security.HashLoginService>
<Set name="name">Test Realm</Set>
<Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
</New>
</Set>
</Get>
注意此处realm.properties的位置是相对于jetty.home
3. realm.properties
username: password,role
注意password需要配置成MD5
例如:username=admin, password=12345
admin: MD5:827ccb0eea8a706c4c34a16891f84e7b, admin
生成上述MD5: java -cp jetty-util-9.2.13.v20150730.jar org.eclipse.jetty.util.security.Password admin 12345
修改或者添加密码后需要重启服务
4. Solrj访问时进行相关权限设置。参见Solr5部分
http://stackoverflow.com/questions/2014700/preemptive-basic-authentication-with-apache-httpclient-4/11868040#11868040
5. 自动更新进行权限设置,参考http://www.cnblogs.com/donganwangshi/p/4276015.html
在sendHttpPost(StringcoreName,Stringparams)中添加
String headerKey = "Authorization";
String encoding = username+":"+password;
String headerValue = "Basic " + new BASE64Encoder().encode(encoding.getBytes());
conn.setRequestProperty(headerKey, headerValue);
其中username和password是从配置文件dataimport.properties中读取的
solr入门之搭建具有安全控制和权限管理功能的SolrCloud集群
结合上次搭建项目和配置安全控制的经验,工程的搭建过程应该如下:1.搭建zookeeper集群
2.配置solr的jetty启动配置
3.在solr启动配置中增加zk的acl配置信息
4.使用solr配置,启动solrcloud集群将 集群交给zookeeper管理
5.上传相关的配置文件,创建集合
6.上传安全配置文件
7.登录admin界面,查看集群状态及能否访问到zookeeper上的文件
8.添加数据到solrcloud中
9.配置客户端,使用solrj来操作solrcloud(摸索阶段)
================================================================
1.配置zookeeper集群
以上是关于Solr5权限配置的主要内容,如果未能解决你的问题,请参考以下文章