ElasticSearch 5版本权限问题解决

时间:2024-05-20 20:23:01

在mac使用ElasticSearch时,出现了一个少见的错误,错误代码如下

2019-10-15T09:16:46,036][INFO ][o.e.n.Node               ] [] initializing ...
[2019-10-15T09:16:46,093][ERROR][o.e.b.Bootstrap          ] Exception
java.security.AccessControlException: access denied ("java.io.FilePermission" "/System/Volumes/Data/Users/first/work/elasticsearch/elasticsearch-5.6.16/data/nodes/0" "write")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) ~[?:1.8.0_181]
    at java.security.AccessController.checkPermission(AccessController.java:884) ~[?:1.8.0_181]
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) ~[?:1.8.0_181]
    at java.lang.SecurityManager.checkWrite(SecurityManager.java:979) ~[?:1.8.0_181]
    at sun.nio.fs.UnixPath.checkWrite(UnixPath.java:801) ~[?:?]
    at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:376) ~[?:?]
    at java.nio.file.Files.createDirectory(Files.java:674) ~[?:1.8.0_181]
    at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781) ~[?:1.8.0_181]
    at java.nio.file.Files.createDirectories(Files.java:727) ~[?:1.8.0_181]
    at org.apache.lucene.store.NativeFSLockFactory.obtainFSLock(NativeFSLockFactory.java:92) ~[lucene-core-6.6.1.jar:6.6.1 9aa465a89b64ff2dabe7b4d50c472de32c298683 - varunthacker - 2017-08-29 21:54:39]
    at org.apache.lucene.store.FSLockFactory.obtainLock(FSLockFactory.java:41) ~[lucene-core-6.6.1.jar:6.6.1 9aa465a89b64ff2dabe7b4d50c472de32c298683 - varunthacker - 2017-08-29 21:54:39]
    at org.apache.lucene.store.BaseDirectory.obtainLock(BaseDirectory.java:45) ~[lucene-core-6.6.1.jar:6.6.1 9aa465a89b64ff2dabe7b4d50c472de32c298683 - varunthacker - 2017-08-29 21:54:39]
    at org.elasticsearch.env.NodeEnvironment.<init>(NodeEnvironment.java:230) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.node.Node.<init>(Node.java:265) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.node.Node.<init>(Node.java:245) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:233) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:233) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) [elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) [elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) [elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) [elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) [elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.6.16.jar:5.6.16]
[2019-10-15T09:16:46,103][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.security.AccessControlException: access denied ("java.io.FilePermission" "/System/Volumes/Data/Users/first/work/elasticsearch/elasticsearch-5.6.16/data/nodes/0" "write")
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.16.jar:5.6.16]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.16.jar:5.6.16]

 

看到上面的错误,首先想到的是没有权限

那就对文件夹赋值权限呗

 sudo chmod -R 777  文件夹位置

结果问题依然存在

 

然后就感觉是执行文件没有权限

进入ElasticSearch的bin目录

执行    chmod +x *.*    (给文件访问权限)

问题依然没有解决

百思不得其解,后在*上找到了类似的问题

ElasticSearch 5版本权限问题解决

发现是java.policy的问题

问的java.policy的文件位置    /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre/lib/security

管理员权限vim java.policy

然后再grant{}的最后加上permission java.security.AllPermission;

重新启动elasticSearch.

正常启动

相关文章