Ubuntu系统 安装 Zabbix Server 6.0

Zabbix6.0简介:

zabbix6.0新特性

1、开箱即用的Zabbix server高可用群集

Zabbix server高可用防止硬件故障或计划维护期的停机:

  • 原生选择加入HA群集配置
  • 定义一个或多个备用节点
  • 实时监控Zabbix server群集节点的状态
  • 不需要外部工具即可将Zabbix server配置为HA群集模式

2、Kubernetes监控

Zabbix6.0LTS新增Kubernetes监控功能,可以在Kubernetes系统从多个维度采集指标:

  • Kubernetes节点和pods的自动发现和监控
  • 无代理方式采集Kubernetes pods和节点的信息
  • 获取Kubernetes节点主机高水平信息

Kubernetes监控还能够监控Kubernetes组件,例如

  • kube-controller-manager
  • kube-apiserver·kube-scheduler
  • kubelet

3、可视化数据的新方法

Zabbix6.0新增的构件提供了展示信息的许多新方法。

  • 地理地图构件能在地图上显示主机和问题
  • 主机排序组件可显示按监控项值排序的前N个或后N个主机的列表
  • 单一监控项构件能展示单个指标的值
  • SLA构件能显示特定业务服务的当前SLA

4、新增模板和集成

Zabbix6.0为最受欢迎的供应商提供了许多新模板:

  • Cisco ASAV
  • Cloudflare
  • Dell PowerEdge
  • f5BIG-IP
  • GridGain
  • HPE ProLiant servers
  • InfluxDB
  • Kubernetes
  • Mikrotik
  • NGINXPlus
  • pfsense
  • Systemd
  • Travis Cl
  • VMWare SD-WAN VeloCloud

 

安装部署:


一、安装MySQL8.0

方法如下:

https://www.cnblogs.com/Magiclala/p/16638781.html

确认安装的MySQL版本

root@Zabbix-Server:~# mysql -V
mysql  Ver 8.0.30 for Linux on x86_64 (MySQL Community Server - GPL)

创建初始Zabbix数据库

安装完成后,root账户登录数据库,配置一个用户zabbix,设置密码为password,并配置本地登录权限 localhost 或者 远程登录权限 %

sudo mysql -uroot -p
password 
mysq1> create database zabbix character set utf8mb4 collate utf8mb4_bin;    #zabbix创建数据库要指定字符集,如果不指定中文会乱码,英文不乱码。
mysql> create user zabbix@'%' identified by 'Qqq1234.0';
mysq1> grant all privileges on zabbix.* to zabbix@'%';    #grant授权 all privileges所有权限 on zabbix表里的.*所有文件,授权给zabbix用户 @'%'远程和本地登录
mysq1> quit;
#如果数据库与zbx,php在一起
grant all privileges on zabbix.* to zabbix@'localhost' identified by 'Qqq1234.0';
#如果数据库与zbx,php不在一起
grant all privileges on zabbix.* to zabbix@'172.16.%'identified by 'Qqq1234.0';
#甚至
grant all privileges on zabbix.* to zabbix@'%'identified by 'Qqq1234.0';

验证登录:

root@Zabbix-Server:~# mysql -uzabbix -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.30 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| performance_schema |
| zabbix             |
+--------------------+
3 rows in set (0.01 sec)

mysql> exit
Bye
root@Zabbix-Server:~# 

数据库账户基本操作命令

#查询数据库账户
select user, host from mysql.user;
#删除账户 'zabbix'
drop user 'zabbix'@'%';
#查询数据库
show databases;
#删除数据库zabbix;
drop database zabbix;
#修改账户密码
alter user 'zabbix'@'%' identified  by 'Qqqq1234.com';

二、安装Zabbix环境  版本:Ubuntu 20.04.4 LTS (GNU/Linux 5.15.0-46-generic x86_64)

安装环境要求:Zabbix官网环境要求

Zabbix官网安装流程跳转

去Wget Zabbix-Server 6.0版本安装包

wget https://repo.zabbix.com/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-3+ubuntu20.04_all.deb

或者去Wget阿里源的安装包

wget http://mirrors.aliyun.com/zabbix/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-3+ubuntu22.04_all.deb

解压缩安装包

dpkg -i zabbix-release_6.0-3+ubuntu20.04_all.deb

apt更新

apt update

这里注意:这里安装zabbix-agent2而不是官方操作流程是安装zabbix-agent,zabbix-agent有2个版本,2会支持更多功能,一定要安装2哦。还要注意是安装apache还是nginx,注意选择

apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2

安装Zabbix中文字体

apt -y install language-pack-zh-hans

 

导入初始架构和数据,系统将提示您输入新创建的密码。

