I'm getting this error when I try to create a new core in solr.
root@ubuntu:/opt/solr# bin/solr create -c gettingstarted -n data_driven_schema_configs
Setup new core instance directory:
/var/solr/data/gettingstarted
Creating new core 'gettingstarted' using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=gettingstarted&instanceDir=gettingstarted
Failed to create core 'gettingstarted' due to: Error CREATEing SolrCore 'gettingstarted': Unable to create core [gettingstarted] Caused by: /var/solr/data/gettingstarted/data
Also, if I try to create alternatively, It gives me same error:
root@ubuntu:/opt/solr# bin/solr create -c mycore
Setup new core instance directory:
/var/solr/data/mycore
Creating new core 'mycore' using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=mycore&instanceDir=mycore
Failed to create core 'mycore' due to: Error CREATEing SolrCore 'mycore': Unable to create core [mycore] Caused by: /var/solr/data/mycore/data
In browser, when I try to access solr admin panel, it displays a notification like:
SolrCore Initialization Failures
opt/solr/example/exampledocs/*.xml: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: /var/solr/data/opt/solr/example/exampledocs/*.xml/data
snapshot is attached.

Since it might help anybody with the same issue, it's indeed caused by permission issues when using root. The script doesn't terminate quickly when executing the command as root and instead creates a piece of the core definition before failing.
So first cleanup the broken core:
bin/solr delete -c mycore
Make sure that no folder(s) linger under /var/solr/data for your mycore core.
Next create the core as the solr user
su -u solr -c "/opt/solr/bin/solr create_core -c mycore"
This time it should succeed
Don't run solr script as root user (it is not recommended). You should run as solr user, e.g.:
sudo -u solr ./bin/solr create -c mycore
I found this as the solution:
sudo su - solr -c "/opt/solr/bin/solr create -c mycore"
More information here: https://www.howtoforge.com/tutorial/how-to-install-and-configure-solr-on-ubuntu-1604/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With