一文吃透zabbix4.0的编译安装,最全最详细的安装。
什么是zabbix? zabbix作为一款企业级,开源的,分布式的监控套件,解决了以往监控软件的短板,可以说是现在流行的监控解决方案之一。
监控系统的理想化模样 1.监控数据收集及可视化。 2.数据要保存在数据库中。这样以后需要的时候可以对这些数据进行分析计算。
3.方便,快速将监控加入服务器上,不需要繁琐的操作。 4.数据可视化不要很花里胡哨,直观好用。
异常数据报警 1.可以定义复杂的报警逻辑,可以做到Item之间的关联报警,而不是针对一个。 2.报警需要被确认,让运维人员知道多少报警已经有人认领并开始处理。 3.报警方式需要自定义,可以发送邮件和短信。 4.报警内容可以自行设置,在报警邮件中加入一些简单的分析,而不是让运维人员上服务器敲命令来获取基本的信息。 5.报警可以自动跑一些命令,这些命令是需要获取信息,也可以是自动修复。 和其他系统协同工作。 (1)有强大的API可以使用,可以让其他系统调用完成工作 (2)监控数据是开放的,数据库中的数据结构不要太复杂,让人无从下手。 (3)监控可视化的图可以方便的引用,而不是要一大串javascript。
zabbix的编译安装 相对于yum安装,还是编译安装最舒服一些 1.自定义软件功能 2.优化编译参数,提高性能 3.解决不必要的软件依赖 4.易做代码升级
进入正题 1.机器规划 10.0.0.20 zabbix Server 10.0.0.23 mysql master 2.zabbix官网下载源码包
cd /usr/local/src groupadd -g 1002 zabbix groupadd -u 1002 -g 1002 zabbix id zabbix 验证zabbix用户 wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.15/zabbix-4.0.15.tar.gz 3.解决必要的依赖关系 #apt install libmysqld-dev libmysqlclient-dev libxml2-dev libxml2 snmp libsnmp-dev libevent-dev curl libcurl4-openssl-dev #apt install openjdk-8-jdk 4.开始编译安装
./configure -prefix=/apps/zabbix_server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 LDAP support: no IPv6 support: no *********************************************************** * Now run 'make install' * * * * Thank you for using Zabbix! * * <http://www.zabbix.com> * *********************************************************** #make #make install
/usr/bin/install -c -m 644 'zabbix_agentd.man' '/apps/zabbix_proxy/share/man/man8/zabbix_agentd.8'
/usr/bin/install -c -m 644 'zabbix_proxy.man' '/apps/zabbix_proxy/share/man/man8/zabbix_proxy.8'
make[2]: Leaving directory '/usr/local/src/zabbix-4.0.29/man'
make[1]: Leaving directory '/usr/local/src/zabbix-4.0.29/man'
Making install in misc
make[1]: Entering directory '/usr/local/src/zabbix-4.0.29/misc'
make[2]: Entering directory '/usr/local/src/zabbix-4.0.29/misc'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/usr/local/src/zabbix-4.0.29/misc'
make[1]: Leaving directory '/usr/local/src/zabbix-4.0.29/misc'
make[1]: Entering directory '/usr/local/src/zabbix-4.0.29'
make[2]: Entering directory '/usr/local/src/zabbix-4.0.29'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/usr/local/src/zabbix-4.0.29'
make[1]: Leaving directory '/usr/local/src/zabbix-4.0.29'
root@zabbix-server:~# ll /apps/zabbix_server/
total 28
drwxr-xr-x 7 root root 4096 Mar 10 14:33 ./
drwxr-xr-x 3 root root 4096 Mar 10 14:35 ../
drwxr-xr-x 2 root root 4096 Mar 10 14:33 bin/
drwxr-xr-x 4 root root 4096 Mar 10 14:33 etc/
drwxr-xr-x 3 root root 4096 Mar 10 14:33 lib/
drwxr-xr-x 3 root root 4096 Mar 10 14:34 sbin/
drwxr-xr-x 4 root root 4096 Mar 10 14:33 share/
5.准备数据库 数据库的名称为zabbix_server1;用户名冷雨夜,密码yuye root@zabbix-server:~# apt install apache2 mysql-client root@mysql-master:~# mysql mysql> create database zabbix_server1 character set utf8 collate utf8_bin; grant all privileges on zabbix_server1.* to lengyuye@"10.0.0.%" identified by 'yuye.zabbix'; mysql> flush privileges; 6.导入数据库 6.1 zabbix_server节点验证是否可以成功登录mysl root@zabbix-server:/usr/local/src/zabbix-4.0.29/database/mysql# mysql -ulengyuye -pyuye.zabbix -h10.0.0.23 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 4 Server version: 5.7.33-0ubuntu0.18.04.1 (Ubuntu) Copyright (c) 2000, 2021, 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> 6.2 导入数据库 #编译安装和apt安装还是稍微不一样的,且看。看你是那一个数据库。 pwd #/usr/local/src/zabbix-4.0.29/database/mysql #检测这个错误,不要紧,意思就是检测到明文密码是不安全的,没关系 root@zabbix-server:/usr/local/src/zabbix-4.0.29/database/mysql# mysql -ulengyuye -pyuye.zabbix -h10.0.0.23 zabbix_server1 < schema.sql mysql: [Warning] Using a password on the command line interface can be insecure. root@zabbix-server:/usr/local/src/zabbix-4.0.29/database/mysql# mysql -ulengyuye -pyuye.zabbix -h10.0.0.23 zabbix_server1 < images.sql mysql: [Warning] Using a password on the command line interface can be insecure. root@zabbix-server:/usr/local/src/zabbix-4.0.29/database/mysql# mysql -ulengyuye -pyuye.zabbix -h10.0.0.23 zabbix_server1 < data.sql mysql: [Warning] Using a password on the command line interface can be insecure.
7.验证数据库 mysql> use zabbix_server1; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +----------------------------+ | Tables_in_zabbix_server1 | +----------------------------+ | 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)
8.编辑zabbix server配置文件修改参数 root@zabbix-server:~# vim /apps/zabbix_server/etc/zabbix_server.conf DBHost=10.0.0.23 DBName=zabbix_server1 DBUser=lengyuye DBPassword=lengyuye 9.启动zabbix #查看zabbix的端口是否被监听 root@zabbix-server:/var/www/html/zabbix# ss -tnl LISTEN 0 128 0.0.0.0:10051 0.0.0.0:* LISTEN 0 128 0.0.0.0:43397 #端口已经被监听启动zabbix server /apps/zabbix_server/sbin/zabbix_server -c /apps/zabbix_server/etc/zabbix_server.conf root@zabbix-server:~# tail /tmp/zabbix_server.log 1706:20210310:220941.608 VMware monitoring: YES 1706:20210310:220941.608 SMTP authentication: YES 1706:20210310:220941.608 Jabber notifications: NO 1706:20210310:220941.608 Ez Texting notifications: YES 1706:20210310:220941.608 ODBC: NO 1706:20210310:220941.608 SSH support: NO 1706:20210310:220941.608 IPv6 support: NO 1706:20210310:220941.608 TLS support: NO 1706:20210310:220941.608 ****************************** 1706:20210310:220941.608 using configuration file: /apps/zabbix_server/etc/zabbix_server.conf
10.登录zabbix #一定会报错,解决方法如下
11.修改配置文件 apt-get install php7.2-ladp apt-get install php7.2-bcmath systemctl restart mysql systemctl restart apache2
再次登录已经全部OK!!!
12.设置数据库
13.zabbix server设置
14.确认信息
15.手动创建配置文件 <?php // Zabbix GUI configuration file. global $DB; $DB['TYPE'] = 'MYSQL'; $DB['SERVER'] = '10.0.0.23'; $DB['PORT'] = '3306'; $DB['DATABASE'] = 'zabbix_server1'; $DB['USER'] = 'lengyuye'; $DB['PASSWORD'] = 'yuye.zabbix'; // Schema name. Used for IBM DB2 and PostgreSQL. $DB['SCHEMA'] = ''; $ZBX_SERVER = 'localhost'; $ZBX_SERVER_PORT = '10051'; $ZBX_SERVER_NAME = 'zabbix-server'; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; #刷新页面,成功显示。
16.登录zabbix 用户名Admin
密码zabbix
编译安装到这里就全部OK了希望对有所帮助,!!!