前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >elastic search 日志不打印问题(root用户惹的祸)

elastic search 日志不打印问题(root用户惹的祸)

作者头像
MickyInvQ
发布2020-09-27 11:19:40
8810
发布2020-09-27 11:19:40
举报
文章被收录于专栏:InvQ的专栏InvQ的专栏
案发现场

之前测试同学启动es,用了root 没起来报错如下,

代码语言:javascript
复制
java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.4.1.jar:5.4.1]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:194) ~[elasticsearch-5.4.1.jar:5.4.1]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:350) [elasticsearch-5.4.1.jar:5.4.1]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:123) [elasticsearch-5.4.1.jar:5.4.1]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:114) [elasticsearch-5.4.1.jar:5.4.1]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:67) [elasticsearch-5.4.1.jar:5.4.1]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) [elasticsearch-5.4.1.jar:5.4.1]
        at org.elasticsearch.cli.Command.main(Command.java:88) [elasticsearch-5.4.1.jar:5.4.1]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.4.1.jar:5.4.1]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.4.1.jar:5.4.1]

后来日志一直没有打印,排查问题成了问题。 通过观察发现如下

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
elasticsearch不能以root运行

当我们在使用elasticsearch的时候,如果是以root权限来执行elasticsearch

这是出于系统安全考虑设置的条件。由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考虑, 建议创建一个单独的用户用来运行ElasticSearch

创建elsearch用户组及elsearch用户
代码语言:javascript
复制
group add elsearch
user add elsearch -g elsearch -p elasticsearch

更改elasticsearch文件夹及内部文件的所属用户及组为elsearch:elsearch

代码语言:javascript
复制
chown -R elsearch:elsearch  elasticsearch

elasticsearch为你elasticsearch的目录名称

