Zabbix分布式监控部署-6.4.9

基础环境

[root@http ~]# hostnamectl set-hostname zabbix-server
[root@http ~]# bash
[root@zabbix-server ~]# systemctl disable firewalld --now && setenforce 0
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@zabbix-server ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 
[root@http ~]# mv /etc/yum.repos.d/CentOS-* /tmp/
[root@zabbix-server ~]# curl -o /etc/yum.repos.d/centos.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@zabbix-server ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

nginx

rpm -ivh http://rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/pcre2-10.23-2.el7.x86_64.rpm
rpm -Uvh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.22.1-1.el7.ngx.x86_64.rpm

### nginx 1.25.3 版本
[root@zabbix-server ~]# vim /etc/yum.repos.d/nginx.repo 
[nginx]
name = nginx repo
baseurl = https://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck = 0
enabled = 1

[root@zabbix-server ~]# systemctl enable nginx --now
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@zabbix-server ~]# nginx -v
nginx version: nginx/1.25.3
nginx解析php
[root@zabbix-server zabbix]# vim /usr/local/nginx/conf/vhost/zabbix.com.conf
server {
    listen 80;
    server_name zabbix.com www.zabbix.com;
    index index.html index.htm index.php;
    root /data/nginx/zabbix;

    ##Zabbix Web 界面数据目录
    location ~* \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

[root@zabbix-server ~]# mkdir -p /data/nginx/zabbix
[root@zabbix-server ~]# echo "<?php phpinfo(); ?>" > /data/nginx/zabbix/1.php

在这里插入图片描述

php

### php 7.4.33 版本
[root@zabbix-server ~]# yum -y install epel-release
[root@zabbix-server ~]# yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

[root@zabbix-server ~]# yum -y install php74-php-bcmath php74-php-cli php74-php-common php74-php-devel php74-php-embedded php74-php-fpm php74-php-gd php74-php-intl php74-php-mbstring php74-php-mysqlnd php74-php-opcache php74-php-pdo php74-php-pear php74-php-pecl-igbinary php74-php-pecl-memcached php74-php-process php74-php-xml

[root@zabbix-server ~]# systemctl enable php74-php-fpm --now
Created symlink from /etc/systemd/system/multi-user.target.wants/php74-php-fpm.service to /usr/lib/systemd/system/php74-php-fpm.service.

[root@zabbix-server ~]# php74 -v
PHP 7.4.33 (cli) (built: Dec 12 2023 14:32:04) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

mariadb

### mariadb 10.6.16 版本
[root@zabbix-server ~]# cat /etc/yum.repos.d/mariadb.repo 
[mariadb]
name = MariaDB
baseurl = https://rpm.mariadb.org/10.6/rhel/$releasever/$basearch
gpgkey= https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

[root@zabbix-server ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@zabbix-server ~]# yum remove -y mariadb-libs

[root@zabbix-server ~]# vim /etc/yum.repos.d/mariadb.repo 
[mariadb]
name = MariaDB
baseurl = https://rpm.mariadb.org/10.6/rhel/$releasever/$basearch
gpgkey= https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

[root@zabbix-server ~]# yum install -y mariadb-server mariadb-client
[root@zabbix-server ~]# systemctl enable mariadb --now
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@zabbix-server ~]# mariadb -V
mariadb  Ver 15.1 Distrib 10.6.16-MariaDB, for Linux (x86_64) using readline 5.1

zabbix服务端

编译安装
[root@zabbix-server src]# yum install -y libevent-devel wget tar gcc gcc-c++ make net-snmp-devel libxml2-devel libcurl-devel

[root@zabbix-server zrc]# yum -y install mysql-devel pcre-devel openssl-devel zlib-devel libxml2-devel net-snmp-devel net-snmp libssh2-devel OpenIPMI-devel libevent-devel openldap-devel libcurl-devel openldap openldap-*

