- Zabbix 是一个企业级的分布式开源监控解决方案,能够监控各种网络参数以及服务器健康性和完整性的软件。
- Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的告警,这样可以快速反馈服务器的问题。
- 基于已存储的数据,Zabbix提供了出色的报告和数据可视化功能。
- Zabbix通过C/S模式采集监控数据
- Zabbix通过B/S模式实现Web管理
- 官方网站:www.zabbix.com
配置监控服务器前提环境
1.防火墙关闭
[root@server-zabbix ~]# systemctl stop firewalld.service
[root@server-zabbix ~]# setenforce 0
[root@server-zabbix ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
安装zabbix软件包
1.配置YUM源
[root@server-zabbix ~]# wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
[root@server-zabbix ~]# rpm -ivh zabbix-release-4.0-2.el7.noarch.rpm
2.修改zabbix.repo文件将官网地址替换为清华源地址
//yum源中zabbix默认下载是从zabbix官网下载的,比较慢,我们更改成清华源
[root@server-zabbix ~]# vim /etc/yum.repos.d/zabbix.repo
.....
:%s#http://repo.zabbix.com/#https://mirrors.tuna.tsinghua.edu.cn/zabbix/#g
:%s#gpgcheck=1#gpgcheck=0#g
3.添加阿里源
[root@server-zabbix ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
4.安装zabbix-server-mysql zabbix-web-mysql
[root@server-zabbix ~]# yum -y install zabbix-server-mysql zabbix-web-mysql
5.安装mariadb
[root@server-zabbix ~]# yum -y install mariadb-server
[root@server-zabbix ~]# systemctl start mariadb.service
[root@server-zabbix ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
6.初始化数据库
[root@server-zabbix ~]# mysql_secure_installation
Enter current password for root (enter for none):
Set root password? [Y/n] n
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
数据库授权
1.创建授权用户
[root@server-zabbix ~]# mysql
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
//zabbix库支持中文
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by '123456';
//创建授权用户
Query OK, 0 rows affected (0.00 sec)
2.导入zabbix初始架构数据
[root@server-zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password: 123456
3.进入数据库查看数据是否存在
[root@server-zabbix ~]# mysql -uzabbix -p123456
MariaDB [(none)]> use zabbix;
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_suppress |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| hstgrp |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| items |
| items_applications |
| maintenance_tag |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| 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 |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| tag_filter |
| task |
| task_acknowledge |
| task_check_now |
| task_close_problem |
| task_remote_command |
| task_remote_command_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
144 rows in set (0.00 sec)
配置zabbix连接数据库
1.修改zabix-server配置文件
[root@server-zabbix ~]# vim /etc/zabbix/zabbix_server.conf
....
DBName=zabbix //数据库名
DBUser=zabbix //连接数据库用户名
DBPassword=123456 //用户密码
2.启动zabbix-server
[root@server-zabbix ~]# systemctl start zabbix-server.service
[root@server-zabbix ~]# systemctl enable zabbix-server.service
[root@server-zabbix ~]# netstat -anput | grep 10051
3.为zabbix前端配置正确时区
[root@server-zabbix ~]# vim /etc/httpd/conf.d/zabbix.conf
...
<IfModule mod_php5.c>
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 always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai //配置正确时区
</IfModule>
4.启动httpd服务
[root@server-zabbix ~]# systemctl start httpd
[root@server-zabbix ~]# systemctl enable httpd
浏览器访问页面
http://192.168.1.61/zabbix/
设置中文
安装agent服
[root@server-zabbix ~]# yum -y install zabbix-agent
[root@server-zabbix ~]# systemctl start zabbix-agent.service
[root@server-zabbix ~]# systemctl enable zabbix-agent.service
1.被监控主机安装zabbix-agent程序
[root@client-zabbix ~]# wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.13-1.el7.x86_64.rpm
[root@client-zabbix ~]# rpm -ivh zabbix-agent-4.0.13-1.el7.x86_64.rpm
2.修改zabbix-agent配置文件指定主服务器信息
[root@client-zabbix ~]# vim /etc/zabbix/zabbix_agentd.conf
...
Server=192.168.1.61 //指定zabbix-server端地址
3.开启zabbix-agent
[root@client-zabbix ~]# systemctl start zabbix-agent.service
[root@client-zabbix ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
创建主机
查看监控信息