เข้าถึง Elasticsearch API
- URL:
http://<server-ip>:9200 - การสื่อสารภายใน cluster:
127.0.0.1:9300(ห้ามเปิดเผยต่อภายนอก)
ข้อมูลประจำตัว
- ผู้ใช้:
elastic - รหัสผ่าน: จัดเก็บอย่างปลอดภัยใน
/root/.cloudzy-creds
ไดเร็กทอรี่ที่สำคัญ
- การกำหนดค่า:
/etc/elasticsearch - ข้อมูล:
/var/lib/elasticsearch - บันทึก:
/var/log/elasticsearch - ไฟล์ไบนารี่:
/usr/share/elasticsearch/bin - ปลั๊กอิน:
/usr/share/elasticsearch/plugins
การจัดการ Service
ใช้ systemctl คำสั่ง
systemctl status elasticsearch systemctl restart elasticsearch systemctl stop elasticsearch systemctl start elasticsearch
การเพิ่ม Kibana เข้า cluster (ไม่บังคับ)
หากต้องการติดตั้ง Kibana แยกต่างหาก ให้สร้าง enrollment token บน Elasticsearch ก่อน แล้วนำไปใช้ตั้งค่า Kibana อย่างปลอดภัย
1. สร้าง enrollment token บนเซิร์ฟเวอร์ Elasticsearch:
/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
2. คัดลอก token ที่ได้ แล้วรันคำสั่งต่อไปนี้บนเซิร์ฟเวอร์ Kibana:
/usr/share/kibana/bin/kibana-setup --enrollment-token "<your-token>"
เป็นการเพิ่ม Kibana เข้ากับ Elasticsearch อย่างปลอดภัย
ตัวอย่างคำสั่ง Elasticsearch
ตรวจสอบสถานะ cluster:
curl -X GET -k "https://localhost:9200/_cluster/health?pretty" -u elastic:<password> --cacert /etc/elasticsearch/certs/http_ca.crt
แสดงรายการ index ทั้งหมด:
curl -X GET -k "https://localhost:9200/_cat/indices?v" -u elastic:<password> --cacert /etc/elasticsearch/certs/http_ca.crt