DEV Community

Cover image for Workaround: Killing Kibana Causing Elasticsearch Down / ELK 7.2
Sawit M.
Sawit M.

Posted on

3 1

Workaround: Killing Kibana Causing Elasticsearch Down / ELK 7.2

เรื่องมันมีอยู่ว่า ... ♫ ... ♫ ... เมื่อวาน ขณะกำลังนั่งปั้น ELK(K) stack 7.2 สด! ใหม่! ใส! กิ๊ก! อยู่นั้น ผมก็ทำไปตาม step มาตรฐานที่เคยทำมานั่นคือ install elasticsearch, performance test, enable security แล้ว performance test อีกรอบ จากนั้นก็จบด้วย setup kibana เป็นขั้นตอนสุดท้าย

ทุกอย่างเกือบเรียบร้อยแล้ว จบกระทั้งเรื่องไม่คาดขวัญเกิดขึ้น

img

เชี่ย !!! process elasticsearch หายไปไหนนะ! ตาย!!! ทำไมตาย! error ก็ไม่มี

หลังจากสืบค้น ไปได้ซักพัก ก็พบว่า ...

ความจริงมีเพียงหนึ่งเดียว

😫 เห้ย !!! นั่นมัน Conan The Barbarian


😒 ยัง! ยังไม่เลิกอีก !!!! นั่นมัน Conan O'Brien


OK ! OK ! OK ! เพลงมา....

ฆาตรกรในห้องปิดตายคนนั้นก็คือ init script ของ kibana นั่นเอง !!! แต่สาเหตุมันคืออะไรล่ะ ?

สืบเนื่องจาก kibana ไม่ได้ run ด้วย root ทำให้ไม่สามารถ สร้าง pid file ที่ /var/run ได้ พอเราสั่ง systemctl stop kibana หรือ systemctl restart kibana มันเลยไป kill process elasticsearch

ถ้า stop ผ่าน init script ตรงๆ จะไม่มีผลกระทบอะไร

case นี้ผมคิดว่า น่าจะเป็นแค่ kibana 7.2 เท่านั้น เพราะอีก cluster ของผมที่เป็น kibana 7.1 ไม่พบปัญหา นี้

มาดู Environment ที่ผมพบปัญหากัน

OS: RHEL7.6
Kibana version: 7.2.0
Elasticsearch version: 7.2.0

วิธีแก้แบบปะผุ

  1. systemctl stop kibana
  2. systemctl stop elasticsearch
  3. เพิ่ม pid.file: /var/run/kibana/kibana.pid to /etc/kibana/kibana.yml
  4. แก้ /etc/init.d/kibana โดยเปลี่ยนจาก pidfile="/var/run/$name.pid" เป็น pidfile="/var/run/$name/$name.pid"
  5. systemctl edit kibana แล้วใส่ ข้อความนี้ลงไป
   [Service]
   RuntimeDirectory=kibana
  1. systemctl daemon-reload
  2. systemctl start elasticsearch
  3. systemctl start kibana

เท่านี้ก็เรียบร้อย (~ ̄▽ ̄)~


Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay