Bước đầu tiên là đảm bảo đã cài đặt JDK 17 trở lên.
Tài liệu chính thức: https://www.elastic.co/guide/en/elasticsearch/reference/8.6/deb.html#install-deb
1. Cài đặt khóa ký số
2. Cập nhật kho APT để hỗ trợ HTTPS
3. Thêm nguồn gói vào hệ thống
4. Cập nhật danh sách gói và cài đặt Elasticsearch phiên bản mới nhất (có thể yêu cầu JDK cụ thể)
5. Cài đặt cụ thể phiên bản 8.6.2
6. Gỡ bỏ phần mềm khi cần
7. Chỉnh sửa file cấu hình Elasticsearch
sudo wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
sudo apt-get install apt-transport-https
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
sudo apt-get update && sudo apt-get install elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.6.2-amd64.deb
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.6.2-amd64.deb.sha512
shasum -a 512 -c elasticsearch-8.6.2-amd64.deb.sha512
sudo dpkg -i elasticsearch-8.6.2-amd64.deb
sudo apt-get remove --purge elasticsearch
# ======================== Elasticsearch Configuration =========================
#
# Ghi chú: Elasticsearch sử dụng các giá trị mặc định hợp lý cho hầu hết các thiết lập.
# Trước khi thay đổi, hãy hiểu rõ mục tiêu và hệ quả của từng thay đổi.
#
# Cách chính để cấu hình node là thông qua file này. File mẫu liệt kê các thiết lập quan trọng
# thường cần điều chỉnh trong môi trường sản xuất.
#
# Xem tài liệu để biết thêm chi tiết:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
cluster.name: my-cluster
#
# ------------------------------------ Node ------------------------------------
node.name: es-node-01
#
# ----------------------------------- Paths ------------------------------------
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
# bootstrap.memory_lock: true
#
# Đặt kích thước heap bằng khoảng một nửa dung lượng RAM hệ thống.
# Người sở hữu tiến trình phải được cấp quyền sử dụng giới hạn này.
#
# ---------------------------------- Network -----------------------------------
# network.host: 0.0.0.0
# http.port: 9200
#
# --------------------------------- Discovery ----------------------------------
discovery.seed_hosts: ["127.0.0.1", "[::1]"]
cluster.initial_master_nodes: ["es-node-01"]
#
# --------------------------------- Readiness ----------------------------------
# readiness.port: 9399
#
# ---------------------------------- Various -----------------------------------
# action.destructive_requires_name: false
#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl.enabled: true
xpack.security.http.ssl.keystore.path: certs/http.p12
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/transport.p12
xpack.security.transport.ssl.truststore.path: certs/transport.p12
http.host: 0.0.0.0
# transport.host: 0.0.0.0
#----------------------- END SECURITY AUTO CONFIGURATION -------------------------