1、Zabbix安装
下载zabbix server源码包
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.1/zabbix-4.4.1.tar.gz
安装依赖
yum install wget telnet net-tools python-paramiko gcc gcc-c++ dejavu-sans-fonts python-setuptools python-devel sendmail mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC libevent-devel mysql-devel libxml2-devel libssh2-devel OpenIPMI-devel java-1.8.0-openjdk-devel openldap-devel curl-devel unixODBC-devel
解压并编译安装
tar -zxvf zabbix-4.4.1.tar.gz
cd zabbix-4.4.1/
建立编译安装目录
mkdir -p /data/zabbix
./configure --prefix=/data/zabbix --enable-server --enable-agent --enable-java --with-mysql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-ldap --with-libcurl --with-iconv
make
make install
查看安装版本
/data/zabbix/sbin/zabbix_server -V
数据库安装
yum install mariadb-server
systemctl start mariadb.service
systemctl status mariadb.service
mysql_secure_installation
创建数据库
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'abc123456.';
flush privileges;
导入数据结构
mysql -uzabbix -pabc123456. zabbix < /root/zabbix-4.4.1/database/mysql/schema.sql
mysql -uzabbix -pabc123456. zabbix < /root/zabbix-4.4.1/database/mysql/images.sql
mysql -uzabbix -pabc123456. zabbix < /root/zabbix-4.4.1/database/mysql/data.sql
修改zabbix server配置
vim /data/zabbix/etc/zabbix_server.conf
增加用户
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix System" zabbix
启动服务
/data/zabbix/sbin/zabbix_server -c /data/zabbix/etc/zabbix_server.conf
/data/zabbix/sbin/zabbix_agentd -c /data/zabbix/etc/zabbix_agentd.conf
tailf /tmp/zabbix_server.log
tailf /tmp/zabbix_agentd.log
ps aux | grep zabbix
增加Zabbix镜像源
rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
安装Zabbix Frontend
yum install zabbix-web-mysql
配置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
cd zabbix-4.4.1
cp misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix-server
cp misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix-agent
chmod +x /etc/rc.d/init.d/zabbix-server
chmod +x /etc/rc.d/init.d/zabbix-agent
chkconfig --add zabbix-server
chkconfig --add zabbix-agent
chkconfig zabbix-server on
chkconfig zabbix-agent on
vi /etc/rc.d/init.d/zabbix-agent 和zabbix-server
编辑客户端配置文件
BASEDIR=/data/zabbix/
zabbix安装目录
PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid #pid文件路径
(可以使用默认)
:wq! #保存退出
Admin
zabbix
2、grafana安装
wget https://dl.grafana.com/oss/release/grafana-6.4.4-1.x86_64.rpm
yum localinstall grafana-6.4.4-1.x86_64.rpm
systemctl daemon-reload
systemctl start grafana-server
systemctl status grafana-server
配置支持zabbix
安装 zabbix 插件(grafana-zabbix)
grafana-cli plugins install alexanderzobnin-zabbix-app
systemctl restart grafana-server
启用插件
进入 Plugins 界面,选择 “Zabbix”
开始面板(左上角图标) -> Plugins -> Apps -> Zabbix
添加 zabbix 数据源
进入 “添加数据源” 界面
开始面板(左上角图标) -> Data Sources -> Add data source
配置 Zabbix 数据源
配置完后,保存退出,配置的内容如下:
重要参数有:
Type: Zabbix
Url: http://zabbix服务器/zabbix/api_jsonrpc.php
Access: direct
(Zabbix API details)
Username: Admin(默认)
Password: zabbix(默认)
验证
之后,我们从 开始面板 -> Zabbix 中,便可看到 Zabbix 相关的监控数据。
监控客户端
安装Zabbix Agent
yum install zabbix-agent
systemctl start zabbix-agent.service