Hello Boubacary and thanks for using Wazuh.
Changing your your infrastructure from all in one deployment to distributed will require you to do the following steps:
NOTE: I assume here that the new nodes are already install and will focus on the configuration to cluster mode. Also a documentation on this is actually been written and will be published soon.
Adding an Indexer Node:
1. Create a config.yml file in the root directory of the existing node to add the new indexer node(s):
Run the following command to ensure you’re in the root directory:
# cd
Then create the config.yml file with it’s content as follows:
nodes:
# Wazuh indexer nodes
indexer:
- name: <WAZUH-INDEXER1-NODE-NAME>
ip: <WAZUH-INDEXER1-IP>
- name: <WAZUH-INDEXER2-NODE-NAME>
ip: <WAZUH-INDEXER2-IP>
# Wazuh server nodes
server:
- name: <WAZUH-SERVER-NODE-NAME>
ip: <WAZUH-SERVER-IP>
# Wazuh dashboard nodes
dashboard:
- name: <WAZUH-DASHBOARD-NODE-NAME>
ip: <WAZUH-DASHBOARD-IP>
Replace the values with your node names and their corresponding IP addresses.
2.Download and run ./wazuh-certs-tool.sh to recreate the certificates for the old and new nodes:
# curl -sO https://packages.wazuh.com/4.5/wazuh-certs-tool.sh
# bash wazuh-certs-tool.sh -A3. Compress the certificates folder and copy it to the new node(s). You can make use of the scp utility for easy and secure copying of the compressed file:
# tar -cvf ./wazuh-certificates.tar -C ./wazuh-certificates/ .
# rm -rf ./wazuh-certificates
# scp wazuh-certificates.tar <target-username>@<target-IP>:
4. Create a file, e.g., env_variables.sh, in the root directory of the existing node where you define your environmental variables as follows:
export NODE_NAME1=<WAZUH-INDEXER-NODE-NAME>
export NODE_NAME2=<WAZUH-SERVER1-NODE-NAME>
export NODE_NAME3=<WAZUH-DASHBOARD-NODE-NAME>
Replace <WAZUH-INDEXER-NODE-NAME>, <WAZUH-SERVER-NODE-NAME>, <WAZUH-DASHBOARD-NODE-NAME> respectively with the names of the Wazuh indexer, Wazuh server and Wazuh dashboard nodes as defined in config.yml.
5. Create a deploy-certificates.sh script in the root directory and copy the following:
#!/bin/bash
# Source the environmental variables from the external file
source ~/env_variables.sh
rm -rf /etc/wazuh-indexer/certs
mkdir /etc/wazuh-indexer/certs
tar -xf ./wazuh-certificates.tar -C /etc/wazuh-indexer/certs/ ./$NODE_NAME1.pem ./$NODE_NAME1-key.pem ./admin.pem ./admin-key.pem ./root-ca.pem
mv -n /etc/wazuh-indexer/certs/$NODE_NAME1.pem /etc/wazuh-indexer/certs/wazuh-indexer.pem
mv -n /etc/wazuh-indexer/certs/$NODE_NAME1-key.pem /etc/wazuh-indexer/certs/wazuh-indexer-key.pem
chmod 500 /etc/wazuh-indexer/certs
chmod 400 /etc/wazuh-indexer/certs/*
chown -R wazuh-indexer:wazuh-indexer /etc/wazuh-indexer/certs
rm -rf /etc/filebeat/certs
mkdir /etc/filebeat/certs
tar -xf ./wazuh-certificates.tar -C /etc/filebeat/certs/ ./$NODE_NAME2.pem ./$NODE_NAME2-key.pem ./root-ca.pem
mv -n /etc/filebeat/certs/$NODE_NAME2.pem /etc/filebeat/certs/wazuh-server.pem
mv -n /etc/filebeat/certs/$NODE_NAME2-key.pem /etc/filebeat/certs/wazuh-server-key.pem
chmod 500 /etc/filebeat/certs
chmod 400 /etc/filebeat/certs/*
chown -R root:root /etc/filebeat/certs
rm -rf /etc/wazuh-dashboard/certs
mkdir /etc/wazuh-dashboard/certs
tar -xf ./wazuh-certificates.tar -C /etc/wazuh-dashboard/certs/ ./$NODE_NAME3.pem ./$NODE_NAME3-key.pem ./root-ca.pem
mv -n /etc/wazuh-dashboard/certs/$NODE_NAME3.pem /etc/wazuh-dashboard/certs/wazuh-dashboard.pem
mv -n /etc/wazuh-dashboard/certs/$NODE_NAME3-key.pem /etc/wazuh-dashboard/certs/wazuh-dashboard-key.pem
chmod 500 /etc/wazuh-dashboard/certs
chmod 400 /etc/wazuh-dashboard/certs/*
chown -R wazuh-dashboard:wazuh-dashboard /etc/wazuh-dashboard/certs
Then deploy the certificates by executing the following command:
# bash ./deploy-certificates.shThis deploys the SSL certificates to encrypt communications between the Wazuh central components.
6. Download the Wazuh password management tool and run it to generate and change passwords for all the Wazuh indexer users. The script will also automatically update the passwords where necessary.
# curl -so wazuh-passwords-tool.sh https://packages.wazuh.com/4.5/wazuh-passwords-tool.sh
# bash wazuh-passwords-tool.sh -aSave the admin password as it would be useful later to connect to the Wazuh dashboard.
7. Edit the indexer configuration file at /etc/wazuh-indexer/opensearch.yml on both th new and old nodes to include the different indexers as follows. Uncomment or add more lines, according to your config.yml definitions:
network.host: "<WAZUH-INDEXER1-IP>"
node.name: "<WAZUH-INDEXER1-NODE-NAME>"
cluster.initial_master_nodes:
- "<WAZUH-INDEXER1-IP>"
- "<WAZUH-INDEXER2-IP>"
cluster.name: "wazuh-cluster"
discovery.seed_hosts:
- "<WAZUH-INDEXER1-IP>"
- "<WAZUH-INDEXER2-IP>"
plugins.security.nodes_dn:
- "CN=indexer,OU=Wazuh,O=Wazuh,L=California,C=US"
- "CN=<WAZUH-INDEXER2-NODE-NAME>,OU=Wazuh,O=Wazuh,L=California,C=US"8. Edit the filebeat configuration file /etc/filebeat/filebeat.yml to add the new indexer node(s). Uncomment or add more lines, according to your config.yml definitions:
output.elasticsearch.hosts:
- <WAZUH-INDEXER1-IP>:9200
- <WAZUH-INDEXER2-IP>:9200
output.elasticsearch:
protocol: https
username: ${username}
password: ${password}Confirm the configurations works by running the command below:
# filebeat test outputEdit the Wazuh dashboard configuration file /etc/wazuh-dashboard/opensearch_dashboards.yml to include the new Wazuh indexer node(s):
opensearch.hosts: ["https://<WAZUH-INDEXER1-IP>:9200", "https://<WAZUH-INDEXER2-IP>:9200"]
Restart the services:
# systemctl restart wazuh-indexer
# systemctl restart filebeat
# systemctl restart wazuh-manager
# systemctl restart wazuh-dashboardRun the Wazuh indexer indexer-security-init.sh script on any Wazuh indexer node to load the new certificates information and start the single-node or multi-node cluster:
/usr/share/wazuh-indexer/bin/indexer-security-init.shThe output should display the number of Indexer nodes present on your cluster