zabbix实战

实验一:安装zabbix5.0

范例: 在ubuntu20.04 安装 Zabbix Server 5.0

#官网下载
root@ubuntu2004:~# wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb
--2022-06-22 21:33:23--  https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb
Resolving repo.zabbix.com (repo.zabbix.com)... 178.128.6.101, 2604:a880:2:d0::2062:d001
Connecting to repo.zabbix.com (repo.zabbix.com)|178.128.6.101|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4244 (4.1K) [application/octet-stream]
Saving to: ‘zabbix-release_5.0-1+focal_all.deb’zabbix-release_5.0-1+focal_all 100%[====================================================>]   4.14K  --.-KB/s    in 0s      2022-06-22 21:33:24 (367 MB/s) - ‘zabbix-release_5.0-1+focal_all.deb’ saved [4244/4244]root@ubuntu2004:~# dpkg -i zabbix-release_5.0-1+focal_all.deb
Selecting previously unselected package zabbix-release.
(Reading database ... 114056 files and directories currently installed.)
Preparing to unpack zabbix-release_5.0-1+focal_all.deb ...
Unpacking zabbix-release (1:5.0-1+focal) ...
Setting up zabbix-release (1:5.0-1+focal) ...root@ubuntu2004:~# dpkg -L zabbix-release
/.
/etc
/etc/apt
/etc/apt/sources.list.d
/etc/apt/sources.list.d/zabbix.list
/etc/apt/trusted.gpg.d
/etc/apt/trusted.gpg.d/zabbix-official-repo.gpg
/usr
/usr/share
/usr/share/doc
/usr/share/doc/zabbix-release
/usr/share/doc/zabbix-release/README.Debian
/usr/share/doc/zabbix-release/changelog.Debian
/usr/share/doc/zabbix-release/copyright#镜像加速
root@ubuntu2004:/etc/apt/sources.list.d# sed -i.bak 's#http://repo.zabbix.com#https://mirror.tuna.tsinghua.edu.cn/zabbix#' /etc/apt/sources.list.d/zabbix.listoot@ubuntu2004:~# cat /etc/apt/sources.list.d/zabbix.list
deb https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/ubuntu focal main
deb-src https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/ubuntu focal mainroot@ubuntu2004:~# apt update#安装包
root@ubuntu2004:~#apt -y  install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-agent2 zabbix-get#安装数据库MySQL
root@ubuntu2004:~# apt -y install mysql-server#如果MySQL和ZabbixServer在同一台主机,此项可不改
[root@zabbix-server ~]#vim /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address     = 0.0.0.0
[root@zabbix-server ~]#systemctl restart mysql.servicemysql> create database zbbix character set utf8 collate utf8_bin;
Query OK, 1 row affected, 2 warnings (0.00 sec)mysql> create user zabbix@'10.0.0.%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)mysql> grant all privileges on zabbix.* to zabbix@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)mysql> select user,host from mysql.user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| zabbix           | 10.0.0.%  |
| debian-sys-maint | localhost |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
6 rows in set (0.00 sec)mysql> exit
Bye#初绐化数据库的表
[root@zabbix-server ~]#zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p123456 zabbix#修改Zabbix Server 连接MySQL
[root@zabbix-server ~]#vim /etc/zabbix/zabbix_server.conf
DBPassword=123456root@ubuntu2004:~# cat /etc/zabbix/nginx.conf
server {listen 80;server_name     zabbix.ehuo.org; #修改主机名
#        listen          80;
#        server_name     example.com;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/run/php/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@ubuntu2004:~# root@ubuntu2004:~# sed -i.bak '/date.timezone/c php_value[date.timezone] = Asia/Shanghai' /etc/zabbix/php-fpm.conf
root@ubuntu2004:~# ^C
root@ubuntu2004:~# cat /etc/zabbix/php-fpm.conf
[zabbix]
user = www-data
group = www-datalisten = /var/run/php/zabbix.sock
listen.owner = www-data
listen.allowed_clients = 127.0.0.1pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/sessions/php_value[max_execution_time] = 300
php_value[memory_limit] = 128M
php_value[post_max_size] = 16M
php_value[upload_max_filesize] = 2M
php_value[max_input_time] = 300
php_value[max_input_vars] = 10000
php_value[date.timezone] = Asia/Shanghai#安装中文包
[root@zabbix-server ~]#apt -y install language-pack-zh-hansroot@ubuntu2004:~# systemctl disable --now apache2
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable apache2
Removed /etc/systemd/system/multi-user.target.wants/apache2.service.
root@ubuntu2004:~# systemctl restart  zabbix-server zabbix-agent2 nginx php7.4-fpm
root@ubuntu2004:~# systemctl enable   zabbix-server
Synchronizing state of zabbix-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable zabbix-server
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /lib/systemd/system/zabbix-server.service.
root@ubuntu2004:~# 

第一次登录, 默认的用户名是 Admin,密码是zabbix

安装zabbix5.0脚本

wget https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.0-1+focal_all.deb
dpkg -i zabbix-release_5.0-1+focal_all.deb
sed -i.bak 's#http://repo.zabbix.com#https://mirror.tuna.tsinghua.edu.cn/zabbix#' /etc/apt/sources.list.d/zabbix.list
apt update
apt -y  install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-agent2
apt -y install mysql-server
cat << EOF | mysql
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by '123456';
grant all privileges on zabbix.* to zabbix@localhost;
EOFzcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p123456  zabbixsed -i.bak '/# DBPassword/a DBPassword=123456' /etc/zabbix/zabbix_server.conf
sed -i.bak '/^server/a\        listen 80;\n        server_name     zabbix.ehuo.org;' /etc/zabbix/nginx.confsed -i.bak '/date.timezone/c php_value[date.timezone] = Asia/Shanghai' /etc/zabbix/php-fpm.confsystemctl disable --now apache2systemctl restart  zabbix-server zabbix-agent2 nginx php7.4-fpmsystemctl enable   zabbix-server

因为字体兼容性的原因,在显示中文时可能会有乱码出现

root@zabbix-server fonts]#pwd
/usr/share/zabbix/assets/fonts
#支持ttf和ttc后缀的字体文件
[root@zabbix-server fonts]#mv graphfont.ttf graphfont.ttf.bak
[root@zabbix-server fonts]#mv SIMYOU.TTF graphfont.ttf
[root@zabbix-server fonts]#ls
graphfont.ttf graphfont.ttf.bak
#注意:字体文件路径和名称的定义在文件/usr/share/zabbix/include/defines.inc.php中配置
#可以修改下面FONT_NAME指定新字体件,注意不需加文件后缀
[root@zabbix-server ~]#grep FONT_NAME /usr/share/zabbix/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name
define('ZBX_FONT_NAME', 'graphfont');root@ubuntu2004:/usr/share/zabbix/assets/fonts# mv SIMYOU.TTF graphfont.ttf
root@ubuntu2004:/usr/share/zabbix/assets/fonts# ls
graphfont.ttf  graphfont.ttf.bak  MSYH.TTC
root@ubuntu2004:/usr/share/zabbix/assets/fonts# grep FONT_NAME /usr/share/zabbix/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME',     'graphfont'); // font file name
define('ZBX_FONT_NAME', 'graphfont');
root@ubuntu2004:/usr/share/zabbix/assets/fonts# 

