监控服务zabbix部署
2022/7/7 6:20:14
本文主要是介绍监控服务zabbix部署,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1. zabbix介绍
zabbix`是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix
能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix
由2部分构成,zabbix server
与可选组件zabbix agent
。
zabbix server
可以通过SNMP
,zabbix agent
,ping
,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Ubuntu,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
zabbix agent
需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。
zabbix server
可以单独监视远程服务器的服务状态;同时也可以与zabbix agent
配合,可以轮询zabbix agent
主动接收监视数据(agent方式),同时还可被动接收zabbix agent
发送的数据(trapping方式)。
另外zabbix server
还支持SNMP (v1,v2),可以与SNMP软件(例如:net-snmp)等配合使用。
2. zabbix特点
`zabbix的主要特点:
- 安装与配置简单,学习成本低
- 支持多语言(包括中文)
- 免费开源
- 自动发现服务器与网络设备
- 分布式监视以及WEB集中管理功能
- 可以无agent监视
- 用户安全认证和柔软的授权方式
- 通过WEB界面设置或查看监视结果
- email等通知功能
Zabbix主要功能:
- CPU负荷
- 内存使用
- 磁盘使用
- 网络状况
- 端口监视
- 日志监视
3. 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 | 0} |
UserParameter | 指定自定义监控脚本参数 |
LogFile | 设置客户端日志文件存放路径 |
4. 部署zabbix
4.1 zabbix服务端安装
//下载zabbix [root@localhost ~]# wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.25.tar.gz //解压安装包 [root@localhost ~]# tar xf zabbix-5.0.25.tar.gz [root@localhost ~]# ls anaconda-ks.cfg apr-util-1.6.1 php-7.4.29 apr-util-1.6.1.tar.gz oniguruma-6.9.4 php-7.4.29.tar.gz httpd-2.4.53 oniguruma-6.9.4.tar.gz zabbix-5.0.25.tar.gz //安装依赖包 [root@localhost ~]# yum -y install net-snmp-devel libevent-devel [root@localhost ~]# useradd -r -M -s /sbin/nologin zabbix //创建存放目录 [root@localhost ~]# mkdir -p /usr/lib/zabbix [root@localhost ~]# chown -R zabbix.zabbix /usr/lib/zabbix/ [root@localhost ~]# chmod 770 /usr/lib/zabbix/ //配置zabbix数据库 [root@localhost ~]# mysql -uroot -pruntime123 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.37 MySQL Community Server (GPL) Copyright (c) 2000, 2022, Oracle and/or its affiliates. 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 statement. mysql> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.01 sec) mysql> create user 'zabbix'@'localhost' identified by 'runtime123'; Query OK, 0 rows affected (0.03 sec) mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.02 sec) mysql> quit Bye //向数据库里面插入文件 [root@localhost mysql]# mysql -uzabbix -pruntime zabbix < schema.sql mysql: [Warning] Using a password on the command line interface can be insecure. [root@localhost mysql]# mysql -uzabbix -pruntime zabbix < images.sql mysql: [Warning] Using a password on the command line interface can be insecure. [root@localhost mysql]# mysql -uzabbix -pruntime zabbix < data.sql mysql: [Warning] Using a password on the command line interface can be insecure. [root@localhost mysql]# cd [root@localhost ~]# cd zabbix-5.0.25/ [root@localhost zabbix-5.0.25]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
4.2 zabbix服务端配置
//修改服务端配置文件 [root@localhost etc]# vim zabbix_server.conf .... DBPassword=runtime123 [root@localhost etc]# zabbix_server [root@localhost etc]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 0.0.0.0:10051 0.0.0.0:* LISTEN 0 128 127.0.0.1:9000 0.0.0.0:* LISTEN 0 128 *:80 *:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 80 *:3306 *:* [root@localhost etc]# zabbix_agentd [root@localhost etc]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 0.0.0.0:10050 0.0.0.0:* LISTEN 0 128 0.0.0.0:10051 0.0.0.0:* LISTEN 0 128 127.0.0.1:9000 0.0.0.0:* LISTEN 0 128 *:80 *:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 80 *:3306 *:*
4.3.1 zabbix web界面安装前配置
//修改/etc/php.ini的配置 [root@localhost ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini [root@localhost ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini [root@localhost ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini [root@localhost ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini [root@localhost ~]# service php-fpm restart //并重启php-fpm Gracefully shutting down php-fpm Starting php-fpm done [root@localhost ~]# cd /usr/local/apache/htdocs/ [root@localhost htdocs]# ls httpd.conf index.html test.com [root@localhost htdocs]# rm -rf * [root@localhost htdocs]# ls [root@localhost htdocs]# cd [root@localhost ~]# cd zabbix-5.0.25/ [root@localhost zabbix-5.0.25]# cp -a ui/* /usr/local/apache/htdocs/ [root@localhost zabbix-5.0.25]# cd /usr/local/apache/htdocs/ [root@localhost htdocs]# ls actionconf.php hostgroups.php overview.php api_jsonrpc.php hostinventoriesoverview.php queue.php app hostinventories.php report2.php applications.php host_prototypes.php report4.php assets host_screen.php robots.txt audio hosts.php screenconf.php auditacts.php httpconf.php screenedit.php browserwarning.php httpdetails.php screen.import.php chart2.php image.php screens.php chart3.php imgstore.php services.php chart4.php include setup.php chart5.php index_http.php slideconf.php chart6.php index.php slides.php chart7.php index_sso.php srv_status.php chart.php items.php sysmap.php conf js sysmaps.php conf.import.php jsLoader.php templates.php correlation.php jsrpc.php toptriggers.php discoveryconf.php local tr_events.php disc_prototypes.php locale trigger_prototypes.php favicon.ico maintenance.php triggers.php graphs.php map.import.php vendor history.php map.php zabbix.php host_discovery.php modules
4.3.2 安装zabbix web界面
开始安装
4.4 登录zabbix
zabbix默认登录用户名和密码:
用户名 | 密码 |
---|---|
Admin | zabbix |
进入ZABBIX界面
这篇关于监控服务zabbix部署的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-28微服务架构中API版本控制的实践
- 2024-09-28AI给的和自己写的Python代码,都无法改变输入框的内容,替换也不行
- 2024-09-27Sentinel配置限流资料:新手入门教程
- 2024-09-27Sentinel配置限流资料详解
- 2024-09-27Sentinel限流资料:新手入门教程
- 2024-09-26Sentinel限流资料入门详解
- 2024-09-26Springboot框架资料:初学者入门教程
- 2024-09-26Springboot框架资料详解:新手入门教程
- 2024-09-26Springboot企业级开发资料:新手入门指南
- 2024-09-26SpringBoot企业级开发资料新手指南