參考鏈接
阿里巴巴開源鏡像站-OPSX鏡像站-阿里云開發(fā)者社區(qū) (aliyun.com)
zabbix鏡像-zabbix下載地址-zabbix安裝教程-阿里巴巴開源鏡像站 (aliyun.com)
Zabbix三種架構(gòu)
Server-Agent
Server-Node-Agent
Server-Proxy-Agent
配置介紹
Zabbix Proxy的配置
- Server-Node-Agent
- Server-Proxy-Agent
1、配置proxy主機
① 安裝相應(yīng)的zabbix包
zabbix-proxy-mysql zabbix-get zabbix-agent zabbix-sender
② 準備數(shù)據(jù)庫
創(chuàng)建、授權(quán)用戶、導(dǎo)入schema.sql
③ 修改配置文件
④ 在server端添加此Proxy
Administration ——> Proxies
⑤ 在Server端配置通過此Proxy監(jiān)控的主機
<font color =red>注意:zabbix agent端要允許zabbix proxy主機執(zhí)行數(shù)據(jù)采集操作</font>
實戰(zhàn)演練—分布式監(jiān)控
實驗部署架構(gòu)
| 主機名稱 | IP地址 | 服務(wù)角色 | 架構(gòu)類型 |
|---|---|---|---|
| zabbix-server | 192.168.200.60 | Zabbix 監(jiān)控端 | / |
| zabbix-agent-centos | 192.168.200.70 | Zabbix 客戶端 | Server-Agent |
| zbxproxy | 192.168.200.90 | Zabbix Proxy | / |
| zabbix-agent-02 | 192.168.200.100 | Zabbix 客戶端 | Server-Proxy-Agent |
1、實驗前期準備(Server端、Proxy端)
配置服務(wù)端和代理端時間同步
# 服務(wù)端和代理端安裝ntpdate服務(wù)包yum install -y ntpdate# 服務(wù)端和代理端同步阿里云時間服務(wù)器ntpdate ntp1.aliyun.com
關(guān)閉防火墻、SELinux安全模式
systemctl stop firewalldsystemctl disable firewalldsetenforce 0getenforceiptables -nL
設(shè)置主機名
配置域名解析
[root@zabbix-agent-02 ~]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.200.60 zabbix-server192.168.200.90 zbxproxy.xybdiy.com zbxproxy192.168.200.100 zabbix-agent-02
zabbix-server 直接監(jiān)控一臺主機zabbix-agent-centos
zabbix-server 通過代理zbproxy 監(jiān)控zabbix-agent-02
2、在代理服務(wù)器上配置MySQL
- 創(chuàng)建MariaDB.repo
[root@zbproxy yum.repos.d]# vim mariadb.repo[root@zbproxy yum.repos.d]# cat mariadb.repo[mariadb]name = MariaDBbaseurl = http://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64/gpgkey=http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDBgpgcheck=1
- 安裝mariadb
[root@zbproxy ~]# yum install -y MariaDB-server MariaDB-client

- 修改數(shù)據(jù)庫配置文件
[root@zbproxy ~]# vim /etc/my.cnf.d/server.cnf[mysqld]skip_name_resolve = ON # 跳過主機名解析innodb_file_per_table = ON # 開啟獨立表空間innodb_buffer_pool_size = 256M # 緩存池大小max_connections = 2000 # 最大連接數(shù)log-bin = master-log # 開啟二進制日志
- 啟動數(shù)據(jù)庫服務(wù)
[root@zbproxy ~]# systemctl start mariadb[root@zbproxy ~]# systemctl enable mariadb
- 初始化數(shù)據(jù)庫
[root@zbproxy ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none):OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password? [Y/n] yNew password:Re-enter new password:Password updated successfully!Reloading privilege tables..... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] n... skipping.By default, MariaDB comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y- Dropping test database...... Success!- Removing privileges on test database...... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y... Success!Cleaning up...All done! If you've completed all of the above steps, your MariaDBinstallation should now be secure.Thanks for using MariaDB![root@zbproxy ~]# mysql -uroot -p000
- 創(chuàng)建數(shù)據(jù)庫 和 授權(quán)用戶
# 創(chuàng)建數(shù)據(jù)庫zbxproxydbMariaDB [(none)]> create database zbxproxydb character set 'utf8';Query OK, 1 row affected (0.00 sec)# 授權(quán)用戶zbxproxydbMariaDB [(none)]> grant all on zbxproxydb.* to 'zbxproxyuser'@'192.168.200.%' identified by 'zbxproxypass';Query OK, 0 rows affected (0.00 sec)# 刷新,重新加載MariaDB [(none)]> flush privileges;Query OK, 0 rows affected (0.00 sec)# 退出MariaDB [(none)]> exitBye[root@zbproxy ~]#
3、在代理服務(wù)器上下載zabbix相應(yīng)的包。
主要是代理proxy的包
[root@zbproxy src]# yum localinstall zabbix-agent-5.0.20-1.el7.x86_64.rpm zabbix-proxy-mysql-5.0.20-1.el7.x86_64.rpm zabbix-get-5.0.20-1.el7.x86_64.rpm zabbix-sender-5.0.20-1.el7.x86_64.rpm