注意:乱码和语言环境无关,英语环境也支持中文显示,但会有乱码

范例: Rocky8 安装Zabbix Agent2

#从国内镜像下载
[root@rocky8 ~]#rpm -ivh https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/x86_64/zabbix-agent2-6.0.5-1.el8.x86_64.rpm
[root@localhost ~]# rpm -ql https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/x86_64/zabbix-agent2-6.0.5-1.el8.x86_64.rpm
warning: https://mirror.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/x86_64/zabbix-agent2-6.0.5-1.el8.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
/etc/logrotate.d/zabbix-agent2
/etc/zabbix/zabbix_agent2.conf
/etc/zabbix/zabbix_agent2.d
/etc/zabbix/zabbix_agent2.d/plugins.d/ceph.conf
/etc/zabbix/zabbix_agent2.d/plugins.d/docker.conf
/etc/zabbix/zabbix_agent2.d/plugins.d/memcached.conf
/etc/zabbix/zabbix_agent2.d/plugins.d/modbus.conf
/etc/zabbix/zabbix_agent2.d/plugins.d/mongodb.conf
/etc/zabbix/zabbix_agent2.d/plugins.d/mqtt.conf
/etc/zabbix/zabbix_agent2.d/plugins.d/mysql.conf
/etc/zabbix/zabbix_agent2.d/plugins.d/oracle.conf
/etc/zabbix/zabbix_agent2.d/plugins.d/postgres.conf
/etc/zabbix/zabbix_agent2.d/plugins.d/redis.conf
/etc/zabbix/zabbix_agent2.d/plugins.d/smart.conf
/usr/lib/.build-id
/usr/lib/.build-id/88
/usr/lib/.build-id/88/e20f765be60a306e65225d3110fae01371ddee
/usr/lib/systemd/system/zabbix-agent2.service
/usr/lib/tmpfiles.d/zabbix_agent2.conf
/usr/sbin/zabbix_agent2
/usr/share/doc/zabbix-agent2
/usr/share/doc/zabbix-agent2/AUTHORS
/usr/share/doc/zabbix-agent2/COPYING
/usr/share/doc/zabbix-agent2/ChangeLog
/usr/share/doc/zabbix-agent2/NEWS
/usr/share/doc/zabbix-agent2/README
/usr/share/man/man8/zabbix_agent2.8.gz
/var/log/zabbix
/var/run/zabbix
root@rocky8 ~]#vim /etc/zabbix/zabbix_agent2.conf
Server=zabbix.ehuo.org
[root@rocky8 ~]#systemctl enable --now zabbix-agent2.service
[root@rocky8 ~]#ss -ntlp|grep zabbix
LISTEN 0    128        *:10050      *:*  users:
(("zabbix_agent2",pid=22792,fd=8))[root@zabbix-server ~]#zabbix_get -s 10.0.0.8 -k agent.ping
1

