SIEM/Log Management [Phần 1] Triển khai Data Node trong hệ thống SIEM trên service, có cluster (Opensearch + Wazuh Manager + Vector)

Mô hình triển khai:

1764049811930.png

Chú thích: Các node Management + Agent Management; Log pipeline + Load Blancing sẽ được gộp lại để giảm chi phí triển khai.

VMIP
Data0110.30.194.181
Data0210.30.194.182
Data0310.30.194.183
Dashboard10.30.194.184
Manager0110.30.194.185
Manager0210.30.194.186
Pipeline0110.30.194.187
Pipeline0210.30.194.188

Vai trò của Data Node trong hệ thống:​

1. Lưu trữ dữ liệu (Storage Engine)​

Đây là chức năng cơ bản nhất. Data Node là nơi chứa các dữ liệu thực tế (documents) mà bạn đẩy vào (ví dụ: log từ Wazuh, metric hệ thống).
  • Sharding: Dữ liệu trong OpenSearch được chia nhỏ thành các phần gọi là Shards. Các Shards này được lưu trữ trực tiếp trên ổ cứng của Data Node.
  • Data Tiering: Trong các hệ thống lớn, Data Node có thể chia thành các lớp: Hot (dữ liệu mới, truy xuất nhanh), Warm (dữ liệu cũ hơn), và Cold (lưu trữ lâu dài, ít truy xuất).

2. Đánh chỉ mục (Indexing - Ghi dữ liệu)​

Khi có dữ liệu mới được gửi đến (ví dụ: Log bắn về từ Wazuh Manager), Data Node chịu trách nhiệm:
  • Phân tích cú pháp dữ liệu (Parsing).
  • Tạo Inverted Index (bảng chỉ mục đảo) để giúp việc tìm kiếm sau này diễn ra nhanh chóng.
  • Ghi dữ liệu xuống đĩa.
  • Tài nguyên: Quá trình này ngốn rất nhiều I/O (tốc độ ổ cứng)CPU.

3. Tìm kiếm và Tổng hợp (Search & Aggregation - Đọc dữ liệu)​


Khi vào Dashboard (Wazuh Dashboard/OpenSearch Dashboards) để search log hoặc xem biểu đồ:
  • Yêu cầu tìm kiếm được gửi đến Data Node.
  • Data Node quét qua các Shards cục bộ của nó, lọc dữ liệu khớp với câu lệnh query.
  • Thực hiện các phép tính toán học (Aggregations) như: đếm số lượng alert, tính trung bình, tìm max/min...
  • Tài nguyên: Quá trình này ngốn rất nhiều RAMCPU.

4. Đảm bảo tính sẵn sàng (Replication)​

Để tránh mất dữ liệu khi một server bị hỏng, Data Node lưu trữ các bản sao (Replicas):
  • Primary Shard: Bản chính của dữ liệu.
  • Replica Shard: Bản sao lưu dự phòng.
  • Nếu một Data Node bị chết, Cluster sẽ tự động kích hoạt Replica Shard trên một Data Node khác để hệ thống vẫn hoạt động bình thường.

Chi tiết triển khai:​

Vì cluster HA chỉ có 3 node nên để tối ưu thì cả 3 node đều giữ vai trò:
  • cluster_manager: Tham gia bầu chọn quản lý cụm.
  • data: Lưu trữ dữ liệu log và sự kiện bảo mật.
  • ingest: Xử lý dữ liệu đầu vào từ Vector và Wazuh Manager.
Triển khai tương trên cả 3 node: 10.30.194.181, 10.30.194.182, 10.30.194.183
Cập nhật danh sách gói phần mềm hệ thống và cài package cần thiết:


sudo apt-get update && sudo apt-get -y install lsb-release ca-certificates curl gnupg2
Import public GPG key:

curl -fsSL https://artifacts.opensearch.org/publickeys/opensearch-release.pgp \ | sudo gpg --dearmor -o /etc/apt/keyrings/opensearch.gpg
Sau khi đã thêm khóa GPG để xác thực, thêm đường dẫn repository của OpenSearch vào danh sách nguồn của hệ thống (apt). Điều này cho phép công cụ quản lý gói (apt) biết nơi để tìm và tải xuống các gói cài đặt OpenSearch:

