安装插件
配置数据源
导入模版
查看
wget https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/rpm/Packages/grafana-10.0.0-1.x86_64.rpm
[root@rocky8 apps]# yum install grafana-10.0.0-1.x86_64.rpm
[root@rocky8 apps]# systemctl start grafana-server.service
修改为中文
[root@rocky8 apps]# vi /etc/grafana/grafana.ini
default_language = zh-Hans
[root@rocky8 apps]# systemctl restart grafana-server.service
访问
http://192.168.1.250:3000/
列出插件版本
[root@rocky8 apps]# grafana-cli plugins list-versions alexanderzobnin-zabbix-app
4.4.1
4.4.0
安装插件
[root@rocky8 apps]# grafana-cli plugins install alexanderzobnin-zabbix-app 4.4.1
重启
systemctl restart grafana-server.service
安装插件的目录
ll /var/lib/grafana/plugins/alexanderzobnin-zabbix-app/
添加数据源
在granfana上添加zabbix的解析 192.168.1.150 zabbix.luo.com
http://zabbix.luo.com/api_jsonrpc.php #zabbix是通过nginx安装的不用加zabbix
填写zabbix用户名密码,测试成功
Admin
zabbix
导入官网的其它 Grafana 模板
https://grafana.com/grafana/dashboards
模板ID 5363
编辑仪表板,group改为 g r o u p , h o s t 改为 group,host 改为 group,host改为host保存,就可以选择组和主机查看
查看
导出
优化zabbix缓存
CacheSize=128M#调大
修改zabbix进程导致zabbix一直重启
StartDBSyncers=400 #启动多少个线程和数据库连接
StartPollersUnreachable=1000 #用于设置当Zabbix服务器无法连接到被监控主机时,启动的不可达性轮询的数量。
进程加大,可能会导致数据库连接过多,超过最大值,导致Zabbix 无法启动,解决方案,加大数据库的连接数
#注意:如果无法启动,可能是数据库连接数不足
[root@zabbix-server ~]#tail /var/log/zabbix/zabbix_server.log
1367396:20230906:222534.347 [Z3001] connection to database ‘zabbix’ failed: [1040] Too many connections
1367396:20230906:222534.347 Cannot connect to the database. Exiting…
1367399:20230906:222534.350 server #189 started [trapper #4]
1367068:20230906:222534.353 HA manager has been paused
1367400:20230906:222534.354 server #190 started [trapper #5]
1367398:20230906:222534.358 [Z3001] connection to database ‘zabbix’ failed: [1040] Too many connections
查看数据库连接
mysql> show status like ‘Threads%’;
root@server02:~# vi /etc/mysql/mysql.conf.d/mysqld.cnf
max_connections = 1000
ysql> select @@max_connections;
±------------------+
| @@max_connections |
±------------------+
| 1000 |
±------------------+
1 row in set (0.00 sec)
修改数据库参数后数据库变为只读
1372996:20230906:223235.053 [Z3005] query failed: [1290] The MySQL server is running with the --read-only option so it cannot execute this statement [select ha_nodeid,name,status,lastaccess,address,port,ha_sessionid from ha_node order by ha_nodeid for update]
mysql> show global variables like '%read_only%';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_read_only | OFF |
| read_only | ON |
| super_read_only | OFF |
| transaction_read_only | OFF |
+-----------------------+-------+
4 rows in set (0.00 sec)
mysql> set global read_only = 0;
修改mysql配置文件添加
read_only = 0
打开的文件数太多,优化参考https://www.programminghunter.com/article/88832382383/
zabbix_server [1374128]: failed to open log file: [24] Too many open files
zabbix_server [1374128]: failed to write [cannot accept incoming IPC connection: [24] Too many open files] into log file
1374143:20230906:223937.970 executing housekeeper
zabbix不能重启 pkill -9 zabbix_server
root@server02:~# lsof -u zabbix|wc -l
90537
cat vim /etc/security/limits.conf
zabbix soft nofile 1024000
zabbix hard nofile 1024000
zabbix soft soft 1024000
zabbix hard soft 1024000
Zabbix出现 0ut Of Memory,将原本2G内存加到8G还是Out 0f Memory
缓存太少
zabbix配置文件
StartIPMIPollers=0 #初始化启动时,启动IPMI子进程轮询器的数量,数量越多,则服务端吞吐能力越强,对系统资源消耗越大 , 主要用于IPMI技术用于获取硬件状态场景。
StartDiscoverers=1 #设置用于自动发现主机的线程数量,若单台代理所管理机器超过500台,可以考虑加大此数值(仅适用于直接AGENT场景)!!!! 1.8.5以前最大数值为255