总结—elasticsearch启动失败的几种情况及解决

湖蓝几何球体LinkedIn Banner.png
转载说明:如果您喜欢这篇文章并打算转载它,请私信作者取得授权。感谢您喜爱本文,请文明转载,谢谢。


摘要

本文主要梳理从ES初学以来所遇到的启动失败的几种情况。

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 rootat org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-6.1.1.jar:6.1.1]at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-6.1.1.jar:6.1.1]at org.elasticsearch.cli.EnvironmentAwareCommand.execute(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 rootat 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-03 17: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-03 17: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.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:389)at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:167)at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:140)at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:556)at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:617)at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634)at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229)at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)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:618)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:42)at org.elasticsearch.ElasticsearchException.toString(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/config/elasticsearch.yml]; nested: AccessDeniedException[/usr/local/elasticsearch-5.6.0/config/elasticsearch.yml];at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:102)at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:72)at org.elasticsearch.cli.EnvironmentAwareCommand.execute(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/config/elasticsearch.ymlat 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:1032)at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:100)... 6 more
[elk@docker bin]$ 

解决:

看到“Caused by: java.nio.file.AccessDeniedException: /usr/local/elasticsearch-5.6.0/config/elasticsearch.yml”的提示,就去检查目录的权限,果然是root:root权限,使用elk用户去启动,就报错了。
将目录的权限改成elk:elk就好了。

[root@docker ~]# ll /usr/local/
drwxr-xr-x  7 root root       123 9月   7 2017 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月   7 2017 elasticsearch-5.6.0

3、使用yum安装方式,赋权错误,启动失败

在一次使用yum安装elasticsearch的时候,执行完yum -y install elasticsearch 命令后,进行了下面的操作:
1、修改elasticsearch.yml文件
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-12 15:13:50,287 main ERROR Unable to create file /var/log/elasticsearch/elk.log java.io.IOException: 权限不够at java.io.UnixFileSystem.createFileExclusively(Native Method)at java.io.File.createNewFile(File.java:1012)at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:628)at org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory.createManager(RollingFileManager.java:608)at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:113)at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:115)at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188)at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:144)at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:60)at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958)at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898)at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237)at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:166)at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:122)at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:307)at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132)at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123)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)2018-06-12 15:13:50,296 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@16293aa2] unable to create manager for [/var/log/elasticsearch/elk.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@5158b42f[pattern=/var/log/elasticsearch/elk-%d{yyyy-MM-dd}.log, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true)]), strategy=DefaultRolloverStrategy(min=1, max=7, useMax=true), advertiseURI=null, layout=[%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n, filePermissions=null, fileOwner=null]] java.lang.IllegalStateException: ManagerFactory [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$RollingFileManagerFactory@16293aa2] unable to create manager for [/var/log/elasticsearch/elk.log] with data [org.apache.logging.log4j.core.appender.rolling.RollingFileManager$FactoryData@5158b42f[pattern=/var/log/elasticsearch/elk-%d{yyyy-MM-dd}.log, append=true, bufferedIO=true, bufferSize=8192, policy=CompositeTriggeringPolicy(policies=[TimeBasedTriggeringPolicy(nextRolloverMillis=0, interval=1, modulate=true)]), strategy=DefaultRolloverStrategy(min=1, max=7, useMax=true), advertiseURI=null, layout=[%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n, filePermissions=null, fileOwner=null]]at org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:115)at org.apache.logging.log4j.core.appender.OutputStreamManager.getManager(OutputStreamManager.java:115)at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.getFileManager(RollingFileManager.java:188)at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:144)at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:60)at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958)at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898)at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237)at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:166)at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:122)at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:307)at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132)at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123)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)2018-06-12 15:13:50,311 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.RollingFileAppender for element RollingFile: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.RollingFileAppenderat org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:229)at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:134)at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958)at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898)at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237)at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:166)at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:122)at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:307)at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132)at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123)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)

解决:

原来在执行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+   5157      1 80 15:49 ?        00:00:08 /usr/local/jdk1.8.0_151/bin/java -Xms512m -Xmx512m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -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/share/elasticsearch -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -p /var/run/elasticsearch/elasticsearch.pid -d -Edefault.path.logs=/var/log/elasticsearch -Edefault.path.data=/var/lib/elasticsearch -Edefault.path.conf=/etc/elasticsearch
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/logs/my-application_index_indexing_slowlog.log java.io.IOException: 权限不够”和“Caused by: java.nio.file.AccessDeniedException: /home/elk/data/nodes”。关键日志信息如下(下面两段日志是节选的,日志信息太多了,有很多重复的):