数据库在本地用-h localhost 最后的zabbix是库

zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p -h localhost zabbix

数据库不在本地用-h IP地址 最后的zabbix是库

zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -uzabbix -p -h 192.168.168.201 zabbix

 

验证登录:

root@Zabbix-Server:~# mysql -uzabbix -p

mysql> use zabbix

mysql> show databases;
查看全部过程,导入了173张表
root@Zabbix-Server:~# mysql -uzabbix -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.0.30 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| performance_schema |
| zabbix             |
+--------------------+
3 rows in set (0.09 sec)

mysql> use zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| auditlog                   |
| autoreg_host               |
| conditions                 |
| config                     |
| config_autoreg_tls         |
| corr_condition             |
| corr_condition_group       |
| corr_condition_tag         |
| corr_condition_tagpair     |
| corr_condition_tagvalue    |
| corr_operation             |
| correlation                |
| dashboard                  |
| dashboard_page             |
| dashboard_user             |
| dashboard_usrgrp           |
| dbversion                  |
| dchecks                    |
| dhosts                     |
| drules                     |
| dservices                  |
| escalations                |
| event_recovery             |
| event_suppress             |
| event_tag                  |
| events                     |
| expressions                |
| functions                  |
| globalmacro                |
| globalvars                 |
| graph_discovery            |
| graph_theme                |
| graphs                     |
| graphs_items               |
| group_discovery            |
| group_prototype            |
| ha_node                    |
| history                    |
| history_log                |
| history_str                |
| history_text               |
| history_uint               |
| host_discovery             |
| host_inventory             |
| host_tag                   |
| hostmacro                  |
| hosts                      |
| hosts_groups               |
| hosts_templates            |
| housekeeper                |
| hstgrp                     |
| httpstep                   |
| httpstep_field             |
| httpstepitem               |
| httptest                   |
| httptest_field             |
| httptest_tag               |
| httptestitem               |
| icon_map                   |
| icon_mapping               |
| ids                        |
| images                     |
| interface                  |
| interface_discovery        |
| interface_snmp             |
| item_condition             |
| item_discovery             |
| item_parameter             |
| item_preproc               |
| item_rtdata                |
| item_tag                   |
| items                      |
| lld_macro_path             |
| lld_override               |
| lld_override_condition     |
| lld_override_opdiscover    |
| lld_override_operation     |
| lld_override_ophistory     |
| lld_override_opinventory   |
| lld_override_opperiod      |
| lld_override_opseverity    |
| lld_override_opstatus      |
| lld_override_optag         |
| lld_override_optemplate    |
| lld_override_optrends      |
| maintenance_tag            |
| maintenances               |
| maintenances_groups        |
| maintenances_hosts         |
| maintenances_windows       |
| media                      |
| media_type                 |
| media_type_message         |
| media_type_param           |
| module                     |
| opcommand                  |
| opcommand_grp              |
| opcommand_hst              |
| opconditions               |
| operations                 |
| opgroup                    |
| opinventory                |
| opmessage                  |
| opmessage_grp              |
| opmessage_usr              |
| optemplate                 |
| problem                    |
| problem_tag                |
| profiles                   |
| proxy_autoreg_host         |
| proxy_dhistory             |
| proxy_history              |
| regexps                    |
| report                     |
| report_param               |
| report_user                |
| report_usrgrp              |
| rights                     |
| role                       |
| role_rule                  |
| script_param               |
| scripts                    |
| service_alarms             |
| service_problem            |
| service_problem_tag        |
| service_status_rule        |
| service_tag                |
| services                   |
| services_links             |
| sessions                   |
| sla                        |
| sla_excluded_downtime      |
| sla_schedule               |
| sla_service_tag            |
| sysmap_element_trigger     |
| sysmap_element_url         |
| sysmap_shape               |
| sysmap_url                 |
| sysmap_user                |
| sysmap_usrgrp              |
| sysmaps                    |
| sysmaps_element_tag        |
| sysmaps_elements           |
| sysmaps_link_triggers      |
| sysmaps_links              |
| tag_filter                 |
| task                       |
| task_acknowledge           |
| task_check_now             |
| task_close_problem         |
| task_data                  |
| task_remote_command        |
| task_remote_command_result |
| task_result                |
| timeperiods                |
| token                      |
| trends                     |
| trends_uint                |
| trigger_depends            |
| trigger_discovery          |
| trigger_queue              |
| trigger_tag                |
| triggers                   |
| users                      |
| users_groups               |
| usrgrp                     |
| valuemap                   |
| valuemap_mapping           |
| widget                     |
| widget_field               |
+----------------------------+
173 rows in set (0.01 sec)

mysql>

 

为Zabbix server配置数据库 编辑配置文件

