大佬教程收集整理的这篇文章主要介绍了Linux下Zabbix5.0 LTS监控基础原理及安装部署(图文教程),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Zabbix 是什么?
Zabbix监控系统运行大概流程:
Zabbix由zabbix server与可选组件zabbix agent两部分组成。
那实际监控中是用主动的还是被动的呢?这里主要涉及两个地方:
Zabbix监控常用架构:
Zabbix官方站点:【文档、源码包、rpm包】下载提供了两种版本:LTS版(Long Term Support)和标准版。
Zabbix YUM安装部署过程如下:
属性 | Zabbix Server | Zabbix Client |
节点 | ZabbixServer-01 | ZabbixClient-01 |
系统 | CentOS Linux release 7.5.1804 (Minimal) | CentOS Linux release 7.5.1804 (Minimal) |
内核 | 3.10.0-862.el7.x86_64 | 3.10.0-862.el7.x86_64 |
SELinux | setenforce 0 | disabled | setenforce 0 | disabled |
Firewlld | systemctl stop/disable firewalld | systemctl stop/disable firewalld |
IP地址 | 172.16.70.37 |
172.16.70.171 |
# 准备环境 [root@ZabbixServer-01 ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (CorE) [root@ZabbixServer-01 ~]# uname -r 3.10.0-862.el7.x86_64 [root@ZabbixServer-01 ~]# setenforce 0 [root@ZabbixServer-01 ~]# sed -i '7s#enforcing#disabled#' /etc/selinux/config [root@ZabbixServer-01 ~]# systemctl stop firewalld && systemctl disable firewalld [root@ZabbixServer-01 ~]# yum install -y vim net-tools lsof wget curl lrzsz # 安装zabbix noarch.rpm [root@ZabbixServer-01 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rHel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm # 修改/etc/yum.repos.d/zabbix.repo,将[zabbix-frontend]下的enabled改为1【注意项】 [root@ZabbixServer-01 ~]# sed -i.bak '11s#enabled=0#enabled=1#' /etc/yum.repos.d/zabbix.repo [root@ZabbixServer-01 ~]# yum clean all [root@ZabbixServer-01 ~]# yum repolist | grep zabbix zabbix/x86_64 Zabbix Official Repository - x86_64 200 zabbix-frontend/x86_64 Zabbix Official Repository frontend - x86_64 183 zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x8 5 # 安装zabbix server和agent [root@ZabbixServer-01 ~]# yum install -y zabbix-server-mysql zabbix-agent # 安装Software Collections便于后续安装高版本的php [root@ZabbixServer-01 ~]# yum install -y centos-release-scl # 安装zabbix FE和相关环境 [root@ZabbixServer-01 ~]# yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl # 安装centos7默认的mariadb数据库 [root@ZabbixServer-01 ~]# yum install -y mariadb mariadb-server [root@ZabbixServer-01 ~]# systemctl start mariadb && systemctl enable mariadb # 安全初始化mariadb并配置root密码 [root@ZabbixServer-01 ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for nonE): # 空密码,直接回车 OK, successfully used password, moving on... SetTing the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] Y # 是否设置root密码 New password: # root密码 Re-enter new password: # 再次输入root密码 password updated successfully! Reloading privilege tables.. ... success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for tesTing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y # 是否删除匿名账号 ... success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cAnnot guess at the root password from the network. Disallow root login remotely? [Y/n] Y # 是否禁止root远程登录 ... success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for tesTing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y # 是否删除test库和test库的访问权限 - Dropping test database... ... success! - Removing privileges on test database... ... success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y # 是否刷新授权表使其立即生效 ... success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB! # 测试root登录,并授权 [root@ZabbixServer-01 ~]# mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 12 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. # 创建zabbix数据库 MariaDB [(nonE)]> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.00 seC) # 创建zabbix用户 MariaDB [(nonE)]> create user zabbix@localhost identified by 'zabbix@01'; Query OK, 0 rows affected (0.00 seC) # 授权zabbix权限 MariaDB [(nonE)]> grant all privileges on zabbix.* to zabbix@localhost; Query OK, 0 rows affected (0.00 seC) # 刷新授权,使其立即生效 MariaDB [(nonE)]> flush privileges; Query OK, 0 rows affected (0.00 seC) MariaDB [(nonE)]> exit Bye # 查看用户权限 MariaDB [(nonE)]> SELEct user,host,password from mysql.user; +--------+-----------+-------------------------------------------+ | user | host | password | +--------+-----------+-------------------------------------------+ | root | localhost | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF | | root | 127.0.0.1 | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF | | root | ::1 | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF | | zabbix | localhost | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF | +--------+-----------+-------------------------------------------+ 4 rows in set (0.00 seC) MariaDB [(nonE)]> show grants for zabbix@'localhost'; +---------------------------------------------------------------------------------------------------------------+ | Grants for zabbix@localhost | +---------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY passworD '*A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF' | | GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'localhost' | +---------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.01 seC) # 测试zabbix用户登录 [root@ZabbixServer-01 ~]# mysql -u zabbix -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 13 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)]> show grants for current_user(); +---------------------------------------------------------------------------------------------------------------+ | Grants for zabbix@localhost | +---------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY passworD '*A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF' | | GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix'@'localhost' | +---------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 seC) # 导入zabbix数据库,zabbix数据库用户为zabbix,密码为zabbix@01 [root@ZabbixServer-01 ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix # 编辑配置文件/etc/zabbix/zabbix_server.conf,设置数据库密码 [root@ZabbixServer-01 ~]# sed -i.bak '/# DBpassword=/aDBpassword=zabbix@01' /etc/zabbix/zabbix_server.conf # 编辑配置文件/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf,修改时区 [root@ZabbixServer-01 ~]# sed -i.bak '$c php_value[date.timezone] = Asia/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf # 重启服务并设置开启自启动 [root@ZabbixServer-01 ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm [root@ZabbixServer-01 ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm [root@ZabbixServer-01 ~]# netstat -nutpl | grep -E 'zabbix|mysql|php|http' tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2120/zabbix_agentd tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2127/zabbix_server tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2118/php-fpm: maste tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1991/mysqld tcP6 0 0 :::10050 :::* LISTEN 2120/zabbix_agentd tcP6 0 0 :::10051 :::* LISTEN 2127/zabbix_server tcP6 0 0 :::80 :::* LISTEN 2117/httpd [root@ZabbixServer-01 ~]# hostname -I 172.16.70.37 浏览器访问 http://172.16.70.37/zabbix
@H_176_197@
@H_869_262@
[root@ZabbixServer-01 ~]# cd /usr/share/zabbix/assets/fonts/ [root@ZabbixServer-01 fonts]# mv graphfont.ttf graphfont.ttf.bak [root@ZabbixServer-01 fonts]# rz # 上传粘贴在桌面文字 [root@ZabbixServer-01 fonts]# ls graphfont.ttf.bak simsun.ttc [root@ZabbixServer-01 fonts]# mv simsun.ttc simsun.ttf # 修改拓展名 [root@ZabbixServer-01 fonts]# ls graphfont.ttf.bak simsun.tt # 修改Zabbix的配置文件/usr/share/zabbix/include/defines.inc.php [root@ZabbixServer-01 ~]# sed -i.bak 's/graphfont/simsun/g' /usr/share/zabbix/include/defines.inc.php 解析:将下面两行graphfont改为simsun define('ZBX_GRAPH_FONt_name', 'graphfont'); // font file name define('ZBX_FONt_name', 'graphfont'); [root@ZabbixServer-01 ~]# systemctl restart zabbix-server
# 准备环境 [root@ZabbixClient-01 ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (CorE) [root@ZabbixClient-01 ~]# uname -r 3.10.0-862.el7.x86_64 [root@ZabbixClient-01 ~]# setenforce 0 [root@ZabbixClient-01 ~]# sed -i '7s#enforcing#disabled#' /etc/selinux/config [root@ZabbixClient-01 ~]# systemctl stop firewalld && systemctl disable firewalld [root@ZabbixClient-01 ~]# yum install -y vim net-tools lsof wget curl # 安装zabbix-agent/sender [root@ZabbixClient-01 ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rHel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm [root@ZabbixClient-01 ~]# yum install -y zabbix-agent zabbix-sender # 修改配置文件/etc/zabbix/zabbix_agentd.conf [root@ZabbixClient-01 ~]# sed -i.bak '117s/Server=127.0.0.1/Server=172.16.70.37/;158s/ServerActive=127.0.0.1/ServerActive=172.16.70.37/' /etc/zabbix/zabbix_agentd.conf [root@ZabbixClient-01 ~]#sed -i '169s/Hostname=Zabbix server/Hostname=ZabbixClient-01/' /etc/zabbix/zabbix_agentd.conf # 解析 Server=172.16.70.37 # Zabbix Server服务器IP(被动) ServerActive=172.16.70.37 # Zabbix Server服务器IP(主动) Hostname=ZabbixClient-01 # 本机能被server端识别的名称 # 启动服务 [root@ZabbixClient-01 ~]# systemctl start zabbix-agent [root@ZabbixClient-01 ~]# netstat -nuptl | grep zabbix tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 4839/zabbix_agentd tcP6 0 0 :::10050 :::* LISTEN 4839/zabbix_agentd [root@ZabbixClient-01 ~]# ps -ef |grep zabbix zabbix 4839 1 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf zabbix 4840 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec] zabbix 4841 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiTing for connection] zabbix 4842 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiTing for connection] zabbix 4843 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiTing for connection] zabbix 4844 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
以上是大佬教程为你收集整理的Linux下Zabbix5.0 LTS监控基础原理及安装部署(图文教程)全部内容,希望文章能够帮你解决Linux下Zabbix5.0 LTS监控基础原理及安装部署(图文教程)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。