[elk@docker bin]$ ./elasticsearch
2018-06-04 01:15:07,609 main ERROR Unable to create file /home/elk/logs/my-application.log java.io.IOException: 权限不够at java.io.UnixFileSystem.createFileExclusively(Native Method)at java.io.File.createNewFile(File.java:1012)

后面还有一段:

 Caused by: java.lang.IllegalStateException: Failed to create node environmentat org.elasticsearch.node.Node.<init>(Node.java:268) ~[elasticsearch-5.6.0.jar:5.6.0]at org.elasticsearch.node.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/nodesat sun.nio.fs.UnixException.translateToIOException(UnixException.java:84) ~[?:?]

日志报的“/home/elk/data/”和“/home/elk/logs/”目录都是在elasticsearch.yml配置文件里面配置的两个目录,查看权限果然不对,权限是elk的目录权限是elk,但是下面的data目录和logs目录权限还是root,因此引起了启动失败:

[root@docker home]# ll 
drwx------  5 elk    elk         125 6月   3 17:35 elk       #elk目录权限正常
[root@docker home]# cd elk/
[root@docker elk]# ll
总用量 0
drwxr-xr-x 2 root root 6 6月   3 17:34 data      #下面的data和logs目录还是root
drwxr-xr-x 2 root root 6 6月   3 17: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/security/limits.conf文件修改没有生效。
2、确实物理内存不够

解决:
通过命令查看系统限制:ulimit -a查看open files不够大,如果不够大,就尝试通过设大该值:

[root@docker ~]# ulimit -n
1024

果然是部属的时候修改的/etc/security/limits.conf文件没有生效。于是将机器reboot了一下,在查看就生效了:

[root@docker ~]# ulimit -n
65536

但是在启动的时候还是报同样的错,查看了一下内存,这个虚拟机的内存只有1G,那应该就是物理内存不够了。目前还剩下这么多:

[root@docker ~]# free -htotal        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 -htotal        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 -htotal        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       0      0 10.0.0.16:9200          :::*                    LISTEN      9628/java           
[root@docker elk]# 

然后关掉进程重新后台启动:

