Dennis Konoppa
Dennis Konoppa

Reputation: 225

Create Solr core in console with authentication

I have a Solr core that needs an authentication. Let's say I have a user with password password. When I now try to create a Solr core in the console with

bin\solr create -c test

I get an HTTP Error 401. Of course I need to specify my user. How can I add my user and password in the console? Something like bin\solr create -c test -authentication user:password

Upvotes: 3

Views: 5827

Answers (3)

luhuang
luhuang

Reputation: 121

Using Command Line scripts with BasicAuth Add the following line to the (/opt/solr/bin) solr.in.sh or solr.in.cmd file. This example tells the bin/solr command line to to use "basic" as the type of authentication, and to pass credentials with the user-name "solr" and password "SolrRocks": SOLR_AUTH_TYPE="basic" SOLR_AUTHENTICATION_OPTS="-Dbasicauth=solr:SolrRocks" look: https://lucene.apache.org/solr/guide/6_6/basic-authentication-plugin.html#BasicAuthenticationPlugin-UsingBasicAuthwithSolrJ

Upvotes: 6

dan
dan

Reputation: 43

If you use Basic Authentication than first set in the CMD Console:

set SOLR_AUTH_TYPE=basic
set SOLR_AUTHENTICATION_OPTS="-Dbasicauth=USER:PASS"

Customize USER:PASS for your need

Upvotes: 3

jmathewt
jmathewt

Reputation: 947

It has been a while so, I am not sure if you still have this issue. But this can help others who may come across this like how I did.

I am new to solr, so there could be a better way of doing this than what I have here.

Are you using zookeeper for authentication?

Assuming you are using zookeeper for authentication

First of all, I checked and I don't think there is an -authentication parameter for solr create command. So, this is how I hacked around this issue:

  1. Stopped solr
  2. Started solr without zookeeper
  3. created the core like how you tried for the test core
  4. Then uploaded configuration of the test core to zookeeper. I followed this document - https://systemsarchitect.net/2013/04/06/painless-guide-to-solr-cloud-configuration/
  5. Restarted zookeeper server
  6. Started solr with -p 8983 -z zookeeper_hostname:zookeeper_port You should be able to access your test core with authentication enabled

Upvotes: 1

Related Questions