【zabbix入门学习】RHEL7.3安装zabbix3.5(一)安装zabbix server以及zabbix database的初始化

一、环境检查

[root@rhel:~]#cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.3 (Maipo)
[root@rhel:~]#uname -r
3.10.0-514.el7.x86_64    
[root@rhel:~]#getenforce
Disabled

二、官方源


首先,根据需求获取官方源:

[root@rhel:/opt]#wget http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
--2018-03-15 14:14:26--  http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
Resolving repo.zabbix.com (repo.zabbix.com)... 162.243.159.138
Connecting to repo.zabbix.com (repo.zabbix.com)|162.243.159.138|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13648 (13K) [application/x-redhat-package-manager]
Saving to: ‘zabbix-release-3.5-1.el7.noarch.rpm’

100%[================================>] 13,648      --.-K/s   in 0.03s   

2018-03-15 14:14:27 (423 KB/s) - ‘zabbix-release-3.5-1.el7.noarch.rpm’ saved [13648/13648]

安装源:

[root@rhel:/opt]#rpm -ivh zabbix-release-3.5-1.el7.noarch.rpm
warning: zabbix-release-3.5-1.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-3.5-1.el7         ################################# [100%]

安装完成之后,/etc/yum.repos.d目录下会产生zabbix.repo文件。

[root@rhel:/etc/yum.repos.d]#cat zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/3.5/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch 
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

yum源已就绪,后面执行yum install安装即可。

三、zabbix的几个重要组件

zabbix-server-mysql                  提供zabbix-server服务
zabbix-proxy-mysql                   提供zabbix的代理服务,可以实现分布式监控,减轻zabbix-server的压力
zabbix-web-mysql                     提供httpd服务
zabbix-get                                 提供检查是否能正确获取到zabbix的监控脚本key的监控值
zabbix-agent                             提供zabbix-agent服务

 

由于本次只是在PC的vmware虚拟机上安装测试,所以不安装zabbix-proxy-mysql组件。

四、安装zabbix server

安装zabbix sever需要用到两个组件zabbix-server-mysql 和zabbix-get,zabbix-server-mysql包集成了zabbix server服务和MySQL数据库。选择安装zabbix-server-mysql这个包,是因为数据库选用的是MySQL。

[root@rhel:/opt]#yum install zabbix-server-mysql zabbix-get
Loaded plugins: aliases, changelog, langpacks, ovl, product-id, search-disabled-repos, subscription-manager, tmprepo, verify, versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package zabbix-get.x86_64 0:4.0.0-1.1alpha4.el7 will be installed
---> Package zabbix-server-mysql.x86_64 0:4.0.0-1.1alpha4.el7 will be installed
--> Processing Dependency: fping for package: zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64
--> Processing Dependency: libiksemel.so.3()(64bit) for package: zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64
--> Processing Dependency: libOpenIPMIposix.so.0()(64bit) for package: zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64
--> Processing Dependency: libOpenIPMI.so.0()(64bit) for package: zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64
--> Running transaction check
---> Package OpenIPMI-libs.x86_64 0:2.0.19-15.el7 will be installed
--> Processing Dependency: OpenIPMI-modalias = 2.0.19-15.el7 for package: OpenIPMI-libs-2.0.19-15.el7.x86_64
---> Package fping.x86_64 0:3.10-1.el7 will be installed
---> Package iksemel.x86_64 0:1.4-2.el7.centos will be installed
--> Running transaction check
---> Package OpenIPMI-modalias.x86_64 0:2.0.19-15.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
 Package                                    Arch                          Version                                    Repository                                   Size
=======================================================================================================================================================================
Installing:
 zabbix-get                                 x86_64                        4.0.0-1.1alpha4.el7                        zabbix                                      252 k
 zabbix-server-mysql                        x86_64                        4.0.0-1.1alpha4.el7                        zabbix                                      2.0 M
Installing for dependencies:
 OpenIPMI-libs                              x86_64                        2.0.19-15.el7                              base                                        502 k
 OpenIPMI-modalias                          x86_64                        2.0.19-15.el7                              base                                         15 k
 fping                                      x86_64                        3.10-1.el7                                 zabbix-non-supported                         40 k
 iksemel                                    x86_64                        1.4-2.el7.centos                           zabbix-non-supported                         49 k

Transaction Summary
=======================================================================================================================================================================
Install  2 Packages (+4 Dependent packages)

Total download size: 2.8 M
Installed size: 7.4 M
Is this ok [y/d/N]: y

