前言:Zabbix版本区别

zabbix 版本 zabbix1.8 zabbix2.0 zabbix 2.2 LTS 长期支持版本 zabbix 2.4 zabbix 3.0 LTS zabbix 3.2 标准版 zabbix3.4 标准版 zabbix 4.0 LTS 长期版 4.2 4.4 5.0 长期支持版 标准版是7个月,LTS是长期版本,不是选最新版本哦 Zabbix LTS版本每一年半发布一次,且为Zabbix客户提供五年的支持服务

===============================================================

一:初始化环境,关闭防火墙selinux,zabbix-server内存尽量更大点,4G为好 1.获取zabbix的下载源

rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

2.更换zabbix.repo源为阿里的

sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
yum clean all

3.安装zabbix server和agent

yum install zabbix-server-mysql zabbix-agent -y

4.安装 Software Collections,便于后续安装⾼版本的 php,默认 yum 安装的 php 版本为 5.4 过低。 SCL(Software Collections)可以让你在同⼀个操作系统上安装和使⽤多个 版本的软件,⽽不会影响整个系统的安装包。 软件包会安装在/opt/rh⽬录下 为了避免系统⼴泛冲突,/opt/rh包安装在⽬录中,例如,这允许你在CentOS 7机器上安装Python 3.5,⽽不会删除或⼲扰Python 2.7. /etc/opt/rh/软件包的所有配置⽂件都存储在⽬录中相应的⽬录中,SCL包 提供了定义使⽤所包含应⽤程序所需的环境变量的shell脚本,例如,PATH, LD_LIBRARY_PATH和MANPATH ,这些脚本存储在⽂件系统中,作为 /opt/rh/package-name/enable 。

yum install centos-release-scl -y

5.修改zabbix前端源,修改里面的参数

vim /etc/yum.repos.d/zabbix.repo

AA8V3K~I4`O6JAD2Z72_6.png 6.安装zabbix前端环境,前提是前面安装有scl环境下

yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y

7.安装zabbix所需的数据库,直接⽤centos7⾃带的mariadb

yum install mariadb-server -y

8.启动数据库,且配置开机启动,netstat看看端口起了没

systemctl enable --now mariadb![J`VHRIMZ2E3V~2BYABJ.png]

J`VHRIMZ2E3V~2BYABJ.png

netstat -tunlp

D`3RR741KASOW_RDZLNLT2.png 9.初始化mariadb,设置root密码,a12345678

mysql_secure_installation
[root@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Sorry, passwords do not match.

New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

mysql -uroot -p

O8E_AN7Y~1ONVODR58.png 10.使⽤root⽤户登录mariadb,建⽴zabbix数据库,创建zabbix用户 ,这⾥的编码设置⾮常重要,否则zabbix⽆法安装

create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'a12345678';
grant all privileges on zabbix.* to zabbix@localhost;
flush privileges;
quit;

11.使用zabbix-mysql命令,导入数据库信息 #mysql -u用户名 -p 数据库名

zcat  /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

进去数据库检查一下OB~F4_MO4FG`LDC~9.png 12.修改 zabbix server 配置⽂件/etc/zabbix/zabbix_server.conf ⾥ 的数据库蜜码

vim /etc/zabbix/zabbix_server.conf 

L0O1M8XK07I9LTI3A556F.png 检查下

grep '^DBPassword' /etc/zabbix/zabbix_server.conf

13.修改 zabbix 的 php 配置⽂件 /etc/opt/rh/rh-php72/phpfpm. d/zabbix.conf ⾥的时区

vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf 

~KEGZTFX0YSAPKCEP8N.png 检查下

grep 'timezone' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf

14.启动zabbix相关服务

systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
  1. 通过浏览器访问来配置zabbix服务器,访问地址是http://ip/zabbix 一路检查ok后,默认到这里,填写好密码即可;默认账户是Admin,密码是zabbix 4DN4KF1BHN`SUERO6COBN.png