Zabbix安装与部署
1 Zabbix的安装
1.1 关闭SeLinux
[root@localhost ~]# setenforce 0
setenforce: SELinux is disabled
# 查看配置文件
[root@localhost ~]# cat /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
1.2 关闭防火墙
1.2.1 临时关闭
systemctl stop firewalld.service
1.2.2 永久关闭
systemctl disable firewalld.service
1.3 安装MySQL
因为是测试环境下,所以我们可以使用mariadb,主要是为了方便快捷
yum install -y mariadb mariadb-server
开机自启动
Systemctl enable mariadb
运行服务
Systemctl start mariadb.service
Systemctl status mariadb.service
1.4 安装zabbix
安装步骤:
下载包
安装包
创建数据库
创建账户并且授权设置密码
导入数据表结构
配置
zabbix server
配置文件运行
zabbix-server
服务
1.4.1 下载包
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
注意:在下载过程中会存在 zabbix-server-mysql
和 zabbix-web
下载不下来的情况,请排查是由于网络,如果出现timeout...
等的情况
1.4.2 安装zabbix包
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
1.4.3 安装zabbix的包
yum install -y zabbix-server-mysql zabbix-get zabbix-web zabbix-web-mysql zabbix-agent zabbix-sender
1.4.4 创建一个zabbix库并设置为utf8的字符编码格式
create database zabbix character set utf8 collate utf8_bin;
创建账户并且授权设置密码
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
如果报错:报错信息为
如果报错:Your password does not satisfy the current policy requirements
set global validate_password_policy=0;
set global validate_password_length=1;
quit
1.4.5 导入数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
注意:
注:如果还让输入密码,就再输入一遍,默认密码:zabbix
导入数据时,可能会出现终端卡顿现象,不要着急,多等待一会就好
1.4.6 配置zabbix server配置文件
文件位置:/etc/zabbix/zabbix_server.conf
修改数据:
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
1.4.7 启动zabbix-server服务
systemctl start zabbix-server.service
# 开机自启动zabbix-server服务
systemctl enable zabbix-server.service
1.4.8 配置PHP
# 配置文件位置
vi /etc/httpd/conf.d
# 修改配置文件
# php_value data.timezone Europe/Riga
php_value data.timezone Asia/Shanghai
# 重启httpd服务
Systemctl restart httpd
1.4.9 进入zabbix前端页面
- 打开浏览器 :
服务器主机ip/zabbix
本文参考链接
- https://www.cnblogs.com/Sungeek/p/9069999.html
- https://blog.51cto.com/allmrys/2173915
- https://www.cnblogs.com/xiangsikai/p/9024285.html