先在本地新建security.json文件,并添加如下内容:
{
"authentication":{
"class":"solr.BasicAuthPlugin",
"credentials":{"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0=
Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="}
},
"authorization":{
"class":"solr.RuleBasedAuthorizationPlugin",
"user-role":{"solr":"admin"},
"permissions":[{"name":"security-edit",
"role":"admin"}]
}}
再将该文件上传到zookeeper server:
server/scripts/cloud-scripts/zkcli.sh -zkhost localhost:9983 -cmd putfile /security.json security.json
用以下命令查看是否上传成功:
curl http://localhost:8983/solr/admin/authentication
curl http://localhost:8983/solr/admin/authorization
输入两行命令会有相应的内容出现,表示上传成功。
设置用户名和密码:
curl --user solr:SolrRocks http://localhost:8983/solr/admin/authentication -H 'Content-type:application/json'-d '{
"set-user": {"tom" : "TomIsCool" ,
"harry":"HarrysSecret"}}'
添加了tom和harry两组用户。
重启zookeeper,重启solrcloud,进主页出现登录页面:
输入正确用户名密码即可进入主页。
删除用户:
curl --user solr:SolrRocks http://localhost:8983/solr/admin/authentication -H 'Content-type:application/json'-d '{
"delete-user": ["tom","harry"]}'