elasticsearch启动时报错main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")

用  /usr/local/elasticsearch/bin/elasticsearch 命令启动es时候报错:

Exception in thread "main" 2020-01-14 16:26:37,984 main ERROR No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
2020-01-14 16:26:38,209 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:457)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:585)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1848)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:322)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
    at org.apache.logging.log4j.core.jmx.Server.register(Server.java:393)
    at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:168)
    at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:141)
    at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:558)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:243)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:648)
    at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:54)
    at org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:62)
    at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:101)
    at org.elasticsearch.ExceptionsHelper.<clinit>(ExceptionsHelper.java:48)
    at org.elasticsearch.ElasticsearchException.toString(ElasticsearchException.java:663)
    at java.lang.String.valueOf(String.java:2982)
    at java.io.PrintStream.println(PrintStream.java:821)
    at java.lang.Throwable$WrappedPrintStream.println(Throwable.java:748)
    at java.lang.Throwable.printStackTrace(Throwable.java:655)
    at java.lang.Throwable.printStackTrace(Throwable.java:643)
    at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1061)
    at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1052)
    at java.lang.Thread.dispatchUncaughtException(Thread.java:1952)

SettingsException[Failed to load settings from /usr/local/elasticsearch/config/elasticsearch.yml]; nested: AccessDeniedException[/usr/local/elasticsearch/config/elasticsearch.yml];
    at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:102)
    at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:75)
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70)
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134)
    at org.elasticsearch.cli.Command.main(Command.java:90)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84)
Caused by: java.nio.file.AccessDeniedException: /usr/local/elasticsearch/config/elasticsearch.yml
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
    at java.nio.file.Files.newByteChannel(Files.java:361)
    at java.nio.file.Files.newByteChannel(Files.java:407)
    at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
    at java.nio.file.Files.newInputStream(Files.java:152)
    at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:1039)
    at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:100)
    ... 6 more

解决办法:

改变elasticsearch文件夹所有者到当前用户

chown -R esuser.esuser /usr/local/elasticsearch

再次启动:

/usr/local/elasticsearch/bin/elasticsearch
[esuser@localhost ~]$ /usr/local/elasticsearch/bin/elasticsearch
[2020-01-14T16:37:14,132][INFO ][o.e.n.Node               ] [] initializing ...
[2020-01-14T16:37:15,043][INFO ][o.e.e.NodeEnvironment    ] [ap3p3yv] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [14.6gb], net total_space [17.4gb], spins? [unknown], types [rootfs]
[2020-01-14T16:37:15,043][INFO ][o.e.e.NodeEnvironment    ] [ap3p3yv] heap size [1.9gb], compressed ordinary object pointers [true]
[2020-01-14T16:37:15,065][INFO ][o.e.n.Node               ] node name [ap3p3yv] derived from node ID [ap3p3yvbToe7R8ZyNh2Gvg]; set [node.name] to override
[2020-01-14T16:37:15,065][INFO ][o.e.n.Node               ] version[5.6.11], pid[1227], build[bc3eef4/2018-08-16T15:25:17.293Z], OS[Linux/3.10.0-1062.4.1.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_45/25.45-b02]
[2020-01-14T16:37:15,066][INFO ][o.e.n.Node               ] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/elasticsearch]
[2020-01-14T16:37:22,544][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [aggs-matrix-stats]
[2020-01-14T16:37:22,558][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [ingest-common]
[2020-01-14T16:37:22,558][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [lang-expression]
[2020-01-14T16:37:22,558][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [lang-groovy]
[2020-01-14T16:37:22,559][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [lang-mustache]
[2020-01-14T16:37:22,559][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [lang-painless]
[2020-01-14T16:37:22,559][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [parent-join]
[2020-01-14T16:37:22,559][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [percolator]
[2020-01-14T16:37:22,559][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [reindex]
[2020-01-14T16:37:22,559][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [transport-netty3]
[2020-01-14T16:37:22,559][INFO ][o.e.p.PluginsService     ] [ap3p3yv] loaded module [transport-netty4]
[2020-01-14T16:37:22,560][INFO ][o.e.p.PluginsService     ] [ap3p3yv] no plugins loaded
[2020-01-14T16:37:26,960][INFO ][o.e.d.DiscoveryModule    ] [ap3p3yv] using discovery type [zen]
[2020-01-14T16:37:28,227][INFO ][o.e.n.Node               ] initialized
[2020-01-14T16:37:28,228][INFO ][o.e.n.Node               ] [ap3p3yv] starting ...
[2020-01-14T16:37:29,272][INFO ][o.e.m.j.JvmGcMonitorService] [ap3p3yv] [gc][young][1][4] duration [871ms], collections [1]/[1s], total [871ms]/[1.7s], memory [148.8mb]->[33.7mb]/[1.9gb], all_pools {[young] [129.7mb]->[3mb]/[133.1mb]}{[survivor] [15.2mb]->[16.6mb]/[16.6mb]}{[old] [3.8mb]->[14.4mb]/[1.8gb]}
[2020-01-14T16:37:29,523][WARN ][o.e.m.j.JvmGcMonitorService] [ap3p3yv] [gc][1] overhead, spent [871ms] collecting in the last [1s]
[2020-01-14T16:37:30,127][INFO ][o.e.t.TransportService   ] [ap3p3yv] publish_address {192.168.52.138:9300}, bound_addresses {[::]:9300}
[2020-01-14T16:37:30,195][INFO ][o.e.b.BootstrapChecks    ] [ap3p3yv] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2020-01-14T16:37:34,269][INFO ][o.e.c.s.ClusterService   ] [ap3p3yv] new_master {ap3p3yv}{ap3p3yvbToe7R8ZyNh2Gvg}{6JcbGxnnQjCoUl_elU-WcQ}{192.168.52.138}{192.168.52.138:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)[, ]
[2020-01-14T16:37:34,682][INFO ][o.e.h.n.Netty4HttpServerTransport] [ap3p3yv] publish_address {192.168.52.138:9200}, bound_addresses {[::]:9200}
[2020-01-14T16:37:34,683][INFO ][o.e.n.Node               ] [ap3p3yv] started
[2020-01-14T16:37:34,851][INFO ][o.e.g.GatewayService     ] [ap3p3yv] recovered [0] indices into cluster_state
posted @ 2020-01-14 16:40  cknds  阅读(4700)  评论(0编辑  收藏  举报