添加zabbix源
# ubuntu 16.04
wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+xenial_all.deb
dpkg -i zabbix-release_3.4-1+xenial_all.deb
apt update
# ubuntu 14.04
wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+trusty_all.deb
dpkg -i zabbix-release_3.4-1+trusty_all.deb
apt update
# ubuntu 18.04
wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+bionic_all.deb
dpkg -i zabbix-release_3.4-1+bionic_all.deb
apt update
安装zabbix服务端
先安装mysql, 以防zabbix源里面安装mariadb出错
apt install mysql-server-5.7
修改mysql默认编码,以便zabbix页面能命名中文
/etc/mysql/mysql.conf.d/mysqld.cnf
# 在[mysqld]节下面添加一行
character-set-server=utf8
/etc/mysql/conf.d/mysql.cnf
# 在[mysql]节下面添加一行
default-character-set=utf8
重启mysql
service mysql restart
安装zabbix-server-mysql
apt install zabbix-server-mysql
# 允许开机启动zabbix-server
update-rc.d zabbix-server enable
初始化数据库
# 创建数据库zabbix
mysqladmin -uroot -p create zabbix
# 一下默认使用数据库用户root,可自行创建用户授权
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uroot -p zabbix
修改配置文件/etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=root(或你自己创建的用户)
DBPassword=密码
重启服务
service zabbix-server restart
# 查看服务是否正常运行
netstat -atnp
# tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 1567/zabbix_server
安装zabbix Web前端
apt install zabbix-frontend-php
修改/etc/apache2/conf-enabled/zabbix.conf
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/Shanghai
service apache2 restart
打开浏览器输入http://yourip/zabbix
配置
数据库账号密码按实际配置填写
默认账号Admin
初始密码 zabbix
本地安装zabbix-agent
测试
apt install zabbix-agent
service zabbix-agent start
netstat -atnp | grep zabbix
# tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2535/zabbix_agentd
#
启用默认配置的host做测试
参考系统默认配置的配置
新建仪表盘,添加图标观察
附 Mysql彻底卸载重装
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/log/mysql
sudo rm -rf /var/log/mysql.*
sudo rm -rf /var/lib/mysql
sudo apt-get install mysql-server --fix-missing --fix-broken