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台客户端服务器。

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