RHEL7上面的zabbix部署安裝,包括服務器端和客戶端

本打算在rhel6上面安裝的,查了一下不支持,zabbix需要部署在rhel7以上,rhel6不支持,原因如下:

摘錄自官方文檔
Zabbix frontend on RHEL 6 is not supported because of PHP version. Since Zabbix 3.0 the requirements are to have PHP 5.4.0 or later while RHEL 6 latest version is 5.3.3 .
In most cases Zabbix server and frontend are installed on the same machine. When upgrading 2.2 to 3.0 Zabbix server will perform database upgrade and frontend will stop working. There is no way to roll back the database changes so users will be forced to upgrade PHP using 3rd party packages. This is why Zabbix server is also deprecated on RHEL 6.
https://blog.csdn.net/lampqiu/article/details/79483418

 

OS:RHEL7.3

服務器:db131

客戶端:db132

 

1.服務器端安裝LTS long time support:

[root@qht131 ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0
/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
Retrieving https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.r9QzXK: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-4.0-1.el7         ################################# [100%]


安裝完成之後,就會多一個zabbix的yum源:

[root@qht131 yum.repos.d]# ls
CentOS-Base.repo  zabbix.repo

如果直接獲取失敗,通過網頁打開,手動下載後手動安裝:

下載:

https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm

安裝:

rpm -ivh zabbix-release-4.0-1.el7.noarch.rpm

2.服務器端安裝zabbix相關服務器端軟件:

zabbix服務程序軟件: zabbix-server-mysql
zabbix服務web軟件: zabbix-web-mysql httpd php
數據庫服務軟件: mariadb-server

[root@db131 ~]# yum install -y zabbix-server-mysql zabbix-web-mysql httpd php

Installed:
  httpd.x86_64 0:2.4.6-90.el7.centos      php.x86_64 0:5.4.16-46.1.el7_7  zabbix-server-mysql.x86_64 0:4.0.16-1.el7 
  zabbix-web-mysql.noarch 0:4.0.16-1.el7 

Dependency Installed:
  OpenIPMI.x86_64 0:2.0.27-1.el7                            OpenIPMI-libs.x86_64 0:2.0.27-1.el7                     
  OpenIPMI-modalias.x86_64 0:2.0.27-1.el7                   apr.x86_64 0:1.4.8-5.el7                                
  apr-util.x86_64 0:1.5.2-6.el7                             fping.x86_64 0:3.10-1.el7                               
  httpd-tools.x86_64 0:2.4.6-90.el7.centos                  iksemel.x86_64 0:1.4-2.el7.centos                       
  libzip.x86_64 0:0.10.1-8.el7                              mailcap.noarch 0:2.1.41-2.el7                           
  php-bcmath.x86_64 0:5.4.16-46.1.el7_7                     php-cli.x86_64 0:5.4.16-46.1.el7_7                      
  php-common.x86_64 0:5.4.16-46.1.el7_7                     php-gd.x86_64 0:5.4.16-46.1.el7_7                       
  php-ldap.x86_64 0:5.4.16-46.1.el7_7                       php-mbstring.x86_64 0:5.4.16-46.1.el7_7                 
  php-mysql.x86_64 0:5.4.16-46.1.el7_7                      php-pdo.x86_64 0:5.4.16-46.1.el7_7                      
  php-xml.x86_64 0:5.4.16-46.1.el7_7                        t1lib.x86_64 0:5.1.2-14.el7                             
  unixODBC.x86_64 0:2.3.1-14.el7                            zabbix-web.noarch 0:4.0.16-1.el7                        

Dependency Updated:
  openssl.x86_64 1:1.0.2k-19.el7                         openssl-libs.x86_64 1:1.0.2k-19.el7                        

Complete!


[root@db131 ~]# yum install -y mariadb-server

Installed:
  mariadb-server.x86_64 1:5.5.64-1.el7                                                                               

Dependency Installed:
  mariadb.x86_64 1:5.5.64-1.el7                          perl-DBD-MySQL.x86_64 0:4.023-6.el7                         

Dependency Updated:
  mariadb-libs.x86_64 1:5.5.64-1.el7                                                                                 

Complete!

3.軟件配置:

設置zabbix密碼,修改zabbix_server.conf 第124行如下:

[root@qht131 ~]# vi /etc/zabbix/zabbix_server.conf 

    121 #
    122 # Mandatory: no
    123 # Default:
    124  DBPassword=zabbix
    125 
    126 ### Option: DBSocket

修改時間爲上海,修改zabbix.conf 第20行如下:

[root@qht131 ~]# vi /etc/httpd/conf.d/zabbix.conf 
     19         php_value always_populate_raw_post_data -1
     20         php_value date.timezone Asia/Shanghai
     21     </IfModule>
     22 </Directory>

4.開啓數據庫服務

[root@qht131 ~]# systemctl start mariadb.service
[root@qht131 ~]# systemctl status mariadb.service
?mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-12-20 14:48:02 CST; 3s ago
  Process: 4459 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 4363 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 4458 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           忖4458 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           忖4620 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin...

Dec 20 14:48:00 qht131 mariadb-prepare-db-dir[4363]: MySQL manual for more instructions.
Dec 20 14:48:00 qht131 mariadb-prepare-db-dir[4363]: Please report any problems at http://mariadb.org/jira
Dec 20 14:48:00 qht131 mariadb-prepare-db-dir[4363]: The latest information about MariaDB is available at http...rg/.
Dec 20 14:48:00 qht131 mariadb-prepare-db-dir[4363]: You can find additional information about the MySQL part at:
Dec 20 14:48:00 qht131 mariadb-prepare-db-dir[4363]: http://dev.mysql.com
Dec 20 14:48:00 qht131 mariadb-prepare-db-dir[4363]: Consider joining MariaDB's strong and vibrant community:
Dec 20 14:48:00 qht131 mariadb-prepare-db-dir[4363]: https://mariadb.org/get-involved/
Dec 20 14:48:00 qht131 mysqld_safe[4458]: 191220 14:48:00 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Dec 20 14:48:00 qht131 mysqld_safe[4458]: 191220 14:48:00 mysqld_safe Starting mysqld daemon with databases f...mysql
Dec 20 14:48:02 qht131 systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.

建立一個database,名叫zabbix

[root@qht131 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.64-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| zabbix             |
+--------------------+
5 rows in set (0.00 sec)

新建一個用戶,也叫zabbix:

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)

導入表信息到zabbix數據庫:

[root@qht131 ~]# zcat /usr/share/doc/zabbix-server-mysql-4.0.16/create.sql.gz | mysql -uzabbix -pzabbix zabbix

完成之後,zabbix庫中就有很多的表了:

MariaDB [(none)]> use zabbix
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
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)