[elk@docker bin]$ nohup ./elasticsearch >/dev/null 2>&1 &     #后台启动
[2] 9808
[elk@docker bin]$ ps -ef|grep elasticsearch   #检查进程
elk        9808   4115 10 01:29 pts/0    00:00:23 /usr/local/jdk1.8.0_151/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -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-5.6.0 -cp /usr/local/elasticsearch-5.6.0/lib/* org.elasticsearch.bootstrap.Elasticsearch
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、 elasticsearch.yml的bind的IP写错,服务起不来

在一次安装 elasticsearc的时候,服务起不来,提示“Failed to bind to [9300-9400]”。启动服务报下面的错误:


[elk@host1 bin]$ ./elasticsearch
[2018-06-15T09:56:53,019][INFO ][o.e.n.Node               ] [node1] initializing ...
[2018-06-15T09:56:53,141][INFO ][o.e.e.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 ][o.e.e.NodeEnvironment    ] [node1] heap size [1.9gb], compressed ordinary object pointers [true]
[2018-06-15T09:56:53,143][INFO ][o.e.n.Node               ] [node1] node name [node1], node ID [F0PzQ9qSRPWq8YNcwjj0vg]
[2018-06-15T09:56:53,144][INFO ][o.e.n.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.0_102/25.102-b14]
[2018-06-15T09:56:53,144][INFO ][o.e.n.Node               ] [node1] 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-5.6.0]
[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 ][o.e.n.Node               ] [node1] initialized
[2018-06-15T09:56:56,770][INFO ][o.e.n.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.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.0.jar:5.6.0]at org.elasticsearch.cli.EnvironmentAwareCommand.execute(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: org.elasticsearch.transport.BindTransportException: Failed to bind to [9300-9400]at org.elasticsearch.transport.TcpTransport.bindToPort(TcpTransport.java:771) ~[elasticsearch-5.6.0.jar:5.6.0]at org.elasticsearch.transport.TcpTransport.bindServer(TcpTransport.java:736) ~[elasticsearch-5.6.0.jar:5.6.0]at org.elasticsearch.transport.netty4.Netty4Transport.doStart(Netty4Transport.java:173) ~[?:?]at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:69) ~[elasticsearch-5.6.0.jar:5.6.0]at org.elasticsearch.transport.TransportService.doStart(TransportService.java:209) ~[elasticsearch-5.6.0.jar:5.6.0]at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:69) ~[elasticsearch-5.6.0.jar:5.6.0]at org.elasticsearch.node.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.net.BindException: Cannot assign requested addressat 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 io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:128) ~[?:?]at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:554) ~[?:?]at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1258) ~[?:?]at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501) ~[?:?]at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486) ~[?:?]at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:980) ~[?:?]at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:250) ~[?:?]at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:365) ~[?:?]at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) ~[?:?]at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403) ~[?:?]at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462) ~[?:?]at io.netty.util.concurrent.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 ][o.e.n.Node               ] [node1] stopping ...
[2018-06-15T09:56:57,826][INFO ][o.e.n.Node               ] [node1] stopped
[2018-06-15T09:56:57,826][INFO ][o.e.n.Node               ] [node1] closing ...
[2018-06-15T09:56:57,839][INFO ][o.e.n.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]#

然后检查配置,发现 elasticsearch.yml文件里面有一行的IP写错了:

network.host: 10.0.0.10   #这一行的IP地址写错了,不是本机IP

修改elasticsearch.yml文件,将IP改正确,重新启动服务,就OK了

7、配置文件elasticsearch.yml的权限异常,导致启动失败

有一次在安装elasticsearch的时候,因为elasticsearch.yml文件改得有问题,就从原来备份的elasticsearch.yml.bak文件cp重新生成了一份elasticsearch.yml,改好之后启动报错不能加载配置文件:

[elk@es bin]$ ./elasticsearch
Exception in thread "main" 2018-09-14 09: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/config/elasticsearch.yml]; nested: AccessDeniedException[/usr/local/elasticsearch-5.6.0/config/elasticsearch.yml];at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:102)at org.elasticsearch.cli.EnvironmentAwareCommand.createEnv(EnvironmentAwareCommand.java:72)at org.elasticsearch.cli.EnvironmentAwareCommand.execute(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/config/elasticsearch.ymlat 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:1032)at org.elasticsearch.node.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:100)... 6 more
[elk@es bin]$ 

原来新生成的配置文件elasticsearch.yml还是root权限,用elk用户去启动,当然加载不了:

[root@es config]# ll
total 20
-rw-r----- 1 root root 2961 Sep 14 09:04 elasticsearch.yml
-rw-r----- 1 elk  elk  2854 Sep 14 08:49 elasticsearch.yml.bak
-rw-rw---- 1 elk  elk  3064 Sep  7  2017 jvm.options
-rw-rw---- 1 elk  elk  4456 Sep  7  2017 log4j2.properties
[root@es config]# 

解决:

修改配置文件elasticsearch.yml的权限,再重新启动就好了:

[root@es config]# chown elk:elk elasticsearch.yml
[root@es config]# ll
total 20
-rw-r----- 1 elk elk 2961 Sep 14 09:04 elasticsearch.yml
-rw-r----- 1 elk elk 2854 Sep 14 08:49 elasticsearch.yml.bak
-rw-rw---- 1 elk elk 3064 Sep  7  2017 jvm.options
-rw-rw---- 1 elk elk 4456 Sep  7  2017 log4j2.properties
[root@es config]# 

8、yum安装的elasticsearch,找不到java路径,启动失败

今天使用yum安装elasticsearch的过程中,发现elasticsearch起不来,messages日志有如下的报错:

May 31 14:00:19 test103 systemd: Started Elasticsearch.
May 31 14:00:19 test103 systemd: Starting Elasticsearch...
May 31 14:00:19 test103 elasticsearch: which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)   #elasticsearch在这个路径下面去找java,没有找到
May 31 14:00:19 test103 systemd: elasticsearch.service: main process exited, code=exited, status=1/FAILURE
May 31 14:00:19 test103 elasticsearch: warning: Falling back to java on path. This behavior is deprecated. Specify JAVA_HOME
May 31 14:00:19 test103 elasticsearch: could not find java; set JAVA_HOME
May 31 14:00:19 test103 systemd: Unit elasticsearch.service entered failed state.
May 31 14: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月  31 14: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+  13635      1 70 14:02 ?        00:00:12 /usr/local/sbin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch-7859403592413850651 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/lib/elasticsearch -XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/log/elasticsearch/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Des.path.home=/usr/share/elasticsearch -Des.path.conf=/etc/elasticsearch -Des.distribution.flavor=default -Des.distribution.type=rpm -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -p /var/run/elasticsearch/elasticsearch.pid --quiet
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          
[root@test103 sbin]# 

更多链接:《升级Elasticsearch到8.7.1版本,我给自己挖了很多坑…》

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/589692.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Linux】—— 匿名管道

前言&#xff1a; 接下来我将带大家探索 进程间通信 的方式。本期&#xff0c;要讲的就是管道其中之一“匿名管道”&#xff01;&#xff01; 目录 &#xff08;一&#xff09;进程间通信介绍 1、进程间通信目的 2、进程间通信发展 3、进程间通信分类 &#xff08;二&…

文件分片上传(模拟网盘效果)

文件分片上传&#xff08;模拟网盘效果&#xff09; 文章说明简单模拟拖拽文件夹和选择文件的进度条效果效果展示结合后端实现文件上传效果展示加上分片的效果效果展示加上MD5的校验&#xff0c;实现秒传和分片的效果后续开发说明源码下载 文章说明 文章主要为了学习文件上传&a…

2024年【黑龙江省安全员C证】考试及黑龙江省安全员C证找解析

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 2024年黑龙江省安全员C证考试为正在备考黑龙江省安全员C证操作证的学员准备的理论考试专题&#xff0c;每个月更新的黑龙江省安全员C证找解析祝您顺利通过黑龙江省安全员C证考试。 1、【多选题】下列属于编制安全检查…

浅聊配置化-要不要实现动态表单

1、配置化的原则 配置化是一种抽象&#xff0c;把事物分成2类&#xff1a;不变的&#xff0c;可变的。 如果事物都是可变的&#xff0c;是无法实现配置化的。 配置化的根本在于找到不变的事物&#xff0c;基于不变的事物进行可变事物的配置。 所以&#xff0c;认为一切皆可…

[LLM]大模型训练(二)--DeepSpeed使用

安装DeepSpeed与集成 DeepSpeed可以通过pip安装&#xff0c;无需指定PyTorch和CUDA的版本。DeepSpeed内包含需要自定义的CUDA算子&#xff0c;将通过即时编译的方式在运行时构建。 pip install deepspeed DeepSpeed与HuggingFace Transformers直接集成。使用者可以通过在模型…

从入门到精通,30天带你学会C++【第十一天:二分查找】

目录 Everyday English 前言 二分查找 例题 50分做法 分析利弊 示例代码 示例截图 100分做法 二分查找是什么&#xff1f; 这题该怎么用二分查找&#xff1f; 示例代码 示例截图 结尾 Everyday English Look before you leap. 三思而后行 前言 今天是2024年的…

爬取糖豆视频

爬虫案例积累&#xff0c;以爬取糖豆视频为例&#xff1a; 爬取视频类型的数据一般步骤&#xff1a; 1.点击media,刷新&#xff0c;播放一个视频&#xff0c;会刷新一个包&#xff0c;点击发现是播放视频的包&#xff0c; 2.复制这个包url中的关键字&#xff0c;在搜索框中进…

在宝塔Linux中安装Docker

前言 帮助使用宝塔的用户快速上手docke的安装 &#x1f4da;&#x1f4da; &#x1f3c5;我是默&#xff0c;一个在CSDN分享笔记的博主。&#x1f4da;&#x1f4da; ​​​​ &#x1f31f;在这里&#xff0c;我要推荐给大家我的专栏《Docker》。&#x1f3af;&#x1f3af…

[新版Hi3531DV200 性能强悍]

新版Hi3531DV200 性能强悍 Hi3531DV200是针对多路高清/超高清&#xff08;1080p/4M/5M/4K&#xff09;DVR产品应用开发的新一代专业SoC芯片。Hi3531DV200集成了ARM A53四核处理器和性能强大的神经网络推理引擎&#xff0c;支持多种智能算法应用。同时&#xff0c;Hi3531DV200还…

Spring Boot Admin健康检查引起的Spring Boot服务假死

问题现象 最近在spring boot项目中引入了 spring-boot-starter-actuator 后&#xff0c;测试环境开始出现服务假死的现象&#xff0c; 且这个问题十分怪异&#xff0c;只在多个微服务中的简称A的这个服务中出现&#xff0c;其他服务都没有出现这个问题&#xff0c; 之所以说…

按照故障码类型分类的API接口

随着汽车的普及&#xff0c;车辆故障也成为了一个不可忽视的问题。对于车主来说&#xff0c;及时了解故障码的含义以及解决方案十分重要。挖数据平台为解决这一问题&#xff0c;提供了一套按照故障码类型分类的API接口&#xff0c;用于查询车辆故障、故障码适用品牌以及提供相应…

STL——queue容器

1.queue基本概念 概念&#xff1a;queue是一种先进先出&#xff08;First In First Out,FIFO&#xff09;的数据结构&#xff0c;它有两个出口。 队列容器允许从一端新增元素&#xff0c;从另一端移除元素。 队列中只有队头和队尾才可以被外界使用&#xff0c;因此队列不允许…

Java API 操作Docker浅谈

背景&#xff1a; 使用com.github.docker-java库可以很方便地在Java中操作Docker。下面是一个详细的教程&#xff0c;包括创建镜像、创建容器、启动容器、停止容器和删除容器的步骤以及每一步的说明。 前提&#xff1a; 首先&#xff0c;在你的Java项目中添加com.github.doc…

Linux之组管理和权限管理

组的概念 如图所示&#xff1a;test.txt是由tom创建的&#xff0c;所以tom是文件的所有者&#xff0c;tom归属于组A&#xff0c;组A就是文件的所在组&#xff1b;组B就是文件的其他组。 所有者 谁创建了文件&#xff0c;谁就是文件的所有者。 查看文件的所有者 指令&…

Django 学习教程- Hello world入门案例

系列 Django 学习教程-介绍与安装-CSDN博客 欢迎来到第Djagno学习教程第二章Hello World 入门案例。 在本教程中&#xff0c;我将引导您完成django的Hello World入门案例。 让我们开始吧&#xff01; 版本 Django 5.0Python 3.10 创建项目 安装 Django 之后&#xff0…

信创之国产浪潮电脑+统信UOS Linux操作系统体验10:visual studio code中调试C++程序

☞ ░ 前往老猿Python博客 ░ https://blog.csdn.net/LaoYuanPython 一、引言 老猿在CSDN的《信创之国产浪潮电脑统信UOS操作系统体验2&#xff1a;安装visual studio code和cmake搭建C开发环镜》介绍了在国产浪潮电脑统信UOS操作系统中安装visual studio code和cmake搭建C开…

css动态传参,attr的妙用

今天再做一个编辑器的功能的时候&#xff0c;发现有一段非常奇妙的代码&#xff0c;使用attr获取div标签的data-label值。 css的attr?What fuck?这又是什么鬼东西&#xff0c;emmm。 查询后官方是这么回答的&#xff1a; CSS 表达式 attr() 用来获取选择到的元素的某一 HTM…

GO语言基础笔记(八):高级特性与性能优化

目录 反射&#xff08;Reflection&#xff09; 反射概念 反射的关键概念 反射的常见用途 代码示例 1. 检查类型和值 2. 修改变量值 3. 调用函数 4. 结构体反射 并发模式&#xff08;Concurrency Patterns&#xff09; 1. Worker Pool 模式 工作原理 在代码中的体现…

Unity坦克大战开发全流程——结束场景——通关界面

结束场景——通关界面 就照着这样来拼 写代码 hideme不要忘了 修改上一节课中的代码

动态内存管理篇

为什么要动态内存分配&#xff1f; 之前&#xff0c;我们向内存申请空间&#xff0c;有两种方式&#xff0c;一种是定义变量&#xff0c;一种是建立数组&#xff1b;但是&#xff0c;这两种方式都有缺陷&#xff0c;创建的空间大小是固定的&#xff0c;在程序的运行过程中&…