欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

zabbix监控部署

程序员文章站 2022-07-03 15:00:50
1. zabbix配置文件zabbix配置文件有两种:服务器端配置文件(/usr/local/etc/zabbix_server.conf)客户端配置文件(/usr/local/etc/zabbix_agentd.conf)zabbix代理配置文件(/usr/local/etc/zabbix_proxy.conf)服务器端配置文件zabbix_server.conf常用配置参数:参数作用LogFile设置服务端日志文件存放路径ListenIP设置服务端监听IP...

1. zabbix配置文件

zabbix配置文件有两种:

  • 服务器端配置文件(/usr/local/etc/zabbix_server.conf)
  • 客户端配置文件(/usr/local/etc/zabbix_agentd.conf)
  • zabbix代理配置文件(/usr/local/etc/zabbix_proxy.conf)
  • 服务器端配置文件zabbix_server.conf常用配置参数:
参数 作用
LogFile 设置服务端日志文件存放路径
ListenIP 设置服务端监听IP
ListenPort 设置服务端监听的端口号
PidFile 设置服务端进程号文件存放路径
DBHost 指定zabbix的数据库服务器IP
DBName 指定zabbix使用的数据库库名
DBUser 指定zabbix数据库登录用户
DBPassword 指定zabbix数据库登录密码
DBPort 指定zabbix数据库端口号
User 设置zabbix以什么用户的身份运行
AlertScriptsPath 设置告警脚本存放路径
ExternalScripts 外部脚本存放路径

客户端配置文件zabbix_agentd.conf常用配置参数:

