一开始我想在alios2.1(centos7)上安装zabbix-server6.0,但是到导入server.sql.gz文件时发现没有这个文件,但是zabbix-server-mysql却能安上,后来发现其实安装的是alios自带的zabbix60-server-mysql这个是没有server.sql.gz文件的,于是只能重装了一个alios3.2(centos8)来部署zabbix6.0
mysql安装
-
安装mysql8
yum -y install https://repo.mysql.com//mysql80-community-release-el7-5.noarch.rpm yum -y install mysql-community-server mysql-community-devel
这里可能会出现以下报错Error: GPG check FAILED
原因是没有GPG认证,即是从一些非官方地址下载的,需要安装–nogpgcheckyum install -y openresty --nogpgcheck
然后在刚才的下载命令中加上–nogpgcheck
yum -y install mysql-community-server mysql-community-devel --nogpgcheck
-
初始化mysql
修改vim /etc/my.cnf ,把datadir和socket改成你想要存放的地方
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock default-authentication-plugin=mysql_native_password
启动mysqld
systemctl restart mysqld
-
创建zabbix数据库
先找一下mysql的初始密码
grep 'temporary password' /var/log/mysqld.log
按照初始密码登陆
mysql -u root -p #初始密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'root_21ROOT'; //第一步需要先创建一个复杂一点的密码root_21ROOT SHOW VARIABLES LIKE 'validate_password%'; //查看、修改密码策略 set global validate_password.policy=0; set global validate_password.mixed_case_count=0; set global validate_password.number_count=0; set global validate_password.special_char_count=0; set global validate_password.length=0; ALTER USER 'root'@'localhost' IDENTIFIED BY 'zabbix'; create user 'zabbix'@'%' identified by 'zabbix'; grant all privileges on zabbix.* to zabbix@'%';
为了防止后面到数据时报错,也可以加一个super权限
GRANT SUPER ON *.* TO zabbix@'%';
zabbix-server安装
-
下载rpm资源包
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm dnf clean all
可以到这个网站上去看一下哪些版本支持哪些linux,不然下载下来发现少东西
-
配置zabbix.repo文件仓库
一般位置是/etc/yum.repos.d/zabbix.repo,( baseurl可以不改)
[zabbix] name=Zabbix Official Repository - $basearch #baseurl=https://repo.zabbix.com/zabbix/6.0/rhel/8/$basearch/ baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/x86_64/ # zabbix清华源 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=https://repo.zabbix.com/non-supported/rhel/8/$basearch/ baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/8/x86_64/ # zabbix-non-supported清华源 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgcheck=1 [zabbix-unstable] name=Zabbix Official Repository (unstable) - $basearch baseurl=https://repo.zabbix.com/zabbix/5.5/rhel/8/$basearch/ enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
-
下载zabbix-server
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent
-
导入数据
这里注意,有些版本的server.sql.gz文件位置可能会不一样,可以用find搜一下
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
-
配置server.conf文件
/etc/zabbix/zabbix_server.conf下修改DBPassword为数据库的密码就好了
-
启动服务
systemctl restart zabbix-server zabbix-agent httpd php-fpm systemctl enable zabbix-server zabbix-agent httpd php-fpm
这里可能会有各种各样的问题,到时候到/var/log/zabbix/下面找日志慢慢看就好了
-
登陆zabbix-web
http://ip/zabbix 用户名:Admin 密码:zabbix