Zabbix搭建
虚拟机Centos 7最小安装
打开网络连接:
cd /etc/sysconfig/network-scripts
vi ifcfg-ens33
将ONBOOT=no修改为ONBOOT=yes
重启网卡:
Service network restart
查看ip:
Ip addr
安装网络工具:
yum install net-tools
安装wget
yum -y install wget
centos 7 添加阿里云镜像
1. 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3. 运行 yum makecache 生成缓存
yum -y makecache
yum install -y epel-release
安装常用的开发组件
yum -y groups install "Development Tools"
yum groups info "Development Tools"
增加Zabbix4.4镜像源
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
yum -y install vim
关闭SElinux
vim /etc/selinux/config
SELINUX=disable
重启操作系统
Reboot
yum -y install iptables-services
安装Zabbix Server和Frontend
yum install -y zabbix-server-mysql
yum install -y zabbix-web-mysql
安装MySQL
yum install -y mariadb-server
启动数据库
systemctl start mariadb.service
查看数据库启动状态
systemctl status mariadb.service
mysql_secure_installation
是否需要修改root密码
Enter current password for root (enter for none):回车
是否设置root密码
Set root password? [Y/n] n
是否删除匿名用户
Remove anonymous users? [Y/n] y
是否禁止root登陆
Disallow root login remotely? [Y/n] n
是否删除测试数据库
Remove test database and access to it? [Y/n] y
重新加载权限
Reload privilege tables now? [Y/n] y
创建数据库
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
查看数据库
show databases;
创建数据库用户并赋予访问权限
grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix@findsec123';
刷新权限
Flush privileges;
退出数据库
quit
导入数据结构
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix@findsec123 zabbix
登录数据库
mysql -uroot -p
查看数据库
show databases;
登录zabbix库
use zabbix;
查看表
show tables;
quit
配置Zabbix Serve
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword= zabbix@findsec123
启动Zabbix Server
systemctl start zabbix-server.service
systemctl status zabbix-server.service
more /var/log/zabbix/zabbix_server.log
配置Zabbix frontend
vim /etc/php.ini
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
max_input_vars = 10000
always_populate_raw_post_data = -1
date.timezone = Asia/Shanghai
启动httpd
systemctl start httpd.service
systemctl status httpd.service
前端网页访问
http://192.168.159.130/zabbix/setup.php
Admin
zabbix
安装Zabbix Agent
yum install zabbix-agent
确认agent配置
Vim /etc/Zabbix/Zabbix_agentd.conf
systemctl start zabbix-agent.service