Zabbix安装
Zabbix——基于 WEB 界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案
Zabbix主要功能:
- CPU负荷 - 内存使用 - 磁盘使用 - 网络状况 - 端口监视 - 日志监视
zabbix分为两部分
zabbix server
通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能
zabbix agent
需要安装在被监视的目标服务器上,
主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集
(1)安装Zabbix server
wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+xenial_all.deb
dpkg -i zabbix-release_5.0-1+xenial_all.deb
apt update
(2)数据库
apt-get install zabbix-server-mysql
登陆mysql
mysql -uroot -p
创建数据库
create database zabbix character set utf8 collate utf8_bin;
注:
字符集utf8_bin
授权
grant all privileges on zabbix.* to zabbix@localhost identified by '123456';
导入初始数据
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p
(3) Zabbix Server配置
修改 Zabbix Server配置文件 /etc/zabbix/zabbix_server.conf
配置数据库部分
DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=123456
启动
sudo systemctl restart zabbix-server
查看状态
baby@ubuntu:/etc/zabbix$ sudo systemctl status zabbix-server ● zabbix-server.service - Zabbix Server Loaded: loaded (/lib/systemd/system/zabbix-server.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-12-14 10:33:38 CST; 7s ago Process: 27804 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS) Main PID: 27809 (zabbix_server) Tasks: 38 Memory: 24.9M CPU: 143ms CGroup: /system.slice/zabbix-server.service ├─27809 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf ├─27811 /usr/sbin/zabbix_server: configuration syncer [synced configuration in 0.035316 sec, idle 60 sec ├─27812 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes ├─27813 /usr/sbin/zabbix_server: timer #1 [updated 0 hosts, suppressed 0 events in 0.012570 sec, idle 21 se ├─27814 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.000507 sec, idle 5 sec ├─27815 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000560 sec, idle 60 sec ├─27816 /usr/sbin/zabbix_server: history syncer #1 [processed 1 values, 1 triggers in 0.002847 sec, idle 1 ├─27817 /usr/sbin/zabbix_server: history syncer #2 [processed 0 values, 0 triggers in 0.000029 sec, idle 1 ├─27818 /usr/sbin/zabbix_server: history syncer #3 [processed 0 values, 0 triggers in 0.000025 sec, idle 1 ├─27819 /usr/sbin/zabbix_server: history syncer #4 [processed 0 values, 0 triggers in 0.000029 sec, idle 1 ├─27820 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.001306 sec, idle 3 sec ├─27824 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000040 sec, idle 5 sec ├─27825 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000026 sec, idle 1 sec ├─27826 /usr/sbin/zabbix_server: task manager [processed 0 task(s) in 0.000368 sec, idle 5 sec lines 1-23
(4)安装Zabbix agent
apt install zabbix-agent
启动
sudo systemctl restart zabbix-agent
(5)Zabbix Web服务
启动apache
systemctl restart apache2
安装web服务
apt-get install zabbix-frontend-php
复制zabbix到apache2
cp -r /usr/share/zabbix /var/www/html/zabbix
经过尝试,这样安装的太老,和当前版本不匹配
sudo dpkg --list
删除
sudo dpkg -P zabbix-frontend-php
下载source包,将ui复制到/var/www/html/下
http://XXX.XXX.XXX.XXX/ui
检查配置项,修改
post_max_size = 30M max_execution_time = 300 max_input_time = 300 date.timezone =Asia/Shanghai
安装完成后跳到登陆页面
登陆账号Admin,zabbix
注:
原本想安装最新的5.2,后来发现zabbix-frontend-php和zabbix-server-mysql 安装的一直是2.4版本
zabbix-server启动一直失败,因此换成了5.0