Zabbix+grafana
操作系统为ubuntu22.04
配置Ubuntu ip
root@ubuntu:~# vim /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
dhcp4: false
addresses: [192.168.1.22/24]
routes:
- to: default
via: 192.168.1.2
nameservers:
addresses: [8.8.8.8,114.114.114.114]
version: 2
配置Ubuntu 源
root@ubuntu:~# vim /etc/apt/sources.list
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
apt update #更新源
快速配置Lamp
apt-get install httpd #安装httpd
apt-get install php #安装php
apt-get install mariadb-server # 安装mariadb
systemctl start httpd.server(apache2) #启动httpd或(apache2)服务
systemctl restart mariadb.server #刷新mariadb服务
mysql_secure_installation #初始化数据库
安装zabbix (6.4)
下载zabbix源
wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb
apt update
安装Zabbix server,Web前端,agent
apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent
在数据库主机上运行以下代码。
mysql -uroot -p #输入设置的密码进入MySQL
password:
create database zabbix character set utf8mb4 collate utf8mb4_bin; #创建zabbix数据库
create user zabbix@localhost identified by 'zabbix'; #创建zabbix用户和密码
grant all privileges on zabbix.* to zabbix@localhost; #授权
set global log_bin_trust_function_creators = 1;
flush privileges; #刷新
导入初始架构和数据,系统将提示您输入新创建的密码。
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix
为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf
DBPassword=zabbix
为Zabbix agent配置数据库
编辑配置文件 /etc/zabbix/zabbix_agent.conf
启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
systemctl restart zabbix-server zabbix-agent apache2
systemctl enable zabbix-server zabbix-agent apache2
输入192.168.1.22/zabbix进入web界面
修改主机IP配置
安装grafana
apt-get install -y adduser libfontconfig1 musl
wget https://dl.grafana.com/enterprise/release/grafana-enterprise_10.1.4_amd64.deb
dpkg -i grafana-enterprise_10.1.4_amd64.deb
查看zaabix插件是否存在于grafana-cli工具内
root@ubuntu:~# grafana-cli plugins list-remote | grep zabbix
id: alexanderzobnin-zabbix-app version: 4.4.1
安装图形的饼状插件
root@ubuntu:~# grafana-cli plugins install grafana-piechart-panel
✔ Downloaded and extracted grafana-piechart-panel v1.6.4 zip successfully to /var/lib/grafana/plugins/grafana-piechart-panel
Please restart Grafana after installing or removing plugins. Refer to Grafana documentation for instructions if necessary.
将工具内的zabbix插件下载到本地
root@ubuntu:~# grafana-cli plugins install alexanderzobnin-zabbix-app
✔ Downloaded and extracted alexanderzobnin-zabbix-app v4.4.1 zip successfully to /var/lib/grafana/plugins/alexanderzobnin-zabbix-app
Please restart Grafana after installing or removing plugins. Refer to Grafana documentation for instructions if necessary.
安装其他的图形插件
root@ubuntu:~# grafana-cli plugins install grafana-clock-panel
✔ Downloaded and extracted grafana-clock-panel v2.1.3 zip successfully to /var/lib/grafana/plugins/grafana-clock-panel
Please restart Grafana after installing or removing plugins. Refer to Grafana documentation for instructions if necessary.
字符型展示
root@ubuntu:~# grafana-cli plugins install natel-discrete-panel
✔ Downloaded and extracted natel-discrete-panel v0.1.1 zip successfully to /var/lib/grafana/plugins/natel-discrete-panel
Please restart Grafana after installing or removing plugins. Refer to Grafana documentation for instructions if necessary.
设置开机自启并启动grafane
root@ubuntu:~# systemctl daemon-reload
root@ubuntu:~# systemctl start grafana-server.service
root@ubuntu:~# systemctl status grafana-server.service
Grafana服务配置文件
在其定义了许多配置选项,通常位于Linux系统中的/etc/grafana/grafana.ini。
在这个配置文件中,可以更改默认管理密码、http端口、grafana数据库(sqlite 3、MySQL、Postgres)、身份验证选项(Google、GitHub、LDAP、auth代理)以及许多其他选项。启动您的Grafana服务器。与您的管理用户登录(默认管理/管理)。打开侧菜单(单击顶部菜单中的Grafana图标),头部到数据源并添加数据源。
登录Grafana服务首页
在浏览器上输入http://192.168.1.22:3000(登陆web的端口可以通过修改配置文件来修改,这里不做操作讲解),账号:密码——admin:admin
设置Grafana——融合Zabbix
添加ZABBIX的数据源到GrafanaGrafana默认没有zabbix作为数据源,所以我们需要手动给zabbix安装一个插件,然后再添加进Grafana即可,非常简单,下面开始配置。
Grafana支持多种不同的时序数据库数据源,Grafana对每种数据源提供不同的查询方法,而且能很好的支持每种数据源的特性。
目前官方支持了如下几种数据源:Data Source — 数据源
Graphite
InfluxDB
OpenTSDB
Prometheus
Elasticsearch
CloudWatch
点击左侧菜单栏->齿轮->plugins(插件)