参数 作用
Server 指定zabbix服务器的IP或域名
ServerActive 指定zabbix服务器的IP或域名
Hostname 指定本机的主机名,此项必须与web界面配置项一致
UnsafeUserParameters 是否启用自定义监控项,可选值为{1
UserParameter 指定自定义监控脚本参数
LogFile 设置客户端日志文件存放路径

2.部署zabbix

环境说明:

环境 IP 要安装的应用
服务器 192.168.232.128 lamp架构
zabbix server
zabbix agent
客户端 192.168.232.130 zabbix agent

安装依赖包

[root@wangyitong ~]# wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.1.tar.gz

下载zabbix与解压

[root@wangyitong ~]# wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.1.tar.gz
[root@wangyitong ~]# ls
anaconda-ks.cfg  lamp  zabbix-5.0.1.tar.gz
[root@wangyitong ~]# tar xf zabbix-5.0.1.tar.gz

创建zabbix用户和组

[root@wangyitong ~]# useradd -r -M -s /sbin/nologin zabbix

配置zabbix数据库

[root@wangyitong ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be inre.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.30 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserv

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input state.

mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.01 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123';
Query OK, 0 rows affected, 2 warnings (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

mysql> quit
Bye

[root@wangyitong ~]# cd zabbix-5.0.1/database/mysql/
[root@wangyitong mysql]# ls
data.sql  double.sql  images.sql  Makefile.am  Makefile.in  schema.sql
[root@wangyitong mysql]# mysql -uzabbix -pzabbix123 zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@wangyitong mysql]# mysql -uzabbix -pzabbix123 zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@wangyitong mysql]# mysql -uzabbix -pzabbix123 zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.

编译安装zabbix

[root@wangyitong ~]# cd zabbix-5.0.1
[root@wangyitong zabbix-5.0.1]# ./configure --enable-server \
> --enable-agent \
> --with-mysql \
> --with-net-snmp \
> --with-libcurl \
> --with-libxml2
....
[root@wangyitong zabbix-5.0.1]# make insatall

3.zabbix服务端配置

[root@wangyitong zabbix-5.0.1]# cd /usr/local/etc/
[root@wangyitong etc]# ls
zabbix_agentd.conf    zabbix_server.conf
zabbix_agentd.conf.d  zabbix_server.conf.d
[root@wangyitong etc]# vim zabbix_server.conf

DBPassword=zabbix123      //设置zabbix数据库连接密码

启动zabbix_server和zabbix_agentd
[root@wangyitong ~]# zabbix_server 
[root@wangyitong ~]# zabbix_agentd
[root@wangyitong ~]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128         *:22                      *:*                  
LISTEN     0      100    127.0.0.1:25                      *:*                  
LISTEN     0      128         *:10050                   *:*                  
LISTEN     0      128         *:10051                   *:*                  
LISTEN     0      128    127.0.0.1:9000                    *:*                  
LISTEN     0      128        :::80                     :::*                  
LISTEN     0      128        :::22                     :::*                  
LISTEN     0      100       ::1:25                     :::*                  
LISTEN     0      80         :::3306                   :::*  

4.zabbix服务端web界面安装与配置

4.1 zabbix web界面安装前配置

修改/etc/php.ini的配置并重启php-fpm

root@wangyitong ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@wangyitong ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@wangyitong ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@wangyitong ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@wangyitong ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done

创建数据存放目录并修改目录属主和属组

[root@wangyitong ~]# cd zabbix-5.0.1
[root@wangyitong zabbix-5.0.1]# ls
aclocal.m4  conf           configure.ac  install-sh   misc     ui
AUTHORS     config.guess   COPYING       m4           missing
bin         config.log     database      Makefile     NEWS
build       config.status  depcomp       Makefile.am  README
ChangeLog   config.sub     include       Makefile.in  sass
compile     configure      INSTALL       man          src
[root@wangyitong zabbix-5.0.1]# cp -r ui /usr/local/apache/htdocs/zabbix
[root@wangyitong zabbix-5.0.1]# cd /usr/local/apache/htdocs/
[root@wangyitong htdocs]# ls
index.html  test.com  zabbix
[root@wangyitong htdocs]# chown -R apache.apache zabbix/
[root@wangyitong htdocs]# ll
total 8
-rw-r--r--.  1 apache apache   45 Jun 12  2007 index.html
drwxr-xr-x.  2 apache apache   23 Jul 16 01:40 test.com
drwxr-xr-x. 12 apache apache 4096 Jul 16 20:16 zabbix

配置apache虚拟主机

[root@wangyitong ~]# vim /etc/httpd24/httpd.conf
#添加下面的内容
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/zabbix"
    ServerName www.wyt.com
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
    <Directory "/usr/local/apache/htdocs/zabbix">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>

设置zabbix/conf目录的权限,让zabbix有权限生成配置文件zabbix.conf.php

[root@wangyitong ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[root@wangyitong ~]# ll -d /usr/local/apache/htdocs/zabbix/conf
drwxrwxrwx. 3 apache apache 94 Jul 16 20:16 /usr/local/apache/htdocs/zabbix/conf

重启服务

[root@wangyitong ~]# apachectl stop
[root@wangyitong ~]# apachectl start
[root@wangyitong ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[root@wangyitong ~]# service mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 
[root@wangyitong ~]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128         *:22                      *:*                  
LISTEN     0      100    127.0.0.1:25                      *:*                  
LISTEN     0      128         *:10050                   *:*                  
LISTEN     15     128         *:10051                   *:*                  
LISTEN     0      128    127.0.0.1:9000                    *:*                  
LISTEN     0      128        :::80                     :::*                  
LISTEN     0      128        :::22                     :::*                  
LISTEN     0      100       ::1:25                     :::*                  
LISTEN     0      80         :::3306                   :::*   

4.2.安装zabbix web界面

修改/etc/hosts文件,添加域名与IP的映射
zabbix监控部署
在浏览器上用IP访问进行安装:
zabbix监控部署
zabbix监控部署
zabbix监控部署
zabbix监控部署
zabbix监控部署
zabbix监控部署
zabbix监控部署
恢复zabbix/conf目录的权限为755

[root@wangyitong ~]# chmod 755 /usr/local/apache/htdocs/zabbix/conf
[root@wangyitong ~]# ll -d /usr/local/apache/htdocs/zabbix/conf
drwxr-xr-x. 3 apache apache 117 Jul 16 21:05 /usr/local/apache/htdocs/zabbix/conf

5.登录zabbix

用户名: Admin
密码: zabbix
zabbix监控部署

6.监控配置流程

6.1 添加主机组

zabbix监控部署
zabbix监控部署
zabbix监控部署

## 6.2 添加主机

本文地址:https://blog.csdn.net/lnsistw/article/details/107360705

相关标签: linux

上一篇: 时间戳

下一篇: ThreadLocal记录日志