เข้าถึง Elasticsearch API
- URL:
http://<server-ip>:9200 - การสื่อสารภายใน cluster:
127.0.0.1:9300(ห้ามเปิดเผยต่อภายนอก)
Credentials
- User:
elastic - รหัสผ่าน: จัดเก็บอย่างปลอดภัยใน
/root/.cloudzy-creds
Important Directories
- Config:
/etc/elasticsearch - Data:
/var/lib/elasticsearch - Logs:
/var/log/elasticsearch - Binaries:
/usr/share/elasticsearch/bin - Plugins:
/usr/share/elasticsearch/plugins
การจัดการ Service
Use systemctl commands:
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