### 创建 zabbix 用户
[root@zabbix-server ~]# useradd -s /sbin/nologin zabbix

### 解压源码包
[root@zabbix-server src]# tar -zxvf zabbix-6.4.9.tar.gz
[root@zabbix-server src]# mv /usr/local/src/zabbix-6.4.9 /usr/local/zabbix

[root@zabbix-server src]# cd /usr/local/zabbix/

### 编译安装
[root@zabbix-server zabbix]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2

[root@zabbix-server zabbix]# make -j 4

[root@zabbix-server zabbix]# make install
#################
[root@zabbix-server src]# yum install -y php74-php-ldap
[root@zabbix-server src]# yum install -y openldap-*
环境变量
### 添加环境变量
[root@zabbix-server zabbix]# vim /etc/profile
export PATH=$PATH:/usr/local/zabbix/sbin/:/usr/local/zabbix/bin/
[root@zabbix-server zabbix]# source /etc/profile
[root@zabbix-server zabbix]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/zabbix/sbin/:/usr/local/zabbix/bin/:/usr/local/zabbix/sbin/:/usr/local/zabbix/bin/

[root@zabbix-server zabbix]# zabbix_server --version
zabbix_server (Zabbix) 6.4.9
Revision 6186d441314 30 November 2023, compilation time: Dec 14 2023 05:02:53

Copyright (C) 2023 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <https://www.gnu.org/licenses/>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
配置启动脚本
[root@zabbix-server zabbix]# cp /usr/local/zabbix/misc/init.d/fedora/core/zabbix_server /etc/init.d/
[root@zabbix-server zabbix]# cp /usr/local/zabbix/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/

[root@zabbix-server zabbix]# cat /etc/init.d/zabbix_server | grep BASEDIR
        BASEDIR=/usr/local/zabbix/		### zabbix安装目录
        FULLPATH=$BASEDIR/sbin/$BINARY_NAME
        
[root@zabbix-server zabbix]# cat /etc/init.d/zabbix_agentd | grep BASEDIR   
        BASEDIR=/usr/local/zabbix/		### zabbix安装目录
        FULLPATH=$BASEDIR/sbin/$BINARY_NAME
        
### 修改权限
[root@zabbix-server zabbix]# chmod 755 /etc/init.d/zabbix_*
[root@zabbix-server zabbix]# ll /etc/init.d/zabbix_*
-rwxr-xr-x 1 root root 2178 Dec 12 23:48 /etc/init.d/zabbix_agentd
-rwxr-xr-x 1 root root 2189 Dec 12 23:47 /etc/init.d/zabbix_server

### 启动服务
[root@zabbix-server zabbix]# /etc/init.d/zabbix_server start
Reloading systemd:                                         [  OK  ]
Starting zabbix_server (via systemctl):                    [  OK  ]
[root@zabbix-server zabbix]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd (via systemctl):                    [  OK  ]

[root@zabbix-server zabbix]# /etc/init.d/zabbix_server status
● zabbix_server.service - SYSV: Starts and stops Zabbix Server using chkconfig
   Loaded: loaded (/etc/rc.d/init.d/zabbix_server; bad; vendor preset: disabled)
   Active: active (running) since Tue 2023-12-12 23:50:16 CST; 48s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 11716 ExecStart=/etc/rc.d/init.d/zabbix_server start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/zabbix_server.service
           └─11727 /usr/local/zabbix//sbin/zabbix_server

Dec 12 23:50:16 zabbix-server systemd[1]: Starting SYSV: Starts and stops Zabbix Server using chkconfig...
Dec 12 23:50:16 zabbix-server zabbix_server[11716]: Starting zabbix_server:  [  OK  ]
Dec 12 23:50:16 zabbix-server systemd[1]: Started SYSV: Starts and stops Zabbix Server using chkconfig.