echo "deb [signed-by=/etc/apt/keyrings/opensearch.gpg] https://artifacts.opensearch.org/releases/bundle/opensearch/3.x/apt stable main" \
| sudo tee /etc/apt/sources.list.d/opensearch-3.x.list
Cập nhật để tải thông tin gói từ kho lưu trữ của Opensearch:

sudo apt-get update
Đặt mật khẩu quản trị tùy chỉnh:

sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=<custom-admin-password> apt-get install opensearch=3.3.2
Khởi động Opensearch:

gpg --no-default-keyring --keyring /etc/apt/trusted.gpg.d/opensearch.gpg --fingerprint
sudo systemctl enable opensearch
sudo systemctl start opensearch
Test Opensearch có hoạt động không:

curl -X GET https://<ip-node>:9200 -u 'admin:<custom-admin-password>' --insecure
1764049771410.png

Cấu hình file /etc/opensearch/opensearch.yml trên các node (chỉnh lại node.name và network.host):

cluster.name: poptech
node.name: node-1
node.roles: [cluster_manager, data, ingest]
path.data: /var/lib/opensearch
path.logs: /var/log/opensearch
network.host: 10.30.194.181
discovery.seed_hosts: ["10.30.194.181", "10.30.194.182", "10.30.194.183"]
cluster.initial_cluster_manager_nodes: ["node-1", "node-2", "node-3"]
plugins.security.ssl.transport.pemcert_filepath: esnode.pem
plugins.security.ssl.transport.pemkey_filepath: esnode-key.pem
plugins.security.ssl.transport.pemtrustedcas_filepath: root-ca.pem
plugins.security.ssl.transport.enforce_hostname_verification: false
plugins.security.ssl.http.enabled: true
plugins.security.ssl.http.pemcert_filepath: esnode.pem
plugins.security.ssl.http.pemkey_filepath: esnode-key.pem
plugins.security.ssl.http.pemtrustedcas_filepath: root-ca.pem
plugins.security.allow_unsafe_democertificates: true
plugins.security.allow_default_init_securityindex: true
plugins.security.authcz.admin_dn: ['CN=kirk,OU=client,O=client,L=test,C=de']
plugins.security.audit.type: internal_opensearch
plugins.security.enable_snapshot_restore_privilege: true
plugins.security.check_snapshot_restore_write_privileges: true
plugins.security.restapi.roles_enabled: [all_access, security_rest_api_access]
plugins.security.system_indices.enabled: true
plugins.security.system_indices.indices: [.plugins-ml-agent, .plugins-ml-config, .plugins-ml-connector,
.plugins-ml-controller, .plugins-ml-model-group, .plugins-ml-model, .plugins-ml-task,
.plugins-ml-conversation-meta, .plugins-ml-conversation-interactions, .plugins-ml-memory-meta,
.plugins-ml-memory-message, .plugins-ml-stop-words, .opendistro-alerting-config,
.opendistro-alerting-alert*, .opendistro-anomaly-results*, .opendistro-anomaly-detector*,
.opendistro-anomaly-checkpoints, .opendistro-anomaly-detection-state, .opendistro-reports-*,
.opensearch-notifications-*, .opensearch-notebooks, .opensearch-observability, .ql-datasources,
.opendistro-asynchronous-search-response*, .replication-metadata-store, .opensearch-knn-models,
.geospatial-ip2geo-data*, .plugins-flow-framework-config, .plugins-flow-framework-templates,
.plugins-flow-framework-state, .plugins-search-relevance-experiment, .plugins-search-relevance-judgment-cache]
node.max_local_storage_nodes: 3
Cấu hình file /etc/opensearch/jvm.options: (thường thì gần bằng 1/2 RAM)

-Xms4g
-Xmx4g
Test xem đã join cluster chưa:
curl -XGET https://<ip-node>:9200/_cat/nodes?v -u 'admin:<custom-admin-password>' --insecure
1764049963248.png
 
Sửa lần cuối:
Back
Top