一、简介 Zabbix的常用组件 ?Zabbix Web Gui: 提供Web界面。 Zabbix Databases:提供数据库存储功能并用于存储配置信息。以及采集到的数据。 ?Zabbix Server : 接收来自Agent采集数据的核心组件。 ?Zabbix Agent :部署在被监控的主机上,用于采集本地的数据。 ?Zabbix Proxy: 当监控节点较多时,用于减轻Server压力组件,也可用于分布式。监控系统,由Proxy接收数据后统一发送给Server。 进程 ?zabbix-_agentd:客户端守护进程,负责收集客户端数据,例如cpu负载、内存、硬盘使用情况等。 ?zabbix_get:zabbix数据接收工具,单独使用的命令,通常在Server或者Proxy端执行获取远端客户信息的命令。通常客户排错。例如在Server端获取不到客户端的内存数据,我们可以使用zabbix_get获取客户端的内容的方式来做故障排查。 ?zabbix_sender:zabbix数据发送工具,用于发送数据给Server或者Proxy,通常用于耗时比较长的检查。很多检查非常耗时间,导致zabbix超时。于是我们在脚本执行完毕之后,使用sender主动提交数据。 ?zabbix--_proxy:zabbix代理守护进程。功能类似Server,唯一不同的是它只是一个中转站,它需要把收集到的数据提交/被提交到Server里。 ?zabbix-_java-_gateway:Java网关,类似agentd,但是只用于Java方面。它只能主动去获取数据,而不能被动获取数据。它的数据最终会给到Server或者proxy。 二、Zabbix监控平台搭建 环境介绍: ?CentOS 7.5 ?Zabbix-server(监控端)192.168.92.111 ?Zabbix-agent (被监控端)192.168.92.14 1.基础环境配置: systemctl disable firewalld systemctl stop firewalld setenforce=0 vim /etc/sysconfig/selinux,修改为SELINUX=disabled getenforce yum install tree net-tool net-snmp vim ntpdate wget #安装部分基础软件包 #修改yum源 更改为阿里云 cd /etc/yum.repos.d/ mv CentOS-Base.repo CentOS-Base.repo.bak #下载阿里云镜像仓库 wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo #下载epel仓库 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo yum clean all #重新生成缓存 yum makecache 2.安装Mysql数据库 wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm ls mysql57-community-release-el7-11.noarch.rpm #安装Mysql Yum源 rpm -ivh mysql57-community-release-el7-11.noarch.rpm yum -y install mysql-server systemctl start mysqld systemctl enable mysqld #tcp LISTEN 0 80 [::]:3306 [::]:* users:(("mysqld",pid=54086,fd=21)) ss -antulp | grep :3306 #查看初始密码 grep ‘root@localhost:‘ /var/log/mysqld.log mysql -hlocalhost -uroot -p‘hsQ(7(so_cgX‘ alter user root@"localhost" identified by "123qqq...A"; mysql -uroot -p123qqq...A 3.安装Zabbix 5.0监控平台 #安装Zabbix Yum源仓库 rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm yum clean all #安装Zabbix Server 与 Zabbix agent yum -y install zabbix-server-mysql zabbix-agent 注意: 1.如果安装中报错:Delta RPMs disabled because /usr/bin/applydeltarpm not installed,则安装 deltarpm软件。 yum -y install deltarpm 2.安装zabbixserver,,zabbix-agent的时候,报错: Error downloading packages: zabbix-server-mysql-5.0.2-1.el7.x86_64: [Errno 256] No more mirrors to try. zabbix-agent-5.0.2-1.el7.x86_64: [Errno 256] No more mirrors to try. 问题分析 一般这样的问题是因为用的国外源,下载速度慢导致的,可以多下载几次试试,或者直接换成阿里的源,或者先执行yum -y install zabbix-server-mysql,然后执行yum -y install zabbix-server-mysql zabbix-agent #安装Zabbix frontend yum -y install centos-release-scl vim /etc/yum.repos.d/zabbix.repo [zabbix-frontend] name=Zabbix Official Repository frontend - $basearch baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend enabled=1 //将0修改为1 #安装Zabbix前端包 yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl yum -y install zabbix-web #yum下载多次出错,wget下载,然后rpm方式安装 wget http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/frontend/zabbix-web-5.0.5-1.el7.noarch.rpm #查询noarch包zabbix-web rpm -ivh zabbix-web-5.0.5-1.el7.noarch.rpm rpm -qa | grep zabbix-web #再次执行yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl #[zabbix-non-supported]换成aliyun镜像报错: failure: repodata/repomd.xml from zabbix-non-supported: [Errno 256] No more mirrors to try. https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearc/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found Error downloading packages: zabbix-web-5.0.5-1.el7.noarch: [Errno 256] No more mirrors to try. 解决: wget http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/frontend/zabbix-web-5.0.5-1.el7.noarch.rpm #查询noarch包zabbix-web rpm -ivh zabbix-web-5.0.5-1.el7.noarch.rpm rpm -qa | grep zabbix-web #将官方yum源的地址改为阿里云的地址,仍然报错 vim /etc/yum.repos.d/zabbix.repo [zabbix] name=Zabbix Official Repository - $basearch baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 [zabbix-non-supported] name=Zabbix Official Repository non-supported - $basearch baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearc/ enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgcheck=1 创建和初始化数据库 mysql -uroot -p123qqq...A create database zabbix character set utf8 collate utf8_bin; create user zabbix@localhost identified by ‘123qqq...A‘; grant all privileges on zabbix.* to zabbix@localhost; show databases; exit #导入Zabbix数据库结构和数据 zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p123qqq...A zabbix #mysql: [Warning] Using a password on the command line interface can be insecure. 4.配置Zabbix server ls /etc/opt/rh/rh-nginx116/nginx ls: cannot access /etc/opt/rh/rh-nginx116/nginx: No such file or directory 解决:单独安装 rh-nginx116 yum -y install rh-nginx116 #无此文件 [root@localhost ~]# vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf server { # listen 80; # server_name example.com; 取消以上两行注释修改后为以下: server { listen 80; server_name example.com; ... [root@localhost ~]# cat /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf server { listen 80; server_name example.com; root /usr/share/zabbix; index index.php; location = /favicon.ico { log_not_found off; } location / { try_files $uri $uri/ =404; } location /assets { access_log off; expires 10d; } location ~ /\.ht { deny all; } location ~ /(api\/|conf[^\.]|include|locale) { deny all; return 404; } location ~ [^/]\.php(/|$) { fastcgi_pass unix:/var/opt/rh/rh-php72/run/php-fpm/zabbix.sock; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; fastcgi_param DOCUMENT_ROOT /usr/share/zabbix; fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name; fastcgi_param PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name; include fastcgi_params; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_intercept_errors on; fastcgi_ignore_client_abort off; fastcgi_connect_timeout 60; fastcgi_send_timeout 180; fastcgi_read_timeout 180; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; } } [root@localhost ~]# vim /etc/zabbix/zabbix_server.conf ... 116 DBUser=zabbix //用户名要与数据库中创建的供zabbix访问的用户名一致 ... 124 DBPassword=# //去掉注释,添加创建的zabbix用户的数据库密码 ... #为Zabbix前端配置PHP,不能用#注释,否则php无法识别 ; php_value[date.timezone] = Europe/Riga --》取消注释将Europe/Riga时区修改为以下: php_value[date.timezone] = Aisa/Shanghai listen.acl_users = apache,nginx //添加一个nginx vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf [zabbix] user = apache group = apache listen = /var/opt/rh/rh-php72/run/php-fpm/zabbix.sock listen.acl_users = apache,nginx //添加一个nginx 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 php_value[session.save_handler] = files php_value[session.save_path] = /var/opt/rh/rh-php72/lib/php/session/ php_value[max_execution_time] = 300 php_value[memory_limit] = 128M php_value[post_max_size] = 16M php_value[upload_max_filesize] = 2M php_value[max_input_time] = 300 php_value[max_input_vars] = 10000 ; php_value[date.timezone] = Europe/Riga --》取消注释将Europe/Riga时区修改为以下: php_value[date.timezone] = Asia/Shanghai 6.开启服务 systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm systemctl status zabbix-server systemctl status zabbix-agent systemctl status httpd systemctl status rh-php72-php-fpm systemctl start rh-php72-php-fpm systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm #rh-php72-php-fpm服务未启动 [root@node1 ~]# systemctl status rh-php72-php-fpm ● rh-php72-php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/rh-php72-php-fpm.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Sat 2020-11-28 13:44:57 CST; 3min 55s ago Process: 4031 ExecStart=/opt/rh/rh-php72/root/usr/sbin/php-fpm --nodaemonize (code=exited, status=78) Main PID: 4031 (code=exited, status=78) Nov 28 13:44:57 node1 systemd[1]: Starting The PHP FastCGI Process Manager... Nov 28 13:44:57 node1 php-fpm[4031]: [28-Nov-2020 13:44:57] ERROR: [/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf:6] unknown entry ‘#listen.acl_users‘ Nov 28 13:44:57 node1 php-fpm[4031]: [28-Nov-2020 13:44:57] ERROR: Unable to include /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf from /etc/opt/rh/rh-php72/php-fpm.conf at line 6 Nov 28 13:44:57 node1 php-fpm[4031]: [28-Nov-2020 13:44:57] ERROR: failed to load configuration file ‘/etc/opt/rh/rh-php72/php-fpm.conf‘ Nov 28 13:44:57 node1 php-fpm[4031]: [28-Nov-2020 13:44:57] ERROR: FPM initialization failed Nov 28 13:44:57 node1 systemd[1]: rh-php72-php-fpm.service: main process exited, code=exited, status=78/n/a Nov 28 13:44:57 node1 systemd[1]: Failed to start The PHP FastCGI Process Manager. Nov 28 13:44:57 node1 systemd[1]: Unit rh-php72-php-fpm.service entered failed state. Nov 28 13:44:57 node1 systemd[1]: rh-php72-php-fpm.service failed. [root@localhost ~]# ss -antulp | grep :80 tcp LISTEN 0 128 :::80 :::* users:(("httpd",pid=5619,fd=4),("httpd",pid=5618,fd=4),("httpd",pid=5617,fd=4),("httpd",pid=5616,fd=4),("httpd",pid=5614,fd=4),("httpd",pid=5585,fd=4)) [root@localhost ~]# ps -aux | grep zabbix ...... apache 5677 0.0 0.3 336672 7316 ? S 16:36 0:00 php-fpm: pool zabbix root 5809 0.0 0.0 112736 976 pts/0 S+ 16:47 0:00 grep --color=auto zabbix 7.访问 http://192.168.92.111/zabbix/setup.php The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. ?可以看到已经登录到zabbix 5.0监控界面了,上面的红色提示不是报错,只是提示之前“2次登录尝试失败..”刷新一下提示就消失了。 修改Zabbix 5.0界面语言为中文:
原文:https://www.cnblogs.com/buffercache/p/14055949.html