warning: /var/cache/yum/x86_64/7Server/zabbix/packages/zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY0 ETA
Public key for zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64.rpm is not installed
zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64.rpm | 2.0 MB 00:00:23
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 9.0 kB/s | 2.5 MB 00:04:43
warning: /var/cache/yum/x86_64/7Server/zabbix-non-supported/packages/fping-3.10-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
Importing GPG key 0x79EA5ED4:
Userid : "Zabbix SIA <packager@zabbix.com>"
Fingerprint: fbab d5fb 2025 5eca b22e e194 d13d 58e4 79ea 5ed4
Package : zabbix-release-3.5-1.el7.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
Is this ok [y/N]: y
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Importing GPG key 0xA14FE591:
Userid : "Zabbix LLC <packager@zabbix.com>"
Fingerprint: a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591
Package : zabbix-release-3.5-1.el7.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
PackageKit-1.0.7-6.el7.x86_64 has missing requires of PackageKit-backend
Installing : OpenIPMI-modalias-2.0.19-15.el7.x86_64 1/6
Installing : OpenIPMI-libs-2.0.19-15.el7.x86_64 2/6
Installing : iksemel-1.4-2.el7.centos.x86_64 3/6
Installing : fping-3.10-1.el7.x86_64 4/6
Installing : zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64 5/6
Installing : zabbix-get-4.0.0-1.1alpha4.el7.x86_64 6/6
Verifying : fping-3.10-1.el7.x86_64 1/6
Verifying : zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64 2/6
Verifying : iksemel-1.4-2.el7.centos.x86_64 3/6
Verifying : OpenIPMI-libs-2.0.19-15.el7.x86_64 4/6
Verifying : OpenIPMI-modalias-2.0.19-15.el7.x86_64 5/6
Verifying : zabbix-get-4.0.0-1.1alpha4.el7.x86_64 6/6

Installed:
zabbix-get.x86_64 0:4.0.0-1.1alpha4.el7 zabbix-server-mysql.x86_64 0:4.0.0-1.1alpha4.el7

Dependency Installed:
OpenIPMI-libs.x86_64 0:2.0.19-15.el7 OpenIPMI-modalias.x86_64 0:2.0.19-15.el7 fping.x86_64 0:3.10-1.el7 iksemel.x86_64 0:1.4-2.el7.centos

Complete!

[root@rhel:/opt]#rpm -qa |grep zabbix
zabbix-release-3.5-1.el7.noarch
zabbix-get-4.0.0-1.1alpha4.el7.x86_64
zabbix-server-mysql-4.0.0-1.1alpha4.el7.x86_64

五、初始化zabbix database

由于是测试环境,MySQL和zabbix安装在同一服务器上,由于已经安装过MySQL,在RHEL7.3安装通过YUM安装MySQL5.7,所以这里只需要初始化zabbix的数据库,其实在安装zabbix server时已经包含初始化zabbix数据库的SQL脚本,在zabbix-server-musql中,包含一个名为create.sql.gz的包。

 

[root@rhel:~]#rpm -ql zabbix-server-mysql
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/systemd/system/zabbix-server.service
/usr/lib/tmpfiles.d/zabbix-server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-4.0.0
/usr/share/doc/zabbix-server-mysql-4.0.0/AUTHORS
/usr/share/doc/zabbix-server-mysql-4.0.0/COPYING
/usr/share/doc/zabbix-server-mysql-4.0.0/ChangeLog
/usr/share/doc/zabbix-server-mysql-4.0.0/NEWS
/usr/share/doc/zabbix-server-mysql-4.0.0/README
/usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix

 

解压此包,得到create.sql脚本,但是该脚本并不包含创建zabbix数据库的语句,需要手动创建zabbix的database,然后使用该脚本对zabbix的database进行初始化。

[root@rhel:~]#gunzip /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz
mysql> grant all on zabbix.* to zabbix@'localhost' identified by '1234.Com';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

使用create.sql脚本初始化zabbix的database:

[root@rhel:/usr/share/doc/zabbix-server-mysql-4.0.0]#mysql -uroot -p -Dzabbix < create.sql
Enter password: 

查看zabbix的database中的表:

mysql> 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
mysql> 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_tag                  |
| events                     |
| expressions                |
| functions                  |
| globalmacro                |
| globalvars                 |
| graph_discovery            |
| graph_theme                |
| graphs                     |
| graphs_items               |
| group_discovery            |
| group_prototype            |
| groups                     |
| history                    |
| history_log                |
| history_str                |
| history_text               |
| history_uint               |
| host_discovery             |
| host_inventory             |
| hostmacro                  |
| hosts                      |
| hosts_groups               |
| hosts_templates            |
| housekeeper                |
| 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         |
| 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              |
| task                       |
| task_acknowledge           |
| 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               |
+----------------------------+
140 rows in set (0.00 sec)
View Code

 

 

posted @ 2018-03-16 16:53  Rakas  阅读(7250)  评论(0编辑  收藏  举报