范例: 原来生成环境zabbix agent 升级到zabbix agent2

#停止agent 防止端口10050/tcp冲突
[root@rocky8 ~]#system disable --now zabbix-agent#安装
[root@ubuntu1804 ~]#apt -y install zabbix-agent2
[root@centos8 ~]#yum -y install zabbix-agent2#配置文件和agent相同
[root@ubuntu1804 ~]#grep -vE '^$|#' /etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=10.0.0.100     #修改此行
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
[root@ubuntu1804 ~]#systemctl restart zabbix-agent2#在Zabbix Server测试
[root@zabbix-server ~]#zabbix_get -s 10.0.0.58 -k 'agent.ping'
1#agent2是多线程
[root@rocky8 ~]#pstree -p|grep zabbix_agent2`-zabbix_agent2(1825)-+-{zabbix_agent2}(1826)|-{zabbix_agent2}(1827)|-{zabbix_agent2}(1828)|-{zabbix_agent2}(1829)|-{zabbix_agent2}(1830)|-{zabbix_agent2}(1831)`-{zabbix_agent2}(1833)#agent是多进程
[root@rocky8 ~]#pstree -p | grep zabbix_agent`-zabbix_agentd(1448)-+-zabbix_agentd(1449)|-zabbix_agentd(1450)|-zabbix_agentd(1451)|-zabbix_agentd(1452)`-zabbix_agentd(1453)

案例:将Zabbix Server的MySQL 数据库迁移到独立的MySQL服务器

#备份数据库
[root@zabbix-server ~]#mysqldump -uroot -A -F --single-transaction > /data/all.sql
[root@zabbix-server ~]#systemctl stop zabbix-server.service
[root@zabbix-server ~]#systemctl disable --now mysql#在独立数据库服务器上安装并恢复数据库[root@mysql-server ~]#apt -y install mysql-server
[root@mysql-server ~]#mysql <  all.sql#重新授权用户允许远程连接zabbix数据库
[root@mysql-server ~]#mysql
mysql> grant all privileges on zabbix.* to zabbix'10.0.0.%' identified by '123456';#将php的配置指向新的数据库服务器IP
[root@zabbix-server ~]#vim /usr/share/zabbix/conf/zabbix.conf.php
$DB['SERVER']      = '10.0.0.101';#将Zabbix Server的配置指向新的数据库服务器IP
[root@zabbix-server ~]#vim /etc/zabbix/zabbix_server.conf
DBHost=10.0.0.101
DBPort=3306#重启服务生效
[root@zabbix-server ~]#systemctl start zabbix-server.service

rivileges on zabbix.* to zabbix’10.0.0.%’ identified by ‘123456’;

#将php的配置指向新的数据库服务器IP
[root@zabbix-server ~]#vim /usr/share/zabbix/conf/zabbix.conf.php
$DB[‘SERVER’] = ‘10.0.0.101’;

#将Zabbix Server的配置指向新的数据库服务器IP
[root@zabbix-server ~]#vim /etc/zabbix/zabbix_server.conf
DBHost=10.0.0.101
DBPort=3306

#重启服务生效
[root@zabbix-server ~]#systemctl start zabbix-server.service

