这是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配置文件。可以在线安装也可以下载到系统上本地安装这里直接使用在线安装的方式,安装之前要看好系统的版本是否正确,下载对应版本的zabbix.
检查系统版本号:
[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)
#创建zabbix数据库,并配置相应权限
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
#对zabbix数据库创建用户密码以及用户权限
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 ,主要修改时区,其他可以不修改.
[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 不用做修改,如果修改要修改正确的时区,否则会报错的.
</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
出现这个界面说明配置正常了,可以进行下一步了.
这个界面就是检查之前的配置的,如果时区没配置会有报错的.检查配置没问题就可以下一步了.
这个界面是zabbix的数据库连接以及用户名登陆的,因为本次实验的mariadb和zabbix是在同一个机器的所以是localhost,如果不是则要填写mariadb所在主机的IP,用户名和密码就是之前创建zabbix数据库的用户和密码,填写好了就可以下一步了.
这个界面是配置zabbix服务的端口,别名,主机地址等等,别名可以自己取,自己明白就行.然后点下一步.
这个界面就是刚才所有配置的确认,没问题就下一步.
所有的都没报错就出现这个界面了,直接点下一步就ok了
这个就是最后的登陆界面了,默认的用户密码是:Admin/zabbix,
注意用户名严格区分大小写,登陆进去可以看到zabbix的界面了.
这样就完成了zabbix服务器的搭建了.