- 初始化數(shù)據(jù)庫
#查詢數(shù)據(jù)庫包[root@zbproxy src]# rpm -ql zabbix-proxy-mysql/etc/logrotate.d/zabbix-proxy/etc/zabbix/zabbix_proxy.conf/usr/lib/systemd/system/zabbix-proxy.service/usr/lib/tmpfiles.d/zabbix-proxy.conf/usr/lib/zabbix/externalscripts/usr/sbin/zabbix_proxy_mysql/usr/share/doc/zabbix-proxy-mysql-5.0.20/usr/share/doc/zabbix-proxy-mysql-5.0.20/AUTHORS/usr/share/doc/zabbix-proxy-mysql-5.0.20/COPYING/usr/share/doc/zabbix-proxy-mysql-5.0.20/ChangeLog/usr/share/doc/zabbix-proxy-mysql-5.0.20/NEWS/usr/share/doc/zabbix-proxy-mysql-5.0.20/README/usr/share/doc/zabbix-proxy-mysql-5.0.20/schema.sql.gz/usr/share/man/man8/zabbix_proxy.8.gz/var/log/zabbix/var/run/zabbix
zabbix-proxymysql 包里帶有導(dǎo)入數(shù)據(jù)的文件schema.sql.gz
# 復(fù)制schema.sql.gz[root@zbproxy ~]# cp /usr/share/doc/zabbix-proxy-mysql-5.0.20/schema.sql.gz .[root@zbproxy ~]# lsanaconda-ks.cfg schema.sql.gz# 解壓[root@zbproxy ~]# gzip -d schema.sql.gz[root@zbproxy ~]# lsanaconda-ks.cfg schema.sql# 導(dǎo)入數(shù)據(jù),出現(xiàn)以下問題[root@zbproxy ~]# mysql -uroot -p000 < schema.sqlERROR 1046 (3D000) at line 1: No database selected解決辦法:[root@zbproxy ~]# vim schema.sql在首部添加如下內(nèi)容:USE zbxproxydb;按:wq保存退出[root@zbproxy ~]# mysql -uroot -p000 < schema.sql
- 查看數(shù)據(jù)已經(jīng)生成
MariaDB [(none)]> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || zbxproxydb |+--------------------+4 rows in set (0.00 sec)MariaDB [(none)]> use zbxproxydb;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedMariaDB [zbxproxydb]> show tables;+----------------------------+| Tables_in_zbxproxydb |+----------------------------+| acknowledges || actions || alerts || application_discovery || application_prototype || application_template || applications || auditlog || auditlog_details || autoreg_host || conditions || config || config_autoreg_tls || 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 || host_tag || 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 || interface_snmp || item_application_prototype || item_condition || item_discovery || item_preproc || item_rtdata || items || items_applications || 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 || mappings || 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 || 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_data || task_remote_command || task_remote_command_result || task_result || timeperiods || trends || trends_uint || trigger_depends || trigger_discovery || trigger_tag || triggers || users || users_groups || usrgrp || valuemaps || widget || widget_field |+----------------------------+166 rows in set (0.00 sec)MariaDB [zbxproxydb]>
4、配置proxy端
[root@zbproxy ~]# vim /etc/zabbix/zabbix_proxy.confServer=192.168.200.60 # server 的IPServerPort=10051 # server 的端口Hostname=zbxproxy.xybdiy.com # 主機名ListenPort=10051 # proxy自己的監(jiān)聽端口EnableRemoteCommands=1 # 允許遠程命令LogRemoteCommands=1 # 記錄遠程命令的日志DBHost=192.168.200.90DBName=zbxproxydbDBUser=zbxproxyuserDBPassword=zbxproxypassConfigFrequency=30 # 意思是多長時間去服務(wù)端拖一次有自己監(jiān)控的操作配置,為了實驗更快的生效。這里設(shè)置30秒,默認3600sDataSenderFrequency=1 # 每一秒向server 端發(fā)一次數(shù)據(jù),發(fā)送頻度
開啟proxy服務(wù)
[root@zbxproxy zabbix]# systemctl start zabbix-proxy[root@zbxproxy zabbix]# systemctl enable zabbix-proxy
5、配置Agent端允許proxy代理監(jiān)控
[root@zabbix-agent-02 ~]# vim /etc/zabbix/zabbix_agentd.confServer=192.168.200.60,192.168.200.90ServerActive=192.168.200.60,192.168.200.90[root@zabbix-agent-02 ~]# systemctl restart zabbix-agent
6、把代理加入監(jiān)控server 創(chuàng)建配置agent代理
- 創(chuàng)建agent代理

- 配置


- 創(chuàng)建agent端主機并采用代理監(jiān)控