[root@zabbix-server zabbix]# /etc/init.d/zabbix_agentd status
● zabbix_agentd.service - SYSV: Starts and stops Zabbix Agent using chkconfig
   Loaded: loaded (/etc/rc.d/init.d/zabbix_agentd; bad; vendor preset: disabled)
   Active: active (running) since Tue 2023-12-12 23:50:23 CST; 44s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 11742 ExecStart=/etc/rc.d/init.d/zabbix_agentd start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/zabbix_agentd.service
           ├─11753 /usr/local/zabbix//sbin/zabbix_agentd
           ├─11755 /usr/local/zabbix//sbin/zabbix_agentd: collector [idle 1 sec]
           ├─11756 /usr/local/zabbix//sbin/zabbix_agentd: listener #1 [waiting for connection]
           ├─11757 /usr/local/zabbix//sbin/zabbix_agentd: listener #2 [waiting for connection]
           ├─11758 /usr/local/zabbix//sbin/zabbix_agentd: listener #3 [waiting for connection]
           └─11759 /usr/local/zabbix//sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Dec 12 23:50:23 zabbix-server systemd[1]: Starting SYSV: Starts and stops Zabbix Agent using chkconfig...
Dec 12 23:50:23 zabbix-server zabbix_agentd[11742]: Starting zabbix_agentd:  [  OK  ]
Dec 12 23:50:23 zabbix-server systemd[1]: Started SYSV: Starts and stops Zabbix Agent using chkconfig.
更改数据库
[root@zabbix-server ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 10.6.16-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> set names utf8;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> use zabbix;
Database changed
MariaDB [zabbix]> source /usr/local/zabbix/database/mysql/schema.sql

MariaDB [zabbix]> source /usr/local/zabbix/database/mysql/data.sql;

MariaDB [zabbix]> source /usr/local/zabbix/database/mysql/images.sql;

### 导入数据
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| auditlog                   |
| autoreg_host               |
| changelog                  |
| conditions                 |
| config                     |
| config_autoreg_tls         |
| connector                  |
| connector_tag              |
| corr_condition             |
| corr_condition_group       |
| corr_condition_tag         |
| corr_condition_tagpair     |
| corr_condition_tagvalue    |
| corr_operation             |
| correlation                |
| dashboard                  |
| dashboard_page             |
| dashboard_user             |
| dashboard_usrgrp           |
| dbversion                  |
| dchecks                    |
| dhosts                     |
| drules                     |
| dservices                  |
| escalations                |
| event_recovery             |
| event_suppress             |
| event_symptom              |
| event_tag                  |
| events                     |
| expressions                |
| functions                  |
| globalmacro                |
| globalvars                 |
| graph_discovery            |
| graph_theme                |
| graphs                     |
| graphs_items               |
| group_discovery            |
| group_prototype            |
| ha_node                    |
| history                    |
| history_log                |
| history_str                |
| history_text               |
| history_uint               |
| host_discovery             |
| host_inventory             |
| host_rtdata                |
| host_tag                   |
| hostmacro                  |
| hosts                      |
| hosts_groups               |
| hosts_templates            |
| housekeeper                |
| hstgrp                     |
| httpstep                   |
| httpstep_field             |
| httpstepitem               |
| httptest                   |
| httptest_field             |
| httptest_tag               |
| httptestitem               |
| icon_map                   |
| icon_mapping               |
| ids                        |
| images                     |
| interface                  |
| interface_discovery        |
| interface_snmp             |
| item_condition             |
| item_discovery             |
| item_parameter             |
| item_preproc               |
| item_rtdata                |
| item_tag                   |
| items                      |
| lld_macro_path             |
| lld_override               |
| lld_override_condition     |
| lld_override_opdiscover    |
| lld_override_operation     |
| lld_override_ophistory     |
| lld_override_opinventory   |
| lld_override_opperiod      |
| lld_override_opseverity    |
| lld_override_opstatus      |
| lld_override_optag         |
| lld_override_optemplate    |
| lld_override_optrends      |
| maintenance_tag            |
| maintenances               |
| maintenances_groups        |
| maintenances_hosts         |
| maintenances_windows       |
| media                      |
| media_type                 |
| media_type_message         |
| media_type_param           |
| module                     |
| opcommand                  |
| opcommand_grp              |
| opcommand_hst              |
| opconditions               |
| operations                 |
| opgroup                    |
| opinventory                |
| opmessage                  |
| opmessage_grp              |
| opmessage_usr              |
| optemplate                 |
| problem                    |
| problem_tag                |
| profiles                   |
| proxy_autoreg_host         |
| proxy_dhistory             |
| proxy_history              |
| regexps                    |
| report                     |
| report_param               |
| report_user                |
| report_usrgrp              |
| rights                     |
| role                       |
| role_rule                  |
| scim_group                 |
| script_param               |
| scripts                    |
| service_alarms             |
| service_problem            |
| service_problem_tag        |
| service_status_rule        |
| service_tag                |
| services                   |
| services_links             |
| sessions                   |
| sla                        |
| sla_excluded_downtime      |
| sla_schedule               |
| sla_service_tag            |
| sysmap_element_trigger     |
| sysmap_element_url         |
| sysmap_shape               |
| sysmap_url                 |
| sysmap_user                |
| sysmap_usrgrp              |
| sysmaps                    |
| sysmaps_element_tag        |
| sysmaps_elements           |
| sysmaps_link_triggers      |
| sysmaps_links              |
| tag_filter                 |
| task                       |
| task_acknowledge           |
| task_check_now             |
| task_close_problem         |
| task_data                  |
| task_remote_command        |
| task_remote_command_result |
| task_result                |
| timeperiods                |
| token                      |
| trends                     |
| trends_uint                |
| trigger_depends            |
| trigger_discovery          |
| trigger_queue              |
| trigger_tag                |
| triggers                   |
| user_scim_group            |
| userdirectory              |
| userdirectory_idpgroup     |
| userdirectory_ldap         |
| userdirectory_media        |
| userdirectory_saml         |
| userdirectory_usrgrp       |
| users                      |
| users_groups               |
| usrgrp                     |
| valuemap                   |
| valuemap_mapping           |
| widget                     |
| widget_field               |
+----------------------------+
186 rows in set (0.001 sec)

###### 重启服务
[root@zabbix-server ~]# systemctl restart mariadb
### 先备份
[root@zabbix-server zabbix]# cp /usr/local/zabbix/etc/zabbix_server.conf{,.bak}

[root@zabbix-server zabbix]# ll /usr/local/zabbix/etc/
total 44
-rw-r--r-- 1 root root 10630 Dec 12 23:42 zabbix_agentd.conf
drwxr-xr-x 2 root root     6 Dec 12 23:42 zabbix_agentd.conf.d
-rw-r--r-- 1 root root 16332 Dec 12 23:42 zabbix_server.conf
-rw-r--r-- 1 root root 16332 Dec 12 23:59 zabbix_server.conf.bak
drwxr-xr-x 2 root root     6 Dec 12 23:42 zabbix_server.conf.d

# vi /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBHost=localhost 					### 指定数据库信息(需配合参数 DBSocket 使用) 
DBName=zabbix							###服务端连接数据库的库名
DBUser=zabbix							###连接数据库的用户
DBPassword=zabbix					###连接数据库的密码
DBPort=3306								###指定连接数据库的端口
Timeout=30								###与 AGNET 和其它外部设备通信超时设置,单位为秒
LogSlowQueries=3000#			##用于服务端数据库慢查询功能,单位是毫秒
DBSocket=/var/lib/mysql/mysql.sock	###指定 MYSQL 的 SOCK 连接路径

[root@zabbix-server ~]# find / -name "*.sock"
/var/lib/mysql/mysql.sock

### 修改目录权限
[root@zabbix-server zabbix]# chown -R zabbix:zabbix /usr/local/zabbix/

### 重启服务
[root@zabbix-server zabbix]# /etc/init.d/zabbix_server restart
Restarting zabbix_server (via systemctl):                  [  OK  ]
修改PHP

修改 php.ini 的配置文件

[root@zabbix-server ~]# cp /etc/opt/remi/php74/php.ini{,.bak}
[root@zabbix-server ~]# vim /etc/opt/remi/php74/php.ini
post_max_size = 32M
max_execution_time = 350
max_input_time = 350
date.timezone = Asia/Shanghai

修改 php-fpm.conf 的配置文件

[root@zabbix-server ~]# grep -v "^;" /etc/opt/remi/php74/php-fpm.d/www.conf.bak > /etc/opt/remi/php74/php-fpm.d/www.conf

[root@zabbix-server ~]# cat /etc/opt/remi/php74/php-fpm.d/www.conf
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/opt/remi/php74/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/opt/remi/php74/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/opt/remi/php74/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/opt/remi/php74/lib/php/wsdlcache

[root@zabbix-server ~]# systemctl restart php74-php-fpm
find  / -name "*.sock"

cp -rf /usr/local/zabbix/ui/* /data/nginx/zabbix/

[root@zabbix-server ~]# grep -v "^;" /etc/opt/remi/php74/php-fpm.d/www.conf.bak > /etc/opt/remi/php74/php-fpm.d/www.conf

[root@zabbix-server ~]# cat /etc/opt/remi/php74/php-fpm.d/www.conf
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/opt/remi/php74/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/opt/remi/php74/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/opt/remi/php74/lib/php/session
php_value[soap.wsdl_cache_dir]  = /var/opt/remi/php74/lib/php/wsdlcache

[root@zabbix-server ~]# systemctl restart php74-php-fpm
添加配置文件
[root@zabbix-server ~]# mv zabbix.conf.php /data/nginx/zabbix/conf

[root@zabbix-server ~]# ll /data/nginx/zabbix/conf
total 12
-rw-r--r-- 1 root root 1036 Dec 13 00:09 maintenance.inc.php
-rw-r--r-- 1 root root  428 Dec 12 16:27 zabbix.conf.php
-rw-r--r-- 1 root root  741 Dec 13 00:09 zabbix.conf.php.example

在这里插入图片描述

zabbix客户端

[root@http ~]# hostnamectl set-hostname zabbix-agent
[root@http ~]# bash
[root@zabbix-agent ~]# systemctl disable firewalld --now && setenforce 0
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@zabbix-agent ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 

[root@zabbix-agent ~]# wget http://repo.zabbix.com/zabbix/6.4/rhel/7/x86_64/zabbix-agent-6.4.9-release1.el7.x86_64.rpm


### 缺少 libpcre2-8.so.0 依赖
[root@zabbix-agent ~]# rpm -ivh zabbix-agent-6.4.9-release1.el7.x86_64.rpm 
warning: zabbix-agent-6.4.9-release1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
error: Failed dependencies:
        libpcre2-8.so.0()(64bit) is needed by zabbix-agent-6.4.9-release1.el7.x86_64

### 安装依赖
[root@zabbix-agent ~]# http://mirror.centos.org/centos/7/os/x86_64/Packages/pcre2-10.23-2.el7.x86_64.rpm
[root@zabbix-agent ~]# rpm -ivh pcre2-10.23-2.el7.x86_64.rpm

### 另一种方法
[root@zabbix-agent ~]# yum install -y http://repo.zabbix.com/zabbix/6.4/rhel/7/x86_64/zabbix-agent-6.4.9-release1.el7.x86_64.rpm
安装完后我们后面经常使用的文件如路径如下:
/etc/zabbix/zabbix_agentd.conf			### zabbix_agentd 配置文件
/etc/zabbix/zabbix_agentd.d					### zabbix_agentd 进程文件
/var/run/zabbix/zabbix_agentd.pid		###zabbix_agentd pid 文件路径 
/var/log/zabbix/zabbix_agentd.log		###zabbix_agentd 日志文件路径
修改配置文件
### 这个命令的作用是从/etc/zabbix/zabbix_agentd.conf.bak文件中筛选出不以空行或以#开头的行,并将结果输出到/etc/zabbix/zabbix_agentd.conf文件中

[root@zabbix-agent ~]# egrep -v '^$|#' /etc/zabbix/zabbix_agentd.conf.bak > /etc/zabbix/zabbix_agentd.conf

[root@zabbix-agent ~]# vim /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0								### 指定日志文件的大小,单位 MB。0 表示禁用日志轮转
ListenPort=10050						### 指定监听端口
StartAgents=3				### Zabbix 启动之后开启被动监控的进程数量,如果设置 为 0,那么 Zabbix 被动监控被禁用
ListenIP=0.0.0.0						### 监听 IP 地址,默认为所有接口
Server=192.168.169.204			### 允许哪个 Zabbix server 的 IP 地址监控本机
#ServerActive=127.0.0.1			### Zabbix 主动监控 server 的 ip 地址
Hostname=zabbix-agent
Include=/etc/zabbix/zabbix_agentd.d/*.conf		### 自定义配置文件

主动模式和被动模式的区别:

● 主动模式:Zabbix 的 agent 端,也就是客户端,主动把自己监测到的数

据,上报给 Zabbix 服务器,Zabbix 服务器不需要向 agent 发起请求。

注意:ServerActive 是主动模式开关,注释掉主动模式关闭;与 Server 不能

同时配置。

●被动模式:Zabbix 服务器向 agent 发送请求,告诉 agnet 我需要哪些数据,

然后 agnet 执行相关操作,把执行结果返回给服务端。

注意:StartAgents=0 表示被动模式关闭。

### 重启生效配置
[root@zabbix-agent ~]# systemctl enable zabbix-agent --now
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@zabbix-agent ~]# systemctl restart zabbix-agent
[root@zabbix-agent ~]# systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
   Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-12-13 00:52:23 CST; 5s ago
  Process: 1350 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
 Main PID: 1352 (zabbix_agentd)
   CGroup: /system.slice/zabbix-agent.service
           ├─1352 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
           ├─1353 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
           ├─1354 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
           ├─1355 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
           └─1356 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]

Dec 13 00:52:23 zabbix-agent systemd[1]: Starting Zabbix Agent...
Dec 13 00:52:23 zabbix-agent systemd[1]: Can't open PID file /run/zabbix/zabbix_agentd.pid (yet?) after start: No such file or directory
Dec 13 00:52:23 zabbix-agent systemd[1]: Started Zabbix Agent.


### 查看日志
[root@zabbix-agent ~]# tail -f /var/log/zabbix/zabbix_agentd.log 
  1352:20231213:005223.526 **** Enabled features ****
  1352:20231213:005223.526 IPv6 support:          YES
  1352:20231213:005223.526 TLS support:           YES
  1352:20231213:005223.526 **************************
  1352:20231213:005223.526 using configuration file: /etc/zabbix/zabbix_agentd.conf
  1352:20231213:005223.526 agent #0 started [main process]
  1354:20231213:005223.527 agent #2 started [listener #1]
  1353:20231213:005223.527 agent #1 started [collector]
  1355:20231213:005223.529 agent #3 started [listener #2]
  1356:20231213:005223.530 agent #4 started [listener #3]
  
### 查看端口
[root@zabbix-agent ~]# netstat -ntpl
Active Internet connectionns (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      925/sshd            
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1054/master         
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      1352/zabbix_agentd  
tcp6       0      0 :::22                   :::*                    LISTEN      925/sshd            
tcp6       0      0 ::1:25                  :::*                    LISTEN      1054/master
  • 11
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值