大家好,我是早九晚十二,目前是做运维相关的工作。写博客是为了积累,希望大家一起进步!
我的主页:早九晚十二
相关文章
使用docker搭建mysql8.0+zabbix6.0
centos7.源码安装zabbix4.4
zabbix监控redis连接数
一般来说,华为云的服务器已经自带了源,这个源基本都是全的,我们可以直接用。当然,如果例外情况,可以手动配置zabbix的镜像源。
添加zabbix镜像存储 zabbix官方网站:https://www.zabbix.com
zabbix官方镜像网站:https://repo.zabbix.com
如果都懒得配置,那可以直接下载我打包好的文件 提取码:hl48
下载完成后使用yum全部安装即可。
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb mariadb-server
如果使用我分享的安装包,那么只需要安装mariadb和mariadb-server即可
systemctl start mariadb
systemctl status mariadb
[root@0033 nginx]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
注意:创建的数据库格式必须为utf8格式。目前设置的密码比较简单,仅为了实验,生产环境不建议。
cd /usr/share/doc/zabbix-server-mysql-5.0.22
zcat create.sql.gz |mysql -uzabbix -pzabbix zabbix
共166张表,数量准确即可。
[root@0033 home]# mysql -uzabbix -pzabbix zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host
..........
| valuemaps |
| widget |
| widget_field |
+----------------------------+
166 rows in set (0.00 sec)
cd /etc/zabbix/
mv zabbix_server.conf zabbix_server.conf_bak
vim /etc/zabbix/zabbix_server.conf
#添加以下配置
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai #[25行,注意前面分号要删掉,不然是注释状态]
systemctl start rh-php72-php-fpm
yum -y install nginx
vim /etc/nginx/conf.d/zabbix.conf
#添加以下内容
server {
listen 8000;
server_name localhost;
root /usr/share/zabbix;
index index.php;
location = /favicon.ico {
log_not_found off;
}
location / {
try_files $uri $uri/ =404;
}
location /assets {
access_log off;
expires 10d;
}
location ~ /\.ht {
deny all;
}
location ~ /(api\/|conf[^\.]|include|locale|vendor) {
deny all;
return 404;
}
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/var/opt/rh/rh-php72/run/php-fpm/zabbix.sock;
# fastcgi_pass unix:/var/opt/rh/rh-php73/run/php-fpm/zabbix.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param DOCUMENT_ROOT /usr/share/zabbix;
fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}
[root@test nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@test nginx]# systemctl start nginx
systemctl start zabbix-server zabbix-agent
浏览器访问**http://192.168.X.X:8000/**发现报错502 Bad Gateway
tailf /var/log/nginx/error.log
#发现报错如下
[crit] 16191#16191: *228 connect() to unix:/var/opt/rh/rh-php72/run/php-fpm/zabbix.sock failed (13: Permission denied) while connecting to upstream
解决方法
修改nginx启动用户为nginx(也可以修改php-fpm用户)
vim /etc/nginx/nginx.conf
#修改用户,一般在前几行
user root;
#重载nginx
nginx -s reload
浏览器再次访问发现正常
选择Next Step
继续选择Next Step
填好数据库信息后,继续选择Next Step
确认一遍信息,没有问题,点击Next Step
提示successful,点击Finish
登录zabbix监控后台,默认账号Admin,密码zabbix
查看监控图形时,发现数据为乱码,如下图所示,我们可以通过修改字体来解决
cd /usr/share/zabbix/assets/fonts
mv graphfont.ttf graphfont.ttf_bak
进入电脑C:\Windows\Fonts,选择楷体,拷贝到/usr/share/zabbix/assets/fonts
重命名为graphfont.ttf
mv SIMKAI.TTF graphfont.ttf
1、grafana拥有快速灵活的客户端图表,面板插件有许多不同方式的可视化指标和日志,官方库中具有丰富的仪表盘插件,比如热图、折线图、图表等多种展示方式,让我们复杂的数据展示的美观而优雅。
2、Grafana支持许多不同的时间序列数据(数据源)存储后端。每个数据源都有一个特定查询编辑器。官方支持以下数据源:Graphite、infloxdb、opensdb、prometheus、elasticsearch、cloudwatch。每个数据源的查询语言和功能明显不同。你可以将来自多个数据源的数据组合到一个仪表板上,但每个面板都要绑定到属于特定组织的特定数据源
3、Grafana中的警报允许您将规则附加到仪表板面板上。保存仪表板时,Gravana会将警报规则提取到单独的警报规则存储中,并安排它们进行评估。报警消息还能通过钉钉、邮箱等推送至移动端。但目前grafana只支持graph面板的报警。
4、Grafana使用来自不同数据源的丰富事件注释图表,将鼠标悬停在事件上会显示完整的事件元数据和标记;
6、Grafana使用Ad-hoc过滤器允许动态创建新的键/值过滤器,这些过滤器会自动应用于使用该数据源的所有查询。
wget https://dl.grafana.com/oss/release/grafana-8.3.0-1.x86_64.rpm
yum -y install grafana-8.3.0-1.x86_64.rpm
systemctl daemon-reload
systemctl start grafana-server.service
systemctl enable grafana-server.service
[root@test ~]# netstat -antup|grep 3000
tcp6 0 0 :::3000 :::* LISTEN 20311/grafana-serve
[root@test ~]# grafana-cli plugins list-remote
id: abhisant-druid-datasource version: 0.0.6
id: aceiot-svg-panel version: 0.0.11
id: ae3e-plotly-panel version: 0.5.0
id: agenty-flowcharting-panel version: 0.9.1
id: aidanmountford-html-panel version: 0.0.2
id: akumuli-datasource version: 1.3.12
id: alexanderzobnin-zabbix-app version: 4.2.6
id: alexandra-trackmap-panel version: 1.2.6
id: andig-darksky-datasource version: 1.0.2
id: anodot-datasource version: 4.0.5
id: anodot-panel version: 2.0.1
id: aquaqanalytics-kdbadaptor-datasource version: 3.0.0
id: aquaqanalytics-kdbbackend-datasource version: 1.0.0
id: auxmoney-waterfall-panel version: 1.0.6
id: aws-datasource-provisioner-app version: 1.9.0
id: ayoungprogrammer-finance-datasource version: 1.0.1
id: belugacdn-app version: 1.2.1
id: bessler-pictureit-panel version: 1.0.1
id: bilibala-echarts-panel version: 2.2.4
id: blackcowmoo-googleanalytics-datasource version: 0.1.4
id: blackmirror1-singlestat-math-panel version: 1.1.8
id: blackmirror1-statusbygroup-panel version: 1.1.2
id: bmchelix-ade-datasource version: 3.0.0
id: boazreicher-mosaicplot-panel version: 1.0.14
id: boazreicher-sierraplot-panel version: 1.0.14
id: bosun-app version: 0.0.29
id: briangann-datatable-panel version: 1.0.3
id: briangann-gauge-panel version: 0.0.9
id: camptocamp-prometheus-alertmanager-datasource version: 1.2.1
id: ccin2p3-riemann-datasource version: 0.1.6
id: chaosmeshorg-datasource version: 2.2.3
id: citilogics-geoloop-panel version: 1.1.2
id: clarity89-finnhub-datasource version: 0.3.3
id: cloudflare-app version: 0.2.4
id: cloudspout-button-panel version: 7.0.23
id: cognitedata-datasource version: 2.6.0
id: corpglory-progresslist-panel version: 1.0.6
id: dalmatinerdb-datasource version: 1.0.5
id: dalvany-image-panel version: 2.5.0
id: ddurieux-glpi-app version: 1.3.1
id: devicehive-devicehive-datasource version: 2.0.2
id: devopsprodigy-kubegraf-app version: 1.5.2
id: digrich-bubblechart-panel version: 1.2.0
id: dlopes7-appdynamics-datasource version: 3.0.4
id: doitintl-bigquery-datasource version: 2.0.3
id: esnet-matrix-panel version: 1.0.6
id: factry-untimely-panel version: 0.2.0
id: farski-blendstat-panel version: 1.0.3
id: fastweb-openfalcon-datasource version: 1.0.1
id: fatcloud-windrose-panel version: 0.7.1
id: fetzerch-sunandmoon-datasource version: 0.3.0
id: fifemon-graphql-datasource version: 1.3.0
id: flaminggoat-maptrack3d-panel version: 0.1.9
id: flant-statusmap-panel version: 0.5.1
id: foursquare-clouderamanager-datasource version: 0.9.3
id: foursquare-studio-panel version: 1.0.1
id: frser-sqlite-datasource version: 3.1.0
id: fzakaria-simple-annotations-datasource version: 1.0.1
id: gapit-htmlgraphics-panel version: 2.1.1
id: gnocchixyz-gnocchi-datasource version: 1.7.1
id: goshposh-metaqueries-datasource version: 0.0.9
id: gowee-traceroutemap-panel version: 0.3.0
id: grafadruid-druid-datasource version: 1.4.0
id: grafana-athena-datasource version: 2.3.1
id: grafana-azure-data-explorer-datasource version: 4.1.10
id: grafana-azuredevops-datasource version: 0.1.2
id: grafana-bigquery-datasource version: 1.2.3
id: grafana-clickhouse-datasource version: 2.0.5
id: grafana-clock-panel version: 2.1.1
id: grafana-datadog-datasource version: 2.3.14
id: grafana-db2-datasource version: 0.0.6
id: grafana-discourse-datasource version: 1.1.0
id: grafana-dynatrace-datasource version: 3.4.3
id: grafana-enterprise-logs-app version: 2.6.0
id: grafana-enterprise-traces-app version: 1.1.0
id: grafana-es-open-distro-datasource version: 1.0.6
id: grafana-github-datasource version: 1.0.15
id: grafana-gitlab-datasource version: 0.2.0
id: grafana-googlesheets-datasource version: 1.1.6
id: grafana-guidedtour-panel version: 0.2.0
id: grafana-honeycomb-datasource version: 1.1.0
id: grafana-image-renderer version: 3.5.0
id: grafana-iot-sitewise-datasource version: 1.4.0
id: grafana-iot-twinmaker-app version: 1.2.1
id: grafana-jira-datasource version: 1.0.11
id: grafana-k6-app version: 0.4.1
id: grafana-kairosdb-datasource version: 3.0.2
id: grafana-metrics-enterprise-app version: 3.6.3
id: grafana-mongodb-datasource version: 1.4.12
id: grafana-newrelic-datasource version: 2.2.7
id: grafana-odbc-datasource version: 1.0.1
id: grafana-opcua-datasource version: 1.1.6
id: grafana-opensearch-datasource version: 1.1.2
id: grafana-oracle-datasource version: 2.2.8
id: grafana-orbit-datasource version: 0.1.1
id: grafana-polystat-panel version: 1.2.11
id: grafana-redshift-datasource version: 1.4.1
id: grafana-salesforce-datasource version: 1.0.3
id: grafana-saphana-datasource version: 1.0.5
id: grafana-sentry-datasource version: 1.0.1
id: grafana-servicenow-datasource version: 2.4.0
id: grafana-simple-json-datasource version: 1.4.2
id: grafana-singlestat-panel version: 2.0.0
id: grafana-snowflake-datasource version: 1.4.1
id: grafana-splunk-datasource version: 4.0.6
id: grafana-splunk-monitoring-datasource version: 1.0.5
id: grafana-strava-datasource version: 1.5.1
id: grafana-synthetic-monitoring-app version: 1.5.6
id: grafana-timestream-datasource version: 2.4.0
id: grafana-wavefront-datasource version: 2.0.1
id: grafana-worldmap-panel version: 0.3.3
id: grafana-x-ray-datasource version: 2.2.0
id: gretamosa-topology-panel version: 1.0.1
id: gridprotectionalliance-openhistorian-datasource version: 1.0.3
id: gridprotectionalliance-osisoftpi-datasource version: 1.1.1
id: hadesarchitect-cassandra-datasource version: 2.2.1
id: hamedkarbasi93-kafka-datasource version: 0.2.0
id: hamedkarbasi93-nodegraphapi-datasource version: 1.0.1
id: hawkular-datasource version: 1.1.2
id: humio-datasource version: 3.3.1
id: ibm-apm-datasource version: 0.9.1
id: innius-grpc-datasource version: 1.0.9
id: innius-video-panel version: 1.0.5
id: instana-datasource version: 3.3.4
id: integrationmatters-comparison-panel version: 1.1.0
id: iosb-sensorthings-datasource version: 0.0.4
id: isaozler-paretochart-panel version: 0.3.4
id: isaozler-shiftselector-panel version: 0.0.3
id: itrs-obcerv-datasource version: 1.0.0
id: jasonlashua-prtg-datasource version: 4.0.4
id: jdbranham-diagram-panel version: 1.7.3
id: jeanbaptistewatenberg-percent-panel version: 1.0.6
id: kentik-connect-app version: 1.6.1
id: kniepdennis-neo4j-datasource version: 1.1.0
id: knightss27-weathermap-panel version: 0.3.4
id: larona-epict-panel version: 2.0.5
id: lework-lenav-panel version: 1.0.0
id: lightstep-metrics-datasource version: 1.0.0
id: linksmart-hds-datasource version: 1.0.2
id: linksmart-sensorthings-datasource version: 1.3.1
id: macropower-analytics-panel version: 2.1.0
id: magnesium-wordcloud-panel version: 1.2.4
id: marcuscalidus-svg-panel version: 0.3.4
id: marcusolsson-calendar-panel version: 0.7.1
id: marcusolsson-csv-datasource version: 0.6.2
id: marcusolsson-dynamictext-panel version: 1.9.0
id: marcusolsson-gantt-panel version: 0.8.1
id: marcusolsson-hexmap-panel version: 0.3.3
id: marcusolsson-hourly-heatmap-panel version: 2.0.1
id: marcusolsson-json-datasource version: 1.3.2
id: marcusolsson-static-datasource version: 1.4.4
id: marcusolsson-treemap-panel version: 2.0.0
id: marcusolsson-ynab-datasource version: 0.1.2
id: michaeldmoore-annunciator-panel version: 1.1.0
id: michaeldmoore-multistat-panel version: 1.7.2
id: michaeldmoore-scatter-panel version: 1.1.0
id: monasca-datasource version: 1.0.1
id: monitoringartist-monitoringart-datasource version: 1.0.1
id: moogsoft-aiops-app version: 8.0.2
id: mtanda-google-calendar-datasource version: 1.0.5
id: mtanda-heatmap-epoch-panel version: 0.1.8
id: mtanda-histogram-panel version: 0.1.7
id: mxswat-separator-panel version: 1.0.1
id: natel-discrete-panel version: 0.1.1
id: natel-influx-admin-panel version: 0.0.6
id: natel-plotly-panel version: 0.0.7
id: natel-usgs-datasource version: 0.0.3
id: neocat-cal-heatmap-panel version: 0.0.4
id: netsage-bumpchart-panel version: 1.0.2
id: netsage-sankey-panel version: 1.0.6
id: netsage-slopegraph-panel version: 1.0.6
id: nikosc-percenttrend-panel version: 1.0.7
id: novalabs-annotations-panel version: 0.0.2
id: novatec-sdg-panel version: 4.0.3
id: ntop-ntopng-datasource version: 1.0.1
id: oci-logs-datasource version: 2.0.3
id: oci-metrics-datasource version: 3.0.6
id: opennms-helm-app version: 8.0.2
id: orchestracities-iconstat-panel version: 1.2.3
id: orchestracities-map-panel version: 1.4.4
id: ovh-warp10-datasource version: 2.2.1
id: parca-datasource version: 0.0.3
id: parca-panel version: 0.0.3
id: paytm-kapacitor-datasource version: 0.1.3
id: percona-percona-app version: 1.0.1
id: petrslavotinek-carpetplot-panel version: 0.1.2
id: pgillich-tree-panel version: 0.1.9
id: philipsgis-phlowchart-panel version: 0.1.0
id: pierosavi-imageit-panel version: 1.0.7
id: pixie-pixie-datasource version: 0.0.9
id: pr0ps-trackmap-panel version: 2.1.2
id: praj-ams-datasource version: 1.2.1
id: pue-solr-datasource version: 1.0.3
id: pyroscope-datasource version: 1.1.3
id: pyroscope-panel version: 1.4.1
id: quasardb-datasource version: 3.8.3
id: rackerlabs-blueflood-datasource version: 0.0.3
id: radensolutions-netxms-datasource version: 1.2.3
id: redis-app version: 2.2.1
id: redis-datasource version: 2.1.1
id: redis-explorer-app version: 2.1.1
id: ryantxu-ajax-panel version: 0.1.0
id: ryantxu-annolist-panel version: 0.0.2
id: satellogic-3d-globe-panel version: 0.1.1
id: savantly-heatmap-panel version: 0.2.1
id: sbueringer-consul-datasource version: 0.1.5
id: scadavis-synoptic-panel version: 1.0.5
id: sebastiangunreben-cdf-panel version: 0.2.4
id: sentinelone-dataset-datasource version: 3.0.8
id: shorelinesoftware-shoreline-datasource version: 1.1.0
id: sidewinder-datasource version: 0.2.1
id: simpod-json-datasource version: 0.4.2
id: skydive-datasource version: 1.2.1
id: smartmakers-trafficlight-panel version: 1.0.1
id: sni-pnp-datasource version: 1.0.8
id: sni-thruk-datasource version: 1.0.6
id: snuids-radar-panel version: 1.5.1
id: snuids-svg-panel version: 1.0.0
id: snuids-trafficlights-panel version: 1.5.1
id: speakyourcode-button-panel version: 0.2.2
id: spotify-heroic-datasource version: 0.0.2
id: sskgo-perfcurve-panel version: 1.5.0
id: stagemonitor-elasticsearch-app version: 0.83.3
id: streamr-datasource version: 1.5.0
id: tdengine-datasource version: 3.2.7
id: teamviewer-datasource version: 1.0.2
id: tencentcloud-monitor-app version: 2.8.0
id: thalysantana-appcenter-datasource version: 1.0.0
id: thiagoarrais-matomotracking-panel version: 0.2.3
id: timomyl-breadcrumb-panel version: 1.2.0
id: timomyl-organisations-panel version: 1.4.0
id: udoprog-heroic-datasource version: 0.1.1
id: ventura-psychrometric-panel version: 2.0.0
id: vertamedia-clickhouse-datasource version: 2.5.3
id: vertica-grafana-datasource version: 2.0.3
id: verticle-flowhook-datasource version: 0.1.3
id: volkovlabs-image-panel version: 2.6.0
id: volkovlabs-rss-datasource version: 1.5.0
id: vonage-status-panel version: 1.0.11
id: voxter-app version: 0.0.2
id: williamvenner-timepickerbuttons-panel version: 4.1.1
id: xginn8-pagerduty-datasource version: 0.2.2
id: yesoreyeram-boomtable-panel version: 1.4.1
id: yesoreyeram-boomtheme-panel version: 0.2.1
id: yesoreyeram-infinity-datasource version: 0.8.8
id: yeya24-chaosmesh-datasource version: 0.2.3
id: zestairlove-compacthostmap-panel version: 0.9.0
id: zuburqan-parity-report-panel version: 1.2.2
Please restart Grafana after installing plugins. Refer to Grafana documentation for instructions if necessary.
安装使用grafana-cli plugins install
,如安装时钟组件
grafana-cli plugins install grafana-clock-panel
浏览器访问http://192.168.X.X:3000报错If you're seeing this Grafana has failed to load its application files 1. This could be caused by yo
vim /etc/grafana/grafana.ini
serve_from_sub_path = true #第52行
systemctl restart grafana-server.service
浏览器访问http://192.168.X.X:3000,默认账号admin,密码admin,首次登录需修改密码。
选择插件
输入zabbix
安装zabbix插件
启用zabbix插件
配置zabbix插件
填写zabbix的api地址http://localhost:8000/api_jsonrpc.php
输入zabbix的账号密码,然后保存
导入自带的模板
码字不易。如果文章对您有希望的话,请三连支持一波。
如有问题,欢迎留言,一起探讨,感谢。
也可关注下方公众号,看到留言后会第一时间回复。