zabbix5.0的安装与实现相关推荐

  1. (Openeuler-x86)编译安装php-7.4+zabbix5.0.8(Apache+php+zabbix)

    #关闭防火墙和 selinux 并重启 sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config systemctl dis ...

  2. 安装Zabbix5.0服务并监控服务器

    Zabbix 简介 Zabbix 服务安装部署及监控配置 实战-配置监控远程主机 目录 Zabbix简介 Zabbix 服务安装部署及监控配置 配置监控进程主机 Zabbix简介 官方网站:http: ...

  3. docker php 乱码,如何解决docker安装zabbix5.0界面乱码

    如何解决docker安装zabbix5.0界面乱码? zabbix图形界面乱码如下: 解决: docker部署zabbix-web和源码安装zabbix-web一样,字体都是存储在/usr/share ...

  4. CentOS 8源码安装Zabbix5.0

    安装好操作系统后,关闭防火墙和 selinux 并重启 sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config syste ...

  5. 安装和配置zabbix-5.0.20

    一.zabbix安装 1.上传包zabbix-5.0.20.tar.gz 到/usr/local/ 下 2.解压包:tar -xzvf zabbix-5.0.20.tar.gz 并且:mv zabbi ...

  6. zabbix mysql分开部署_Centos7 安装部署zabbix5.0服务端 超详细图文步骤

    一.系统环境准备 1.操作系统Centos7以上版本,注意尽量保证是空系统,没有安装数据库和Apache等中间件 2.安装前关闭selinux和firewall #ps:关闭防火墙并设置开机不启动(生 ...

  7. Linux 基于官网快速安装zabbix5.0图文教程

    基于官网快速安装zabbix5.0图文教程 前言 1选择下载zabbix的版本和配置 访问官网下载地址 2.安装和配置zabbix 安装zabbix资源库 安装Zabbix server,Web前端, ...

  8. Linux 安装Zabbix5.0超详细教程

    linux 安装Zabbix5.0教程 一.安装环境准备 1.操作系统Centos7.9 2.机器准备 3.关闭防火墙(两台): 4.zabbix数据流向 二.zabbix-server安装(服务端) ...

  9. Centos7.2安装 zabbix5.0

    目录 一.准备工作 1.1.下载安装包 1.2.配置yum和epel源 1.3.关闭防火墙(后续开启防火墙,然后放开端口测试) 1.4    jdk的安装配置 1.4.1.解压安装包 1.4.2.环境 ...

最新文章

  1. 夸克浏览器有没有linux,夸克浏览器怎么样?夸克浏览器使用说明
  2. (转)C# Delegate.Invoke、Delegate.BeginInvoke
  3. URL生成方式性能优化结果
  4. JEECG-P3首个开源插件诞生!CMS网站插件 Jeecg-p3-biz-cms1.0版本发布!
  5. 深度学习(六十二)SqueezeNet网络设计思想笔记
  6. 中国连续纤维毡行业市场供需与战略研究报告
  7. idea ssm打war包_使用idea新建springBoot+Gradle项目(超详细)
  8. android8.1 audio hal关键结构分析(二十五)
  9. ADO.NET:C#/SQL Server
  10. python 发送邮件附件csv_python给指定csv表格中的联系人群发邮件(带附件的邮件)
  11. 魔兽三界血歌鸿蒙武器怎么合成,《伏魔战记》关于武器材料出处以及合成以及对一些武器的使用心的...
  12. 集体建设用地审批程序:
  13. 【前端框架】Element UI Dialog 组件中执行 DOM 操作异常问题的分析与处理
  14. 【if语句与表达式】
  15. Echarts——中国地图绘制
  16. 物联网设备数据流转之数据何时存储:Spring事件及监听机制, 数据入库
  17. 亲测五种高效实用的脱单方法,赶紧收藏帮你快速找到优质对象!
  18. 如何为linux kernel贡献代码
  19. Java面试宝典(问题史上最全,总结最好)
  20. Photoshop安装错误:无法写入注册表值。请检查权限。解决的办法居然是居然是居然是卸载到2345看图王

热门文章

  1. Double类型出现的nan问题
  2. 转贴:iMac上安装雪豹、Win 7双系统
  3. URL链接转二维码图片
  4. 社群运营的本质是什么?
  5. linux 设备树及节点引用
  6. Java编写:输入出租车公里数,输出应付的车费数:(收费标准如下:3000米以下为8元,每超过500米增加1.2元,不足500米按500米计算。)
  7. 在Google Maps中更改”我的位置按钮“的位置
  8. RK3568平台开发系列讲解(设备驱动篇)内核空间与用户空间数据交互实验
  9. 小程序组件中的监听事件
  10. PCIE Feature ----- SRIOV