這是zabbixe中文官方文檔地址: https://www.zabbix.com/documentation/3.4/zh/manual
可以依據(jù)這個(gè)文檔來(lái)進(jìn)行安裝.
前期準(zhǔn)備:
為避免實(shí)驗(yàn)成功確保關(guān)閉firewall和selinux
配置selinux
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
-----------分割線-----------
[root@localhost ~]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #這里改成disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
~
~
~
:wq
關(guān)閉firewall
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
1.安裝源碼庫(kù)配置部署包
安裝源碼庫(kù)配置部署包。這個(gè)部署包包含了yum配置文件。可以在線安裝也可以下載到系統(tǒng)上本地安裝這里直接使用在線安裝的方式,安裝之前要看好系統(tǒng)的版本是否正確,下載對(duì)應(yīng)版本的zabbix.
檢查系統(tǒng)版本號(hào):
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
安裝部署包:
[root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
Retrieving http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
Preparing... ################################# [100%]
package zabbix-release-3.4-1.el7.centos.noarch is already installed
2.安裝mariadb及配置
上一個(gè)步驟做完了就可使用yum來(lái)安裝zabbix但是在此之前先安裝并配置一下mariadb服務(wù).為啥不用mysql這里不做表述了,個(gè)人喜好吧.
安裝mariadb:
[root@localhost ~]# yum -y install mariadb mariadb-server.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.163.com
Package 1:mariadb-5.5.56-2.el7.x86_64 already installed and latest version
Package 1:mariadb-server-5.5.56-2.el7.x86_64 already installed and latest version
Nothing to do
啟動(dòng)mariadb服務(wù)并配置:
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
-----------分割線-----------
[root@localhost ~]# mysql -uroot -p123456 #這數(shù)據(jù)庫(kù)之前已經(jīng)初始化并設(shè)置root密碼了
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, 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)
#創(chuàng)建zabbix數(shù)據(jù)庫(kù),并配置相應(yīng)權(quán)限
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
#對(duì)zabbix數(shù)據(jù)庫(kù)創(chuàng)建用戶密碼以及用戶權(quán)限
MariaDB [(none)]>
3.安裝zabbix并配置
安裝zabbix服務(wù):
[root@localhost ~]# yum -y install zabbix-server-mysql.x86_64 zabbix-web-mysql.noarch
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package zabbix-server-mysql.x86_64 0:3.4.9-1.el7 will be installed
--> Processing Dependency: fping for package: zabbix-server-mysql-3.4.9-1.el7.x86_64
--> Processing Dependency: libiksemel.so.3()(64bit) for package: zabbix-server-mysql-3.4.9-1.el7.x86_64
--> Processing Dependency: libOpenIPMIposix.so.0()(64bit) for package: zabbix-server-mysql-3.4.9-1.el7.x86_64
--> Processing Dependency: libOpenIPMI.so.0()(64bit) for package: zabbix-server-mysql-3.4.9-1.el7.x86_64
--> Processing Dependency: libodbc.so.2()(64bit) for package: zabbix-server-mysql-3.4.9-1.el7.x86_64
---> Package zabbix-web-mysql.noarch 0:3.4.9-1.el7 will be installed
--> Processing Dependency: zabbix-web = 3.4.9-1.el7 for package: zabbix-web-mysql-3.4.9-1.el7.noarch
--> Running transaction check
...省略...
Installed:
zabbix-server-mysql.x86_64 0:3.4.9-1.el7 zabbix-web-mysql.noarch 0:3.4.9-1.el7
Dependency Installed:
OpenIPMI-libs.x86_64 0:2.0.23-2.el7 OpenIPMI-modalias.x86_64 0:2.0.23-2.el7
fping.x86_64 0:3.10-4.el7 iksemel.x86_64 0:1.4-6.el7
php.x86_64 0:5.4.16-45.el7 php-bcmath.x86_64 0:5.4.16-45.el7
php-cli.x86_64 0:5.4.16-45.el7 php-gd.x86_64 0:5.4.16-45.el7
php-ldap.x86_64 0:5.4.16-45.el7 php-xml.x86_64 0:5.4.16-45.el7
t1lib.x86_64 0:5.1.2-14.el7 unixODBC.x86_64 0:2.3.1-11.el7
zabbix-web.noarch 0:3.4.9-1.el7
Dependency Updated:
php-common.x86_64 0:5.4.16-45.el7 php-fpm.x86_64 0:5.4.16-45.el7
php-mbstring.x86_64 0:5.4.16-45.el7 php-mysql.x86_64 0:5.4.16-45.el7
php-pdo.x86_64 0:5.4.16-45.el7
Complete!
將zabbix數(shù)據(jù)導(dǎo)入到mariadb中:
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.9/create.sql.gz | mysql -uzabbix -pzabbix zabbix
編輯數(shù)據(jù)庫(kù)配置:
在/etc/zabbix/zabbix_server.conf中配置,具體配置如下:
# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
#保存退出,其他暫時(shí)不用修改
編輯Zabbix前端的PHP配置:
Zabbix前端的Apache配置文件位于 /etc/httpd/conf.d/zabbix.conf ,主要修改時(shí)區(qū),其他可以不修改.
[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai 不用做修改,如果修改要修改正確的時(shí)區(qū),否則會(huì)報(bào)錯(cuò)的.
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
"/etc/httpd/conf.d/zabbix.conf" 37L, 832C
:wq
啟動(dòng)zabbix和httpd服務(wù):
[root@localhost ~]# systemctl start zabbix-server.service
[root@localhost ~]# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@localhost ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl start httpd.service
訪問(wèn)web的zabbix服務(wù)并安裝:
通過(guò)主機(jī)http://IP/zabbix的方式訪問(wèn)web的zabbix

出現(xiàn)這個(gè)界面說(shuō)明配置正常了,可以進(jìn)行下一步了.

這個(gè)界面就是檢查之前的配置的,如果時(shí)區(qū)沒(méi)配置會(huì)有報(bào)錯(cuò)的.檢查配置沒(méi)問(wèn)題就可以下一步了.

這個(gè)界面是zabbix的數(shù)據(jù)庫(kù)連接以及用戶名登陸的,因?yàn)楸敬螌?shí)驗(yàn)的mariadb和zabbix是在同一個(gè)機(jī)器的所以是localhost,如果不是則要填寫mariadb所在主機(jī)的IP,用戶名和密碼就是之前創(chuàng)建zabbix數(shù)據(jù)庫(kù)的用戶和密碼,填寫好了就可以下一步了.

這個(gè)界面是配置zabbix服務(wù)的端口,別名,主機(jī)地址等等,別名可以自己取,自己明白就行.然后點(diǎn)下一步.

這個(gè)界面就是剛才所有配置的確認(rèn),沒(méi)問(wèn)題就下一步.

所有的都沒(méi)報(bào)錯(cuò)就出現(xiàn)這個(gè)界面了,直接點(diǎn)下一步就ok了

這個(gè)就是最后的登陸界面了,默認(rèn)的用戶密碼是:Admin/zabbix,
注意用戶名嚴(yán)格區(qū)分大小寫,登陸進(jìn)去可以看到zabbix的界面了.

這樣就完成了zabbix服務(wù)器的搭建了.