找到“#DBPassword=”注释掉的那一行,修改成你的zabbix密码,我们的是Qqq1234.0

vim /etc/zabbix/zabbix_server.conf
DBPassword=Qqq1234.0

启动Zabbix-Server、Zabbix-agent2、apache2 并检查他们的状态

systemctl restart zabbix-server zabbix-agent2 apache2
systemctl enable zabbix-server zabbix-agent2 apache2
systemctl status zabbix-server zabbix-agent2 apache2

浏览器访问:http://192.168.0.X/zabbix/

默认英文,选择中文界面(前面已经安装中文语音),下一步

检查全部ok,下一步,密码过于简单的时候,注意配置选择去掉加密模式,可能过不去

选择上海时区,这里的zabbix主机名称,其实是你的网站名字下一步

汇总完成。

通过find命令,你可以找到配置文件的位置

find / -name "zabbix.conf.php"
root@Zabbix-Server:~# find / -name "zabbix.conf.php"
find: ‘/run/user/125/gvfs’: Permission denied
/etc/zabbix/web/zabbix.conf.php
/usr/share/zabbix/conf/zabbix.conf.php
root@Zabbix-Server:~# ls -l /usr/share/zabbix/conf/zabbix.conf.php
lrwxrwxrwx 1 root root 31 8月  29 15:33 /usr/share/zabbix/conf/zabbix.conf.php -> /etc/zabbix/web/zabbix.conf.php
root@Zabbix-Server:~# 

软连接地址是/usr/share/zabbix/conf/zabbix.conf.php

真实的地址是/etc/zabbix/web/zabbix.conf.php

未来在修改数据库地址的时候需要用到

登录Zabbix:

初始用户名称:Admin

初始密码:zabbix

首次登录成功界面,可以看到你设置的Zabbix主机名称

 

(如果)分布式部署Zabbix

vim /etc/zabbix/zabbix_server.conf

找到如下内容,修改成对应IP

# DBHost=localhost
DBHost=192.168.168.104

# DBName=
DBName=zabbix

# DBUser=
DBUser=zabbix

# DBPassword=
DBPassword=Qqq1234.0

# HANodeName=
HANodeName=Zabbix-Server1

# NodeAddress=localhost:10051
NodeAddress=192.168.168.101:10051

wq退出后重启服务
systemctl restart zabbix-server zabbix-agent2 apache2
systemctl enable zabbix-server zabbix-agent2 apache2

主节点执行

root@Zabbix-Server1:~# zabbix_server -R ha_status
Failover delay: 60 seconds
Cluster status:
   #  ID                        Name                      Address                        Status      Last Access
   1. cl7o68azc00018h2faz2usgfg Zabbix-Server1            192.168.168.101:10051          active      3s
   2. cl7o68j7000010m2g1helhtq0 Zabbix-Server2            192.168.168.102:10051          standby     1s
   3. cl7o68y2500016y2hgwidz4qs Zabbix-Server3            192.168.168.103:10051          standby     1s
root@Zabbix-Server1:~# 

报表-系统信息可以查看HA信息

修改主机时区(如有必要)

timedatectl set-timezone Asia/Shanghai
date -R
Thu, 01 Sep 2022 20:25:24 +0800

 

解决中文乱码问题:

apt -y install ttf-wqy-microhei
cp /usr/share/fonts/truetype/wqy/wqy-microhei.ttc /usr/share/zabbix/assets/fonts/graphfont.ttf

 

客户端的配置:angent2配置Server服务器的路径

vim /etc/zabbix/zabbix_agent2.conf

找到Server=127.0.0.1

修改为服务器地址192.168.1.X(zabbix本地自己不用改,仅在客户端上改

root@Zabbix-Server:~# grep '^[a-Z]' /etc/zabbix/zabbix_agent2.conf 
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
Include=./zabbix_agent2.d/plugins.d/*.conf
root@Zabbix-Server:~# 

检查

检查zabbix-agent2是否配置成功。

语法:zabbix_get -s客户端IP -p 客户端agent端口 -k  键值

案例:

zabbix_get -s 192.168.11.51 -k "agent.ping"
1


得到的结果为1表示正常
检查zabbix-server日志是否正常

sudo tail -f /var/log/zabbix/zabbix_server.log

 

替换其他字体的使用方法:

#将windows的微软雅黑字体传到Zabbix Server
[root@ubuntu2004 ~]#cd/usr/share/zabbix/assets/fonts/
[root@ubuntu2004 fonts]#mv graphfont.tff{,.bak}
[root@ubuntu2004 fonts]#mv msyhbd.ttc graphfont.ttf

posted @ 2022-08-30 17:29  Magiclala  阅读(3490)  评论(0编辑  收藏  举报