Elasticsearch 在不执行任何操作时 CPU 使用率为 100%

Elasticsearch 在不执行任何操作时 CPU 使用率为 100%

当我运行 时top,我始终看到 elasticsearch 使用大约 100% 的 CPU。我已完全断开 logstash 的连接,检查“curl localhost:9200/_nodes/hot_threads”的输出仅显示线程空闲:

ubuntu@ip-10-43-108-54:/data$ curl localhost:9200/_nodes/hot_threads ::: {7uyKrAF}{7uyKrAFGS0yMk0XiIrEzUQ}{Bk4GTlkiSqOgNU1cEJVxKw}{10.43.108.54}{10.43.108.54:9300}{ml.machine_memory=16825712640, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} Hot threads at 2018-10-25T18:46:33.827Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:

ubuntu@ip-10-43-108-54:/data$ curl localhost:9200/_nodes/hot_threads ::: {7uyKrAF}{7uyKrAFGS0yMk0XiIrEzUQ}{Bk4GTlkiSqOgNU1cEJVxKw}{10.43.108.54}{10.43.108.54:9300}{ml.machine_memory=16825712640, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} Hot threads at 2018-10-25T18:46:35.452Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:

0.0% (101.7micros out of 500ms) cpu usage by thread 'elasticsearch[7uyKrAF][[timer]]'
 10/10 snapshots sharing following 2 elements
   java.lang.Thread.sleep(Native Method)
   org.elasticsearch.threadpool.ThreadPool$CachedTimeThread.run(ThreadPool.java:543)

ubuntu@ip-10-43-108-54:/data$ curl localhost:9200/_nodes/hot_threads ::: {7uyKrAF}{7uyKrAFGS0yMk0XiIrEzUQ}{Bk4GTlkiSqOgNU1cEJVxKw}{10.43.108.54}{10.43.108.54:9300}{ml.machine_memory=16825712640, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} Hot threads at 2018-10-25T18:46:38.779Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:

ubuntu@ip-10-43-108-54:/data$ curl localhost:9200/_nodes/hot_threads ::: {7uyKrAF}{7uyKrAFGS0yMk0XiIrEzUQ}{Bk4GTlkiSqOgNU1cEJVxKw}{10.43.108.54}{10.43.108.54:9300}{ml.machine_memory=16825712640, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} Hot threads at 2018-10-25T18:46:40.579Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:

0.0% (90.5micros out of 500ms) cpu usage by thread 'elasticsearch[7uyKrAF][[timer]]'
 10/10 snapshots sharing following 2 elements
   java.lang.Thread.sleep(Native Method)
   org.elasticsearch.threadpool.ThreadPool$CachedTimeThread.run(ThreadPool.java:543)

0.0% (33.8micros out of 500ms) cpu usage by thread 'ticker-schedule-trigger-engine'
 10/10 snapshots sharing following 2 elements
   java.lang.Thread.sleep(Native Method)
   org.elasticsearch.xpack.watcher.trigger.schedule.engine.TickerScheduleTriggerEngine$Ticker.run(TickerScheduleTriggerEngine.java:161)</code>

造成这种情况的典型原因是什么?

答案1

显示为热的线程是 Elastic 认为的热线程。要诊断您的情况,您需要查看进程中的所有线程,以查看是否存在意外活动。要收集此信息,请按照以下命令操作:

ps aux | grep elastic

霍格斯特伦 4675 0.0 3.8 7018056 1284496 s001 S+ 下午 4:43 0:17.49 /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/bin/java -Xms1g -Xmx1g [剪辑...]

然后获取 PID 并发出以下命令以获取 JVM 中所有线程的转储。使用上面的示例,

jcmd 4675 Thread.print

这将为您提供所有 Java 线程的线程转储。在那里您可以看到 JVM 中有哪些线程及其状态。

“elasticsearch [cXcMg1Z] [http_server_worker] [T#2]”#61守护进程prio = 5 os_prio = 31 tid = 0x00007fa84fbdd000 nid = 0x14a03可运行 [0x00007000147fa000] java.lang.线程.状态:可运行 在 sun.nio.ch.KQueueArrayWrapper.kevent0(本机方法)在 sun.nio.ch.KQueueArrayWrapper.poll(KQueueArrayWrapper.java:198)在 sun.nio.ch.KQueueSelectorImpl.doSelect(KQueueSelectorImpl.java:117)在 sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)

示例线程是 Runnable。遍历所有线程,您应该找到一个正在运行的线程,并指出正在消耗 CPU 的任务。

相关内容