Hi
Patan Mahammad Khan,I will describe the steps that you will need to execute to get the wazuh-indexer on a different server than your all-in-one installation.
Basically, we will need to install the same version of indexer on your new server and redeploy the certificates due to the IP address should change, so for filebeat and dashboard that connect with Wazuh-indexer, needs to configure the IP of this new indexer and create new certificates to replace the current ones.
On the other hand, it will also be necessary to move the data from the current path of indexer to the new one.
So you will need to follow these steps:
1) Stop wazuh Indexer on your current host.
systemctl stop wazuh-indexer2) Install the dependencies and the wazuh Indexer
on the new server, but without starting the service yet, by running this.
yum -y install coreutils
yum -y install wazuh-indexer-4.3.10-1Move from the current wazuh-indexer to the new one, the path
/var/lib/wazuh-indexer scp -pr /var/lib/wazuh-indexer root@<NEW_INDEXER_IP>:/var/lib/Verify that the files have been moved and that their ownership and group
ls -ltr /var/lib/wazuh-indexerEnsure that the ownership and group be wazuh-indexer user and group.
chown -R wazuh-indexer:wazuh-indexer3)On the new indexer server, download the script and template to create the new certificates.
curl -sO https://packages.wazuh.com/4.4/wazuh-install.sh
curl -sO https://packages.wazuh.com/4.4/config.ymlEdit
./config.yml and change the IP address of each service, like this example,
nodes:
# Wazuh indexer nodes
indexer:
- name: node-1
ip: <NEW_INDEXER_IP>
#- name: node-2
# ip: <indexer-node-ip>
#- name: node-3
# ip: <indexer-node-ip>
# Wazuh server nodes
# If there is more than one Wazuh server
# node, each one must have a node_type
server:
- name: wazuh-1
ip: <CURRENT_WAZUH_MANAGER_IP>
# node_type: master
#- name: wazuh-2
# ip: <wazuh-manager-ip>
# node_type: worker
#- name: wazuh-3
# ip: <wazuh-manager-ip>
# node_type: worker
# Wazuh dashboard nodes
dashboard:
- name: dashboard
ip: <CURRENT_WAZUH_DASHBOARD_IP>Execute the script to create the certificates.
bash ./wazuh-certs-tool.sh -ACreate the tar files with the certificates and remove the creation folder
tar -cvf ./wazuh-certificates.tar -C ./wazuh-certificates/ .
rm -rf ./wazuh-certificates
mkdir /etc/wazuh-indexer/certs
tar -xf ./wazuh-certificates.tar -C /etc/wazuh-indexer/certs/ ./$NODE_NAME.pem ./$NODE_NAME-key.pem ./admin.pem ./admin-key.pem ./root-ca.pem
mv -n /etc/wazuh-indexer/certs/$NODE_NAME.pem /etc/wazuh-indexer/certs/indexer.pem
mv -n /etc/wazuh-indexer/certs/$NODE_NAME-key.pem /etc/wazuh-indexer/certs/indexer-key.pem
chmod 500 /etc/wazuh-indexer/certs
chmod 400 /etc/wazuh-indexer/certs/*
chown -R wazuh-indexer:wazuh-indexer /etc/wazuh-indexer/certs4) Configure the Wazuh-Indexer editing the config file
/etc/wazuh-indexer/opensearch.ymlThese steps are the same as this document.
https://documentation.wazuh.com/4.3/installation-guide/wazuh-indexer/step-by-step.html#configuring-the-wazuh-indexerEdit the /etc/wazuh-indexer/opensearch.yml configuration file and replace the following values:
a)
network.host: Sets the address of this node for both HTTP and transport traffic. The node will bind to this address and use it as its publish address. Accepts an IP address or a hostname.
Use the same node address set in config.yml to create the SSL certificates.
b)
node.name: Name of the Wazuh indexer node as defined in the config.yml file. For example, node-1.
5) Sent the tar file with the certificates from your new indexer server to the Wazuh-Manager/Dashboard server.
scp wazuh-certificates.tar root@<CURRENT_WAZUH_MANAGER_IP>:/root6) Go to your Wazuh-manager host and take a backup of your current certificates
mkdir /root/filebeat_backup_certs
mkdir /root/dashboard_backup_certs
mv /etc/filebeat/cert/* /root/filebeat_backup_certs
mv /etc/wazuh-dashboard/certs/* /root/dashboard_backup_certsStop the filebeat and dashboard service
systemctl stop filebeat
systemctl stop wazuh-dashboardDeploy the certificates for Filebeat and Wazuh-dashboard
These steps are the same of this document:
https://documentation.wazuh.com/current/installation-guide/wazuh-server/step-by-step.html#deploying-certificateshttps://documentation.wazuh.com/current/installation-guide/wazuh-dashboard/step-by-step.html#deploying-certificatesFilebeat:Note Make sure that a copy of the
wazuh-certificates.tar file, created during the initial configuration step, is placed in your working directory.
Replace
<server-node-name> with your Wazuh server node certificate name, the same one used in config.yml when creating the certificates. Then, move the certificates to their corresponding location.
NODE_NAME=<server-node-name>
tar -xf ./wazuh-certificates.tar -C /etc/filebeat/certs/ ./$NODE_NAME.pem ./$NODE_NAME-key.pem ./root-ca.pem
mv -n /etc/filebeat/certs/$NODE_NAME.pem /etc/filebeat/certs/filebeat.pem
mv -n /etc/filebeat/certs/$NODE_NAME-key.pem /etc/filebeat/certs/filebeat-key.pem
chmod 500 /etc/filebeat/certs
chmod 400 /etc/filebeat/certs/*
chown -R root:root /etc/filebeat/certs
Add the new Indexer IP on /etc/filebeat/filebeat.yml
output.elasticsearch.hosts:
- <NEW_INDEXER_IP>:9200Verify that the filename of the files
/etc/filebeat/certs/ matches with the name on your
/etc/filebeat/filebeat.yml config file
ssl.certificate: "/etc/filebeat/certs/filebeat.pem"
ssl.key: "/etc/filebeat/certs/filebeat-key.pem"if they don't match modify the configuration file to match with your certificates.
Start the service:
systemctl daemon-reload
systemctl enable filebeat
systemctl start filebeatValidate if filebeat is correctly running and accessing the new indexer.
filbeat test output.
Dashboard:
Replace
<dashboard-node-name> with your Wazuh dashboard node name, the same one used in config.yml to create the certificates, and move the certificates to their corresponding location.
NODE_NAME=<dashboard-node-name>
tar -xf ./wazuh-certificates.tar -C /etc/wazuh-dashboard/certs/ ./$NODE_NAME.pem ./$NODE_NAME-key.pem ./root-ca.pem
mv -n /etc/wazuh-dashboard/certs/$NODE_NAME.pem /etc/wazuh-dashboard/certs/dashboard.pem
mv -n /etc/wazuh-dashboard/certs/$NODE_NAME-key.pem /etc/wazuh-dashboard/certs/dashboard-key.pem
chmod 500 /etc/wazuh-dashboard/certs
chmod 400 /etc/wazuh-dashboard/certs/*
chown -R wazuh-dashboard:wazuh-dashboard /etc/wazuh-dashboard/certsConfiguring the Wazuh dashboard
Edit the
/etc/wazuh-dashboard/opensearch_dashboards.yml file and replace the IP address of your new Indexer:
opensearch.hosts: https://<NEW_INDEXER_IP>:9200As well that filebeat, verify that the filename of the files
/etc/wazuh-dashboard/certs/ matches with the name on your
/etc/wazuh-dashboard/opensearch_dashboards.yml config file
server.ssl.key: "/etc/wazuh-dashboard/certs/dashboard-key.pem"
server.ssl.certificate: "/etc/wazuh-dashboard/certs/dashboard.pem"Start the service
systemctl daemon-reload
systemctl enable wazuh-dashboard
systemctl start wazuh-dashboardNow you will need to check if you are receiving new alerts and if they are correctly inserted on Wazuh-Indexer.
Please, just let me know if you have any doubts or questions.
Regards
Marcos