wazuh服务端安装

wazuh简介

Wazuh 是一个免费、开源和企业级的安全监控解决方案,用于威胁检测、完整性监控、事件响应和合规性。
官网地址:
https://wazuh.com/
对于wazuh与其他开源安全产品的能力比较可以阅读下面这边文章
https://www.freebuf.com/articles/endpoint/339347.html

本文主要介绍wazuh的安装

前提

1.查看官方安装文档

官方提供两种安装文档,一种是通过安装助手(偏自动化安装),一种是通过组件安装(手动安装每个组件),本安装方法选择第一种

https://documentation.wazuh.com/current/installation-guide/wazuh-indexer/index.html

部署前多看下官方文档可以避免很多错误。出现错误看安装日志,有些错误日志中有给出解决方法

2.服务端配置

部署测试使用单节点,系统版本CentOS Linux release 7.5.1804 (Core),4核32G,安装wazuh4.3(测试时最新版本)

初始配置

3.下载脚本和配置文件

curl -sO https://packages.wazuh.com/4.3/wazuh-install.sh
curl -sO https://packages.wazuh.com/4.3/config.yml

4.编辑配置config.yml

./config.yml 
nodes:
  # Wazuh indexer nodes
  indexer:
    - name: node-1
      ip: <indexer-node-ip>
    # - name: node-2
    #   ip: <indexer-node-ip>
    # - name: node-3
    #   ip: <indexer-node-ip>

  # Wazuh server nodes
  # Use node_type only with more than one Wazuh manager
  server:
    - name: wazuh-1
      ip: <wazuh-manager-ip>
    # node_type: master
    # - name: wazuh-2
    #   ip: <wazuh-manager-ip>
    # node_type: worker

  # Wazuh dashboard node
  dashboard:
    - name: dashboard
      ip: <dashboard-node-ip>

单节点配置,所以只需要填一个IP就可以,格式如下

image

5.使用选项运行助手--generate-config-files以生成安装所需的 Wazuh 集群密钥、证书和密码。

bash wazuh-install.sh --generate-config-files

Wazuh indexer节点安装

安装和配置 Wazuh 索引器节点。

6.使用选项--wazuh-indexer和节点名称运行助手以安装和配置 Wazuh 索引器。节点名称必须与config.yml初始配置中使用的相同,例如node-1.

确保将wazuh-install-files.tar在初始配置步骤中创建的副本放在您的工作目录中。

 bash wazuh-install.sh --wazuh-indexer node-1

7.安装 Wazuh 索引器过程的最后阶段包括运行安全管理脚本。

--start-cluster在任何Wazuh 索引器节点上运行带有选项的 Wazuh 安装助手以加载新证书信息并启动集群。

 bash wazuh-install.sh --start-cluster

注:集群只需初始化一次,无需在每个节点上运行此命令。

安装 Wazuh 服务器

8.--wazuh-server使用后跟节点名称的选项运行助手以安装 Wazuh 服务器。节点名称必须与config.yml初始配置中使用的相同,例如wazuh-1.

 bash wazuh-install.sh --wazuh-server wazuh-1

安装仪表盘

9.使用选项--wazuh-dashboard和节点名称运行助手以安装和配置 Wazuh 仪表板。节点名称必须与config.yml初始配置中使用的相同,例如dashboard.

 bash wazuh-install.sh --wazuh-dashboard dashboard

助手完成安装后,输出会显示访问凭据和确认安装成功的消息。

INFO: --- Summary ---
INFO: You can access the web interface https://<wazuh-dashboard-ip>
    User: admin
    Password: <ADMIN_PASSWORD>
INFO: Installation finished.

image

登录web界面进入主页

image

错误处理

1.日志/var/log/wazuh-install.log中在安装出现以下错误

failure: repodata/repomd.xml from docker-ce-stable: [Errno 256] No more mirrors to try.
https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#60 - "Peer's Certificate has expired."

解决方法:

查看服务器时间

时间不对,使用ntpdate同步时间或者date

2 安装日志出现以下字段

slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=wazuh.skip_if_unavailable=true

failure: repodata/repomd.xml from wazuh: [Errno 256] No more mirrors to try.

解决方法:

执行以下命令

 yum-config-manager --save --setopt=wazuh.skip_if_unavailable=true
执行上面命令提示
yum-config-manager: command not found
这个是因为系统默认没有安装这个命令,这个命令在yum-utils 包里,可以通过命令yum -y install yum-utils 安装就可以了。安装成功之后重新执行上面的命令

3、部署完成web页面无法访问查看监听端口是127.0.0.1而不是服务器地址
image

解决方法:

修改配置opensearch_dashboards.yml文件中server.host的iP为服务器IP,然后重启wazuh-manger

cd /etc/wazuh-dashboard/
[root@localhost wazuh-dashboard]# ls
certs  node.options  opensearch_dashboards.yml
[root@localhost wazuh-dashboard]# vi opensearch_dashboards.yml 
[root@localhost wazuh-dashboard]systemctl restart wazuh-manager

image

4 登录检查出现此错误ERROR: No template found for the selected index-pattern title [wazuh-alerts-*]

image

ERROR: No template found for the selected index-pattern title [wazuh-alerts-*]

解决方法:

错误提示是显示的是索引的模板没找到,看/etc/filebeat目录有没有对应json文件,可以filebeat -e测试是否可以正常向服务端传日志

使用filbeat -e查看发现有错误提示data path被锁

image

到 data path(/var/lib/filebeat)看下文件,发现有xx.lock文件,删掉此文件,再次执行filebeat -e 发现提示没有wazuh-template.json

下载wazuh-template.json文件,放到/etc/filebeat目录下

wazuh/wazuh-template.json at master · wazuh/wazuh (github.com)

cd /etc/filebeat

image

使用此命令刷新模板

curl -X PUT "https://localhost:9200/_template/wazuh" -H 'Content-Type: application/json' -d @wazuh-template.json --key certificates/elasticsearch-ca.pem  -k  -u kibanaserver:smbL3rB9UBZmGHHTc2h1nc?*3txQl888

上面命令最后账号密码通过执行此命令获取

tar -O -xvf wazuh-install-files.tar wazuh-install-files/wazuh-passwords.txt

image

在web界面点击重新检测通过检测。

除了上述一些错误,可能安装过程中也会遇到别的问题,官网也有对于一些错误的解决方法,可访问下面连接链接查看
Wazuh Kibana plugin troubleshooting - Elasticsearch

posted @ 2022-09-25 16:12  axing的星空  阅读(1588)  评论(0编辑  收藏  举报