以下步骤,参考了
监控需求
在搭建步骤之前,还是整理一下本次的监控需求。
- 部署搭建简单,足够轻量级,
- 配置简单,适合菜鸟
- 可以监控多台linux主机的cpu和内存状态
- 最好可以监控日志
- 有
炫酷简洁的图形界面
以上,身为主流监控工具的Zabbix完全可以满足。而且,有良好的扩展性,可以满足日益增长的需求。
搭建步骤
确定安装环境
-
- 安装ubuntu16.04系统见
-
更新系统源
执行 sudo vi /etc/apt/sources.list,修改为: -
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricteddeb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial universedeb http://mirrors.aliyun.com/ubuntu/ xenial-updates universedeb http://mirrors.aliyun.com/ubuntu/ xenial multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-propertiesdeb http://archive.canonical.com/ubuntu xenial partnerdeb-src http://archive.canonical.com/ubuntu xenial partnerdeb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial-security universedeb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
安装Zabbix
-
- 首先更新下apt。执行 sudo apt-get update
- 然后安装Zabbix所有依赖环境(可以不带版本号,但源里目前使用7.0,所以就指定一下7.0 ; mysql环境设置密码为root就可以)sudo apt-get install apache2 mysql-server php7.0 php7.0-gd libapache2-mod-php7.0 php7.0-mysql php7.0-bcmath php7.0-mbstring php7.0-xml php7.0-ldap
- 下载Zabbix安装wget dpkg -i zabbix-release_3.4-1+xenial_all.debsudo apt-get update
- 安装Zabbix的web环境(客户机只需要安装zabbix-agent)sudo apt-get install zabbix-server-mysql zabbix-frontend-php zabbix-agent
修改数据库连接
sudo vim /etc/zabbix/zabbix_server.conf
修改相关DBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=zabbix#非必需,但推荐StartDiscoverers=5 -
-
创建mysql账号
mysql -u root -p
mysql> create database zabbix character set utf8 collate utf8_bin;mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';mysql> flush privileges;
mysql> exit;
导入mysql数据
(password是刚才设置的zabbix)
cd /usr/share/zabbix-server-mysql/
sudo gunzip *.gzmysql -u zabbix -p zabbix < create.sql
配置php参数
sudo vi /etc/apache2/conf-enabled/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128Mphp_value post_max_size 16Mphp_value upload_max_filesize 2Mphp_value max_input_time 300php_value max_input_vars 10000php_value always_populate_raw_post_data -1php_value date.timezone Asia/Shanghai-
启动zabbix服务
(输入系统密码)
service zabbix-server start
sudo service apache2 restart
登录网页
http://HOST_ip/zabbix/
(填写mysql的密码zabbix
填写server_name为zabbix server)
狂点下一步。
默认登录账号密码 Admin/zabbix
修改中文界面
sudo vi /usr/share/zabbix/include/locales.inc.php
第55行,'zh_CN' => ['name' => _('Chinese (zh_CN)'), 'display' => true],
把display改为true,刷新页面即可。
如果还是不行,参考
配置客户端
把拷贝到home目录
然后执行(由于koala中缺少一个库,需要联网安装)
默认配置的服务器地址是192.168.1.200
- zabbix-agent.sh
#!/bin/bash
sudo
apt-get
install
libcurl3
sudo
dpkg -i ~
/zabbix-agent_3
.4.10-1+xenial_amd64.deb
sudo
sed
-i
'97s/127.0.0.1/192.168.1.200/g'
/etc/zabbix/zabbix_agentd
.conf
sudo
sed
-i
'138s/127.0.0.1/192.168.1.200/g'
/etc/zabbix/zabbix_agentd
.conf
sudo
sed
-i
'105s/# //g'
/etc/zabbix/zabbix_agentd
.conf
sudo
sed
-n
'/^Server=/p'
/etc/zabbix/zabbix_agentd
.conf
sudo
sed
-n
'/^ServerActive=/p'
/etc/zabbix/zabbix_agentd
.conf
sudo
sed
-n
'/^ListenPort=/p'
/etc/zabbix/zabbix_agentd
.conf
sudo
/etc/init
.d
/zabbix-agent
start
-