1. 程式人生 > >一文吃透zabbix4.0的編譯安裝,最全最詳細的安裝。

一文吃透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了希望對有所幫助,!!!