总结—elasticsearch启动失败的⼏种情况及解决
总结—elasticsearch启动失败的⼏种情况及解决
1、使⽤root⽤户启动失败
在有⼀次搭建elasticsearch的时候,使⽤systemctl启动elasticsearch失败,然后在bin⽬录下⾯去使⽤启动脚本启动,发现报错不能⽤root⽤户启动,报“Caused by:
java.lang.RuntimeException: can not run elasticsearch as root”:
[root@localhost bin]# ./elasticsearch
[2017-12-20T17:01:47,922][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-6.1.1.jar:6.1.1]
at org.elasticsearch.ute(Elasticsearch.java:112) ~[elasticsearch-6.1.1.jar:6.1.1]
at org.elasticsearch.ute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.1.1.jar:6.1.1]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.1.1.jar:6.1.1]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.1.1.jar:6.1.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-6.1.1.jar:6.1.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) ~[elasticsearch-6.1.1.jar:6.1.1]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.1.1.jar:6.1.1]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.1.1.jar:6.1.1]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:322) ~[elasticsearch-6.1.1.jar:6.1.1]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-6.1.1.jar:6.1.1]
... 6 more
[root@localhost bin]# cd ..
解决:
创建⼀个独⽴的⽤户,⽐如elk来启动elasticsearch,不⽤root⽤户启动
2、elasticsearch安装⽬录权限不对
遇到启动elasticsearch失败,使⽤的是专门的⽤户elk来启动的,启动⽇志提⽰不能加载配置⽂件:
[elk@docker bin]$ ./elasticsearch
Exception in thread "main"2018-06-0317:36:23,881 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging. 2018-06-0317:36:24,113 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission""register")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:585)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1848)
at com.sun.jmx.isterMBean(DefaultMBeanServerInterceptor.java:322)
at com.sun.jmx.isterMBean(JmxMBeanServer.java:522)
at org.apache.ister(Server.java:389)
at org.apache.isterMBeansAfterReconfigure(Server.java:167)
at org.apache.isterMBeansAfterReconfigure(Server.java:140)
at org.apache.LoggerContext.setConfiguration(LoggerContext.java:556)
at org.apache.figure(LoggerContext.java:617)
at org.apache.figure(LoggerContext.java:634)
at org.apache.LoggerContext.start(LoggerContext.java:229)
at org.apache.Context(Log4jContextFactory.java:242)
at org.apache.Context(Log4jContextFactory.java:45)
at org.apache.logging.Context(LogManager.java:174)
at org.apache.logging.Logger(LogManager.java:618)
at org.elasticsearchmon.Logger(ESLoggerFactory.java:54)
at org.elasticsearchmon.Logger(ESLoggerFactory.java:62)
at org.elasticsearchmon.Logger(Loggers.java:101)
at org.elasticsearch.ExceptionsHelper.<clinit>(ExceptionsHelper.java:42)
at org.String(ElasticsearchException.java:663)
at java.lang.String.valueOf(String.java:2994)
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:1959)
SettingsException[Failed to load settings from /usr/local/elasticsearch-5.6.0/l]; nested: AccessDeniedException[/usr/local/elasticsearch-5.6.0/l];
at de.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:102)
at org.elasticsearch.ateEnv(EnvironmentAwareCommand.java:72)
at org.elasticsearch.ute(EnvironmentAwareCommand.java:67)
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-5.6.0/l
at sun.nio.anslateToIOException(UnixException.java:84)
at sun.nio.hrowAsIOException(UnixException.java:102)
at sun.nio.hrowAsIOException(UnixException.java:107)
at sun.nio.wByteChannel(UnixFileSystemProvider.java:214)
at java.nio.wByteChannel(Files.java:361)
at java.nio.wByteChannel(Files.java:407)
at java.nio.file.wInputStream(FileSystemProvider.java:384)
at java.nio.wInputStream(Files.java:152)
at org.elasticsearchmon.settings.Settings$Builder.loadFromPath(Settings.java:1032)
at de.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:100)
... 6 more
[elk@docker bin]$
解决:
看到“Caused by: java.nio.file.AccessDeniedException: /usr/local/elasticsearch-5.6.0/l”的提⽰,就去检查⽬录的权限,果然是root:root权限,使⽤elk⽤户
去启动,就报错了。
将⽬录的权限改成elk:elk就好了。
[root@docker ~]# ll /usr/local/
drwxr-xr-x 7 root root 123 9⽉72017 elasticsearch-5.6.0
[root@docker local]# chown -R elk:elk elasticsearch-5.6.0
[root@docker local]# ll
drwxr-xr-x 7 elk elk 123 9⽉72017 elasticsearch-5.6.0
3、使⽤yum安装⽅式,赋权错误,启动失败
在⼀次使⽤yum安装elasticsearch的时候,执⾏完yum -y install elasticsearch 命令后,进⾏了下⾯的操作:
1、修改l⽂件
2、创建elk⽤户
3、创建/opt/elk/data⽬录,并且赋权为elk:elk
4、修改/var/log/elasticsearch权限为elk:elk
5、启动服务,但是报下⾯的错(截取了部分):
[root@test101 init.d]# ./elasticsearch start
Starting elasticsearch: 2018-06-1215:13:50,287 main ERROR Unable to create file /var/log/elasticsearch/elk.log java.io.IOException: 权限不够
at java.ateFileExclusively(Native Method)
at java.ateNewFile(File.java:1012)
at org.apache.lling.ateManager(RollingFileManager.java:628)
at org.apache.lling.ateManager(RollingFileManager.java:608)
at org.apache.Manager(AbstractManager.java:113)
at org.apache.Manager(OutputStreamManager.java:115)
at org.apache.FileManager(RollingFileManager.java:188)
at org.apache.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:144)
at org.apache.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:60)
at org.apache.onfig.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
at org.apache.atePluginObject(AbstractConfiguration.java:958)
at org.apache.ateConfiguration(AbstractConfiguration.java:898)
at org.apache.ateConfiguration(AbstractConfiguration.java:890)
at org.apache.onfig.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)
at org.apache.onfig.AbstractConfiguration.initialize(AbstractConfiguration.java:237)
at org.apache.onfig.AbstractConfiguration.start(AbstractConfiguration.java:249)
at org.apache.LoggerContext.setConfiguration(LoggerContext.java:545)
at org.apache.LoggerContext.start(LoggerContext.java:261)
at org.elasticsearchmon.figure(LogConfigurator.java:166)
at org.elasticsearchmon.figure(LogConfigurator.java:122)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:307)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132)
at org.elasticsearch.ute(Elasticsearch.java:123)
at org.elasticsearch.ute(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)
2018-06-1215:13:50,296 main ERROR Could not create plugin of type class org.apache.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: ManagerFactory [org.apache.app at org.apache.Manager(AbstractManager.java:115)
at org.apache.Manager(OutputStreamManager.java:115)
at org.apache.FileManager(RollingFileManager.java:188)
at org.apache.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:144)
at org.apache.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:60)
at org.apache.onfig.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
at org.apache.atePluginObject(AbstractConfiguration.java:958)
at org.apache.ateConfiguration(AbstractConfiguration.java:898)
at org.apache.ateConfiguration(AbstractConfiguration.java:890)
at org.apache.onfig.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)
at org.apache.onfig.AbstractConfiguration.initialize(AbstractConfiguration.java:237)
at org.apache.onfig.AbstractConfiguration.start(AbstractConfiguration.java:249)
at org.apache.LoggerContext.setConfiguration(LoggerContext.java:545)
at org.apache.LoggerContext.start(LoggerContext.java:261)
at org.elasticsearchmon.figure(LogConfigurator.java:166)
at org.elasticsearchmon.figure(LogConfigurator.java:122)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:307)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132)
at org.elasticsearch.ute(Elasticsearch.java:123)
at org.elasticsearch.ute(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)
2018-06-1215:13:50,311 main ERROR Unable to invoke factory method in class org.apache.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: No factory method found for class
at org.apache.onfig.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:229)
at org.apache.onfig.plugins.util.PluginBuilder.build(PluginBuilder.java:134)
at org.apache.atePluginObject(AbstractConfiguration.java:958)
at org.apache.ateConfiguration(AbstractConfiguration.java:898)
at org.apache.ateConfiguration(AbstractConfiguration.java:890)
at org.apache.onfig.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)
at org.apache.onfig.AbstractConfiguration.initialize(AbstractConfiguration.java:237)
at org.apache.onfig.AbstractConfiguration.start(AbstractConfiguration.java:249)
at org.apache.LoggerContext.setConfiguration(LoggerContext.java:545)
at org.apache.LoggerContext.start(LoggerContext.java:261)
at org.elasticsearchmon.figure(LogConfigurator.java:166)
at org.elasticsearchmon.figure(LogConfigurator.java:122)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:307)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132)
at org.elasticsearch.ute(Elasticsearch.java:123)
at org.elasticsearch.ute(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)
解决:
原来在执⾏yum -y install elasticsearch的时候,就已经⾃动创建了⼀个单独的管理⽤户elasticsearch,但是我⼜⾃⼰创建了⼀个elk⽤户,并且把data和log⽬录授权给elk,所以
就会出现“Starting elasticsearch: 2018-06-12 15:13:50,287 main ERROR Unable to create file /var/log/elasticsearch/elk.log java.io.IOException: 权限不够”的报错。
因此只需要将/opt/elk/data和/var/log/elasticsearch⽬录权限改为elasticsearch:elasticsearch就好了:
然后重启服务成功:
[root@test101 init.d]# ./elasticsearch start
Starting elasticsearch: [ 确定 ]
[root@test101 init.d]# ps -ef|grep elasticsearch
elastic+ 515718015:49 ? 00:00:08 /usr/local/jdk1.8.0_151/bin/java -Xms512m -Xmx512m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server root 5177 921 0 15:50 pts/0 00:00:00 grep --color=auto elasticsearch
[root@test101 init.d]# netstat -tlunp|grep 9200
tcp6 0 0 :::9200 :::* LISTEN 5157/java
[root@test101 init.d]#
4、⽇志和数据⽬录权限异常,启动失败
在⼀次启动elasticsearch的时候启动失败,⽇志有提⽰“main ERROR Unable to create file /home/elk/l
ogs/my-application_index_indexing_slowlog.log java.io.IOException: 权限不够”和“Caused by: java.nio.file.AccessDeniedException: /home/elk/da [elk@docker bin]$ ./elasticsearch
2018-06-0401:15:07,609 main ERROR Unable to create file /home/elk/logs/my-application.log java.io.IOException: 权限不够
at java.ateFileExclusively(Native Method)
at java.ateNewFile(File.java:1012)
后⾯还有⼀段:
Caused by: java.lang.IllegalStateException: Failed to create node environment
at de.Node.<init>(Node.java:268) ~[elasticsearch-5.6.0.jar:5.6.0]
at de.Node.<init>(Node.java:245) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.bootstrap.Bootstrap$5.<init>(Bootstrap.java:233) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:233) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.0.jar:5.6.0]
... 6 more
Caused by: java.nio.file.AccessDeniedException: /home/elk/data/nodes
at sun.nio.anslateToIOException(UnixException.java:84) ~[?:?]
⽇志报的“/home/elk/data/”和“/home/elk/logs/”⽬录都是在l配置⽂件⾥⾯配置的两个⽬录,查看权限果然不对,权限是elk的⽬录权限是elk,但是下⾯的data⽬录和logs⽬录权限还是root,因此引起了启动失败:
[root@docker home]# ll
drwx------ 5 elk elk 125 6⽉317:35 elk #elk⽬录权限正常
[root@docker home]# cd elk/
[root@docker elk]# ll
总⽤量0
drwxr-xr-x 2 root root 6 6⽉317:34 data #下⾯的data和logs⽬录还是root
drwxr-xr-x 2 root root 6 6⽉317:34 logs
解决:
将⽬录权限修改成elk之后,启动就OK了
[root@docker elk]# chown elk:elk -R ./*
[root@docker elk]# ll
总⽤量 0
drwxr-xr-x 2 elk elk 6 6⽉ 3 17:34 data
drwxr-xr-x 2 elk elk 6 6⽉ 3 17:34 logs
[root@docker elk]#
5、内存不够,启动失败
在⼀次使⽤虚拟机做实验的过程中启动elasticsearch遇到了这样的报错:
[elk@docker bin]$ ./elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/local/elasticsearch-5.6.0/bin/hs_err_pid2819.log
解决:
原因:
查看了 /usr/local/elasticsearch-5.6.0/bin/hs_err_pid1027.log⽇志⽂件,出现这样的报错,有两种可能:
1、系统进程数达到上限了,部署服务的时候/etc/f⽂件修改没有⽣效。
java valueof2、确实物理内存不够
解决:
通过命令查看系统限制:ulimit -a查看open files不够⼤,如果不够⼤,就尝试通过设⼤该值:
[root@docker ~]# ulimit -n
1024
果然是部属的时候修改的/etc/f⽂件没有⽣效。于是将机器reboot了⼀下,在查看就⽣效了:)
将ulimit 值添加到/etc/profile⽂件中(适⽤于有root权限登录的系统)
为了每次系统重新启动时,都可以获取更⼤的ulimit值,将ulimit 加⼊到/etc/profile ⽂件底部。
echo ulimit -n 65535 >>/etc/profile
source /etc/profile #加载修改后的profile
ulimit -n #显⽰65535,修改完毕!
[root@docker ~]# ulimit -n
65536
但是在启动的时候还是报同样的错,查看了⼀下内存,这个虚拟机的内存只有1G,那应该就是物理内存不够了。⽬前还剩下这么多:
[root@docker ~]# free -h
total used free shared buff/cache available
Mem: 974M 119M 79M 7.7M 775M 680M
Swap: 819M 0B 819M
⼿动清理了⼀下内存:
[root@docker ~]# echo 3 > /proc/sys/vm/drop_caches
[root@docker ~]# free -h
total used free shared buff/cache available
Mem: 974M 114M 789M 7.7M 69M 739M
Swap: 819M 0B 819M
[root@docker ~]#
但是在启动报错依旧。
于是增加物理内存到2G:
[root@docker elk]# free -h
total used free shared buff/cache available
Mem: 1.8G 1.6G 77M 4K 72M 29M
Swap: 819M 691M 128M
然后切换到elk⽤户去启动服务,就OK了:
[elk@docker bin]$ ./elasticsearch #为了看启动⽇志就前台启动的,ctrl+c 进程就会over掉
检查端⼝,起来了
[root@docker elk]# netstat -tlunp|grep 9200
tcp6 0010.0.0.16:9200 :::* LISTEN 9628/java
[root@docker elk]#
然后关掉进程重新后台启动:
[elk@docker bin]$ nohup ./elasticsearch >/dev/null2>&1 & #后台启动
[2] 9808
[elk@docker bin]$ ps -ef|grep elasticsearch #检查进程
elk 980841151001:29 pts/000:00:23 /usr/local/jdk1.8.0_151/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss elk 9890 4115 0 01:32 pts/0 00:00:00 grep --color=auto elasticsearch
[elk@docker bin]$
[root@docker elk]# netstat -tlunp|grep 9200 #⽤root⽤户检查端⼝
tcp6 0 0 10.0.0.16:9200 :::* LISTEN 9808/java
[root@docker elk]#
6、 l的bind的IP写错,服务起不来
在⼀次安装 elasticsearc的时候,服务起不来,提⽰“Failed to bind to [9300-9400]”。启动服务报下⾯的错误:
[elk@host1 bin]$ ./elasticsearch
[2018-06-15T09:56:53,019][INFO ][Node ] [node1] initializing ...
[2018-06-15T09:56:53,141][INFO ][NodeEnvironment ] [node1] using [1] data paths, mounts [[/data (/dev/mapper/data-data)]], net usable_space [179.8gb], net total_space [179.9gb], spins? [possibly], types [xfs]
[2018-06-15T09:56:53,142][INFO ][NodeEnvironment ] [node1] heap size [1.9gb], compressed ordinary object pointers [true]
[2018-06-15T09:56:53,143][INFO ][Node ] [node1] node name [node1], node ID [F0PzQ9qSRPWq8YNcwjj0vg]
[2018-06-15T09:56:53,144][INFO ][Node ] [node1] version[5.6.0], pid[27627], build[781a835/2017-09-07T03:09:58.087Z], OS[Linux/3.10.0-514.el7.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8
[2018-06-15T09:56:53,144][INFO ][Node ] [node1] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOcc
upancyOnly, -XX:+AlwaysPreTouch, -Xss [2018-06-15T09:56:54,161][INFO ][o.e.p.PluginsService ] [node1] loaded module [aggs-matrix-stats]
[2018-06-15T09:56:54,162][INFO ][o.e.p.PluginsService ] [node1] loaded module [ingest-common]
[2018-06-15T09:56:54,162][INFO ][o.e.p.PluginsService ] [node1] loaded module [lang-expression]
[2018-06-15T09:56:54,162][INFO ][o.e.p.PluginsService ] [node1] loaded module [lang-groovy]
[2018-06-15T09:56:54,162][INFO ][o.e.p.PluginsService ] [node1] loaded module [lang-mustache]
[2018-06-15T09:56:54,162][INFO ][o.e.p.PluginsService ] [node1] loaded module [lang-painless]
[2018-06-15T09:56:54,163][INFO ][o.e.p.PluginsService ] [node1] loaded module [parent-join]
[2018-06-15T09:56:54,163][INFO ][o.e.p.PluginsService ] [node1] loaded module [percolator]
[2018-06-15T09:56:54,163][INFO ][o.e.p.PluginsService ] [node1] loaded module [reindex]
[2018-06-15T09:56:54,163][INFO ][o.e.p.PluginsService ] [node1] loaded module [transport-netty3]
[2018-06-15T09:56:54,163][INFO ][o.e.p.PluginsService ] [node1] loaded module [transport-netty4]
[2018-06-15T09:56:54,164][INFO ][o.e.p.PluginsService ] [node1] no plugins loaded
[2018-06-15T09:56:55,941][INFO ][o.e.d.DiscoveryModule ] [node1] using discovery type [zen]
[2018-06-15T09:56:56,770][INFO ][Node ] [node1] initialized
[2018-06-15T09:56:56,770][INFO ][Node ] [node1] starting ...
[2018-06-15T09:56:57,059][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node1] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: BindTransportException[Failed to bind to [9300-9400]]; nested: BindException[Cannot assign requested address];
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.ute(Elasticsearch.java:123) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.ute(EnvironmentAwareCommand.java:67) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.0.jar:5.6.0]
Caused by: ansport.BindTransportException: Failed to bind to [9300-9400]
at ansport.TcpTransport.bindToPort(TcpTransport.java:771) ~[elasticsearch-5.6.0.jar:5.6.0]
at ansport.TcpTransport.bindServer(TcpTransport.java:736) ~[elasticsearch-5.6.0.jar:5.6.0]
at ansportty4.Netty4Transport.doStart(Netty4Transport.java:173) ~[?:?]
at org.elasticsearchmonponent.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:69) ~[elasticsearch-5.6.0.jar:5.6.0]
at ansport.TransportService.doStart(TransportService.java:209) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearchmonponent.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:69) ~[elasticsearch-5.6.0.jar:5.6.0]
at de.Node.start(Node.java:694) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:278) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:351) ~[elasticsearch-5.6.0.jar:5.6.0]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.0.jar:5.6.0]
... 6 more
Caused by: java.BindException: Cannot assign requested address
at sun.nio.ch.Net.bind0(Native Method) ~[?:?]
at sun.nio.ch.Net.bind(Net.java:433) ~[?:?]
at sun.nio.ch.Net.bind(Net.java:425) ~[?:?]
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[?:?]
at ioty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:128) ~[?:?]
at ioty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:554) ~[?:?]
at ioty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1258) ~[?:?]
at ioty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:
501) ~[?:?]
at ioty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486) ~[?:?]
at ioty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:980) ~[?:?]
at ioty.channel.AbstractChannel.bind(AbstractChannel.java:250) ~[?:?]
at ioty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:365) ~[?:?]
at urrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[?:?]
at urrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403) ~[?:?]
at ioty.channel.nio.NioEventLoop.run(NioEventLoop.java:462) ~[?:?]
at urrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) ~[?:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
[2018-06-15T09:56:57,822][INFO ][Node ] [node1] stopping ...
[2018-06-15T09:56:57,826][INFO ][Node ] [node1] stopped
[2018-06-15T09:56:57,826][INFO ][Node ] [node1] closing ...
[2018-06-15T09:56:57,839][INFO ][Node ] [node1] closed
[elk@host1 bin]$
[elk@host1 bin]$
[root@host1 bin]# netstat -tlunp|grep 9300
[root@host1 bin]# netstat -tlunp|grep 9200
[root@host1 bin]#
解决:
开始以为是端⼝被占⽤了,检查端⼝,发现并没有被占⽤:
[root@host1 bin]# netstat -tlunp|grep 9300
[root@host1 bin]# netstat -tlunp|grep 9200
[root@host1 bin]#
然后检查配置,发现 l⽂件⾥⾯有⼀⾏的IP写错了:
network.host: 10.0.0.10 #这⼀⾏的IP地址写错了,不是本机IP
修改l⽂件,将IP改正确,重新启动服务,就OK了
7、配置⽂件l的权限异常,导致启动失败
有⼀次在安装elasticsearch的时候,因为l⽂件改得有问题,就从原来备份的l.bak⽂件cp重新⽣成了⼀份l,改好之后启动报错
不能加载配置⽂件:
[elk@es bin]$ ./elasticsearch
Exception in thread "main"2018-09-1409:04:49,470 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging. SettingsException[Failed to load settings from /usr/local/elasticsearch-5.6.0/l]; nested: AccessDeniedException[/usr/local/elasticsearch-5.6.0/l];
at de.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:102)
at org.elasticsearch.ateEnv(EnvironmentAwareCommand.java:72)
at org.elasticsearch.ute(EnvironmentAwareCommand.java:67)
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-5.6.0/l
at sun.nio.anslateToIOException(UnixException.java:84)
at sun.nio.hrowAsIOException(UnixException.java:102)
at sun.nio.hrowAsIOException(UnixException.java:107)
at sun.nio.wByteChannel(UnixFileSystemProvider.java:214)
at java.nio.wByteChannel(Files.java:361)
at java.nio.wByteChannel(Files.java:407)
at java.nio.file.wInputStream(FileSystemProvider.java:384)
at java.nio.wInputStream(Files.java:152)
at org.elasticsearchmon.settings.Settings$Builder.loadFromPath(Settings.java:1032)
at de.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:100)
原来新⽣成的配置⽂件l还是root权限,⽤elk⽤户去启动,当然加载不了:
[root@es config]# ll
total 20
-rw-r----- 1 root root 2961 Sep 1409:l
-rw-r----- 1 elk elk 2854 Sep 1408:l.bak
-rw-rw---- 1 elk elk 3064 Sep 72017 jvm.options
-rw-rw---- 1 elk elk 4456 Sep 72017 log4j2.properties
[root@es config]#
解决:
修改配置⽂件l的权限,再重新启动就好了:
[root@es config]# chown elk:l
[root@es config]# ll
total 20
-rw-r----- 1 elk elk 2961 Sep 1409:l
-rw-r----- 1 elk elk 2854 Sep 1408:l.bak
-rw-rw---- 1 elk elk 3064 Sep 72017 jvm.options
-rw-rw---- 1 elk elk 4456 Sep 72017 log4j2.properties
[root@es config]#
8、yum安装的elasticsearch,不到java路径,启动失败
今天使⽤yum安装elasticsearch的过程中,发现elasticsearch起不来,messages⽇志有如下的报错:
May 3114:00:19 test103 systemd: Started Elasticsearch.
May 3114:00:19 test103 systemd:
May 3114:00:19 test103 elasticsearch: which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin) #elasticsearch在这个路径下⾯去java,没有到
May 3114:00:19 test103 systemd: elasticsearch.service: main process exited, code=exited, status=1/FAILURE
May 3114:00:19 test103 elasticsearch: warning: Falling back to java on path. This behavior is deprecated. Specify JAVA_HOME
May 3114:00:19 test103 elasticsearch: could not find java; set JAVA_HOME
May 3114:00:19 test103 systemd: Unit elasticsearch.service entered failed state.
May 3114:00:19 test103 systemd: elasticsearch.service failed.
报错说不到java,但是实际上我是安装过jdk了,查看当前java路径为:
[root@test103 ~]# whereis java
java: /usr/local/jdk1.8.0_151/bin/java
[root@test103 ~]#
然后查看/usr/local/sbin/⽬录下没有java,所以elasticsearch在启动的时候不到java路径。
解决:
把/usr/local/jdk1.8.0_151/bin/java做了个软连接到 /usr/local/sbin下⾯:
[root@test103 sbin]# ln -s /usr/local/jdk1.8.0_151/bin/java /usr/local/sbin/java
[root@test103 sbin]# ll
总⽤量0
lrwxrwxrwx 1 root root 32 5⽉3114:01 java -> /usr/local/jdk1.8.0_151/bin/java
现在查看java路径,就有/usr/local/sbin/java了:
[root@test103 sbin]# whereis java
java: /usr/local/sbin/java /usr/local/jdk1.8.0_151/bin/java
[root@test103 sbin]#
然后重新启动elasticsearch,发现就可以正常启动了:
[root@test103 sbin]# systemctl start elasticsearch
[root@test103 sbin]# ps -ef|grep elasticsearch
elastic+ 1363517014:02 ? 00:00:12 /usr/local/sbin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -l=60 -Desworka elastic+ 13692 13635 0 14:02 ? 00:00:00 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
root 13698 10140 0 14:02 pts/0 00:00:00 grep --color=auto elasticsearch
[root@test103 sbin]# netstat -tlunp|grep 9300
tcp6 0 0 10.0.0.103:9300 :::* LISTEN 13635/java
[root@test103 sbin]# netstat -tlunp|grep 9200
tcp6 0 0 10.0.0.103:9200 :::* LISTEN 13635/java
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论