改后重新用elsearch用户启动
在这里插入图片描述
在这里插入图片描述
代码语言:javascript
复制
[elastic@bin]$ sh elasticsearch
[2020-05-19T20:00:01,716][INFO ][o.e.n.Node               ] [node-8] initializing ...
[2020-05-19T20:00:02,323][INFO ][o.e.e.NodeEnvironment    ] [node-8] using [1] data paths, mounts [[/data (/dev/vdb1)]], net usable_space [128.4gb], net total_space [196.7gb], spins? [possibly], types [ext4]
[2020-05-19T20:00:02,324][INFO ][o.e.e.NodeEnvironment    ] [node-8] heap size [1.9gb], compressed ordinary object pointers [true]
[2020-05-19T20:00:02,472][INFO ][o.e.n.Node               ] [node-8] node name [node-8], node ID [Oy0B1GOwT8CoPLQOq8JrBQ]
[2020-05-19T20:00:02,473][INFO ][o.e.n.Node               ] [node-8] version[5.4.1], pid[10493], build[2cfe0df/2017-05-29T16:05:51.443Z], OS[Linux/2.6.32-642.el6.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_45/25.45-b02]
[2020-05-19T20:00:02,473][INFO ][o.e.n.Node               ] [node-8] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+DisableExplicitGC, -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=/data/local/elasticsearch-5.4.1]
[2020-05-19T20:00:03,841][INFO ][o.e.p.PluginsService     ] [node-8] loaded module [aggs-matrix-stats]
[2020-05-19T20:00:03,841][INFO ][o.e.p.PluginsService     ] [node-8] loaded module [ingest-common]
[2020-05-19T20:00:03,841][INFO ][o.e.p.PluginsService     ] [node-8] loaded module [lang-expression]
[2020-05-19T20:00:03,842][INFO ][o.e.p.PluginsService     ] [node-8] loaded module [lang-groovy]
[2020-05-19T20:00:03,842][INFO ][o.e.p.PluginsService     ] [node-8] loaded module [lang-mustache]
[2020-05-19T20:00:03,842][INFO ][o.e.p.PluginsService     ] [node-8] loaded module [lang-painless]
[2020-05-19T20:00:03,846][INFO ][o.e.p.PluginsService     ] [node-8] loaded module [percolator]
[2020-05-19T20:00:03,846][INFO ][o.e.p.PluginsService     ] [node-8] loaded module [reindex]
[2020-05-19T20:00:03,846][INFO ][o.e.p.PluginsService     ] [node-8] loaded module [transport-netty3]
[2020-05-19T20:00:03,846][INFO ][o.e.p.PluginsService     ] [node-8] loaded module [transport-netty4]
[2020-05-19T20:00:03,847][INFO ][o.e.p.PluginsService     ] [node-8] loaded plugin [analysis-ik]
[2020-05-19T20:00:03,847][INFO ][o.e.p.PluginsService     ] [node-8] loaded plugin [analysis-pinyin]
[2020-05-19T20:00:06,351][INFO ][o.e.d.DiscoveryModule    ] [node-8] using discovery type [zen]
[2020-05-19T20:00:07,537][INFO ][o.e.n.Node               ] [node-8] initialized
[2020-05-19T20:00:07,537][INFO ][o.e.n.Node               ] [node-8] starting ...
[2020-05-19T20:00:07,739][INFO ][o.e.t.TransportService   ] [node-8] publish_address {10.20.30.40:9300}, bound_addresses {10.20.30.40:9300}
[2020-05-19T20:00:07,747][INFO ][o.e.b.BootstrapChecks    ] [node-8] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2020-05-19T20:00:10,840][INFO ][o.e.c.s.ClusterService   ] [node-8] new_master {node-8}{Oy0B1GOwT8CoPLQOq8JrBQ}{R3UnviE0TVOTkXcq2TKRmw}{10.20.30.40}{10.20.30.40:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2020-05-19T20:00:10,865][INFO ][o.e.h.n.Netty4HttpServerTransport] [node-8] publish_address {10.20.30.40:9200}, bound_addresses {10.20.30.40:9200}
[2020-05-19T20:00:10,874][INFO ][o.e.n.Node               ] [node-8] started
[2020-05-19T20:00:10,972][INFO ][o.w.a.d.Monitor          ] try load config from /data/local/elasticsearch-5.4.1/config/analysis-ik/IKAnalyzer.cfg.xml
[2020-05-19T20:00:10,973][INFO ][o.w.a.d.Monitor          ] try load config from /data/local/elasticsearch-5.4.1/plugins/ik/config/IKAnalyzer.cfg.xml
[2020-05-19T20:00:11,668][INFO ][o.e.m.j.JvmGcMonitorService] [node-8] [gc][4] overhead, spent [440ms] collecting in the last [1s]
[2020-05-19T20:00:11,725][INFO ][o.w.a.d.Monitor          ] [Dict Loading] custom/mydict.dic
[2020-05-19T20:00:11,726][INFO ][o.w.a.d.Monitor          ] [Dict Loading] custom/single_word_low_freq.dic
[2020-05-19T20:00:11,729][INFO ][o.w.a.d.Monitor          ] [Dict Loading] custom/ext_stopword.dic
[2020-05-19T20:00:21,659][INFO ][o.e.g.GatewayService     ] [node-8] recovered [30] indices into cluster_state

之后如果再启动的话(如果是以root权限登录服务器),只需要执行切换账户,然后运行elasticsearch就可以了

代码语言:javascript
复制
su elsearch #切换账户
cd elasticsearch/bin #进入你的elasticsearch目录下的bin目录
sh elasticsearch

查看后台命令是否启动成功

代码语言:javascript
复制
ps -ef |grep elasticsearch
代码语言:javascript
复制
/usr/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+DisableExplicitGC -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=/data/local/elasticsearch-5.4.1 -cp /data/local/elasticsearch-5.4.1/lib/* org.elasticsearch.bootstrap.Elasticsearch
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-05-19 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 案发现场
  • elasticsearch不能以root运行
  • 创建elsearch用户组及elsearch用户
  • 改后重新用elsearch用户启动
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档