MariaDB [zabbix]> 

5.啓動zabbix相關服務

[root@qht131 zabbix-server-mysql-4.0.16]# systemctl start zabbix-server.service httpd mariadb.service
[root@qht131 zabbix-server-mysql-4.0.16]# systemctl enable zabbix-server.service httpd mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

6.登錄web界面,進行初始化配置

需要關閉防火牆,否則只能本地登入

[root@qht131 zabbix-server-mysql-4.0.16]#  systemctl disable  firewalld

關閉selinux,編輯/etc/sysconfig/selinux文檔 

將SELINUX=enforcing改爲SELINUX=disabled。

 Next step

Next step,密碼爲zabbix

默認服務器端口10051,名字自定義,

Next setp:

 Finish

默認賬戶爲 Admin
密碼是剛纔設置的 zabbix

 登入成功

 

至此,服務端安裝結束!

 

7.客戶端也關閉防火牆和selinux

需要關閉防火牆,否則只能本地登入

[root@qht132 ~]#  systemctl disable  firewalld

關閉selinux,編輯/etc/sysconfig/selinux文檔 

將SELINUX=enforcing改爲SELINUX=disabled。

8.下載安裝zabbix客戶端軟件

[root@qht132 yum.repos.d]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
Retrieving https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.djjDzi: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-4.0-1.el7         ################################# [100%]

安裝完成之後,就會多一個zabbix的yum源:

[root@qht132 yum.repos.d]# ls
CentOS-Base.repo  zabbix.repo

9.安裝客戶端軟件:

[root@qht132 yum.repos.d]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.0-2.el7.x86_64.rpm
Retrieving https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.0-2.el7.x86_64.rpm
warning: /var/tmp/rpm-tmp.3maLIX: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-agent-4.0.0-2.el7         ################################# [100%]

10.更改客戶端 配置文件:

將zabbix_agentd.conf的第98行改成服務器的IP

[root@qht132 ~]# vi /etc/zabbix/zabbix_agentd.conf 

     94 # Mandatory: yes, if StartAgents is not explicitly set to 0
     95 # Default:
     96 # Server=
     97 
     98 Server=172.17.61.131
     99 
    100 ### Option: ListenPort

11.啓動zabbix客戶端軟件

[root@qht132 ~]# systemctl start zabbix-agent
[root@qht132 ~]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@qht132 ~]# netstat -nal | grep 10050
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN     
tcp6       0      0 :::10050                :::*                    LISTEN    

12.再來看一下服務器的web狀態,主機數據還是1,只有服務器,客戶端還沒有加上,需要配置一下。

  13.在zabbix控制平臺上,點配置--》主機》創建主機,添加主機名稱和IP地址,然後在模板裏面添加需要監控的模板後,就能查看相應的主機信息了。

主機數量是4個,我添加了3臺客戶端服務器。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章