這是zabbixe中文官方文檔地址: https://www.zabbix.com/documentation/3.4/zh/manual
可以依據這個文檔來進行安裝.
前期準備:
為避免實驗成功確保關閉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
關閉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.安裝源碼庫配置部署包
安裝源碼庫配置部署包。這個部署包包含了yum配置文件菠秒。可以在線安裝也可以下載到系統(tǒng)上本地安裝這里直接使用在線安裝的方式,安裝之前要看好系統(tǒng)的版本是否正確,下載對應版本的zabbix.
檢查系統(tǒng)版本號:
[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及配置
上一個步驟做完了就可使用yum來安裝zabbix但是在此之前先安裝并配置一下mariadb服務.為啥不用mysql這里不做表述了,個人喜好吧.
安裝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
啟動mariadb服務并配置:
[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 #這數據庫之前已經初始化并設置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數據庫,并配置相應權限
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
#對zabbix數據庫創(chuàng)建用戶密碼以及用戶權限
MariaDB [(none)]>
3.安裝zabbix并配置
安裝zabbix服務:
[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數據導入到mariadb中:
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.9/create.sql.gz | mysql -uzabbix -pzabbix zabbix
編輯數據庫配置:
在/etc/zabbix/zabbix_server.conf中配置,具體配置如下:
# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
#保存退出,其他暫時不用修改
編輯Zabbix前端的PHP配置:
Zabbix前端的Apache配置文件位于 /etc/httpd/conf.d/zabbix.conf ,主要修改時區(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 不用做修改,如果修改要修改正確的時區(qū),否則會報錯的.
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
"/etc/httpd/conf.d/zabbix.conf" 37L, 832C
:wq
啟動zabbix和httpd服務:
[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
訪問web的zabbix服務并安裝:
通過主機http://IP/zabbix的方式訪問web的zabbix
出現這個界面說明配置正常了,可以進行下一步了.
這個界面就是檢查之前的配置的,如果時區(qū)沒配置會有報錯的.檢查配置沒問題就可以下一步了.
這個界面是zabbix的數據庫連接以及用戶名登陸的,因為本次實驗的mariadb和zabbix是在同一個機器的所以是localhost,如果不是則要填寫mariadb所在主機的IP,用戶名和密碼就是之前創(chuàng)建zabbix數據庫的用戶和密碼,填寫好了就可以下一步了.
這個界面是配置zabbix服務的端口,別名,主機地址等等,別名可以自己取,自己明白就行.然后點下一步.
這個界面就是剛才所有配置的確認,沒問題就下一步.
所有的都沒報錯就出現這個界面了,直接點下一步就ok了
這個就是最后的登陸界面了,默認的用戶密碼是:Admin/zabbix,
注意用戶名嚴格區(qū)分大小寫,登陸進去可以看到zabbix的界面了.
這樣就完成了zabbix服務器的搭建了.