Reputation: 31
I have a linux system and installed solr 9.2.0 and started solr. My solr installation path is /opt/solr-9.2.0/ and I tried creating a core by doing the following steps
mkdir -p /opt/solr-9.2.0/server/solr/samplecore/conf
cp -pr /opt/solr-9.2.0/server/solr/configsets/sample_techproducts_configs/conf /opt/solr-9.2.0/server/solr/samplecore
I created core.properties in the location /opt/solr-9.2.0/server/solr/samplecore/ with below content by referring to a sample version from another very old version installation
#Written by CorePropertiesLocator
#Wed May 03 17:32:11 PDT 2023
name=samplecore
config=solrconfig.xml
schema=schema.xml
dataDir=/index/dev/solr/samplecore
I started solr as below
/opt/solr-9.2.0/bin/solr start -h mylinuxbox -p 8983
After this I visited http://mylinuxbox:8983/solr in browser and expected to see the created core but i 'm getting an error as follows
SolrCore Initialization Failures samplecore: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: access denied ("java.io.FilePermission" "/index/dev/solr/samplecore/snapshot_metadata" "read") Please check logs for more information.
Is there any other setting or configuration I am missing? I need the solr to use /index/dev/solr/samplecore path for index data. Please help me with this. I am new to solr and java.
I have explained in the description everything I tried
Upvotes: 3
Views: 2095
Reputation: 121
The original answer below was required for us due to some quirks of our deployment but might not be necessary for everyone. You may be able to avoid upgrading solr or modifying security.policy and instead just set SOLR_DATA_HOME
in your solr.in.cmd or solr.in.sh respectively:
set SOLR_DATA_HOME=C:/path/to/data
or
export SOLR_DATA_HOME="/path/to/data"
Note: We found that using a relative path (../data
) caused us to still encounter the permission failure.
As of Solr 9.4 there seems to be a proper fix for this issue.
Either upgrade to Solr 9.4 or add the following to solr/server/etc/security.policy
:
permission java.io.FilePermission "${solr.allowPaths}", "read,write,delete,readlink";
permission java.io.FilePermission "${solr.allowPaths}${/}-", "read,write,delete,readlink";
Add the following to your solr.in.cmd:
set SOLR_OPTS=%SOLR_OPTS% -Dsolr.allowPaths=C:\path1\to\allow,C:\path2\to\allow
or solr.in.sh:
SOLR_OPTS="$SOLR_OPTS -Dsolr.allowPaths=/path1/to/allow,/path2/to/allow"
Restart solr.
As noted in previous answers, solr 9 comes with the java security manager enabled by default. This prevents solr from accessing directories outside of its root directory. This is why previous answers suggested disabling the security manager.
In Solr 8.6 a solr.allowPaths
property was added for specifying allowed paths outside of the default directories. In solr 9.0 -> 9.3 this property was not configured in the security manager. This means that even though you could add your paths to this property, it would still result in a permission error.
This has been resolved in solr 9.4, with the following lines added to the security.policy file in solr/server/etc
permission java.io.FilePermission "${solr.allowPaths}", "read,write,delete,readlink";
permission java.io.FilePermission "${solr.allowPaths}${/}-", "read,write,delete,readlink";
This means you can now configure the allowPaths property in solr.in.cmd or solr.in.sh as described in step 2 of the short answer above.
If you are unable to upgrade to 9.4 for some reason, you could add these lines to the security.policy manually.
Upvotes: 2
Reputation: 171
It helps to resolve the dependency for symlink
SOLR_SECURITY_MANAGER_ENABLED=false
Upvotes: 0
Reputation: 27821
We noticed that when creating a new core on v9, you cannot point the data directory to a directory that is not within the core's root directory. So in your example, you might need to change your core.properties
to:
name=samplecore
config=solrconfig.xml
schema=schema.xml
dataDir=data
Note that creating a symlink to the data directory (if it's outside of the core's root directory) also causes the same error to occur.
Upvotes: 3