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