IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> zabbix部署及监控 -> 正文阅读

[系统运维]zabbix部署及监控

一、部署zabbix服务

操作系统——RockyLinux8.6

配置国内yum源并备份原yum源

http://t.zoukankan.com/wswind-p-15469768.html
在这里插入图片描述

关闭防火墙和selinux
在这里插入图片描述

安装常用软件
[root@localhost ~]# yum install lrzsz wget vim net-tools tree psmisc bash-completion dos2unix -y

时间同步
[root@localhost ~]# yum install chrony -y
[root@localhost ~]# vim /etc/chrony.conf
[root@localhost ~]# systemctl restart chronyd
[root@localhost ~]# systemctl enable chronyd
[root@localhost ~]# chronyc sources
在这里插入图片描述
在这里插入图片描述

关机做快照
在这里插入图片描述

RPM包安装

1. 配置安装yum源

[root@localhost ~]# dnf localinstall https://repo.huaweicloud.com/zabbix/zabbix/5.4/rhel/8/x86_64/zabbix-release-5.4-1.el8.noarch.rpm
[root@localhost yum.repos.d]# vim zabbix.repo 
[root@localhost yum.repos.d]# cat zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://repo.zabbix.com/zabbix/5.4/rhel/8/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://repo.zabbix.com/non-supported/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

>>>>>>>>>>>>>>修改url<<<<<<<<<<<<<<
[root@localhost yum.repos.d]# sed -i 's#https://repo.zabbix.com#https://repo.huaweicloud.com/zabbix#' /etc/yum.repos.d/zabbix.repo
[root@localhost yum.repos.d]# cat zabbix.repo 
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://repo.huaweicloud.com/zabbix/zabbix/5.4/rhel/8/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://repo.huaweicloud.com/zabbix/non-supported/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1

2. 安装zabbix server

过滤查看zabbix
在这里插入图片描述

[root@localhost ~]# dnf install -y zabbix-server-mysql

3. 安装zabbix agent

[root@localhost ~]# dnf install -y zabbix-agent2

4. 安装zabbix web

[root@localhost ~]#  dnf install -y zabbix-web-mysql httpd zabbix-apache-conf zabbix-sql-scripts.noarch

5. 安装数据库

[root@localhost ~]# dnf install -y mariadb-server

6. 部署数据库

启动数据库
[root@localhost ~]# systemctl enable --now mariadb
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

-----------------------------------------------------
配置数据库
[root@localhost ~]# mysql -e "create database zabbix character set utf8 collate utf8_bin;"
[root@localhost ~]# mysql -e "create user 'zabbix'@'localhost' identified by 'zabbix';"
[root@localhost ~]# mysql -e "grant all privileges on zabbix.* to 'zabbix'@'localhost';"

[root@localhost ~]# mysql
mysql                       mysqld_multi                mysql_fix_extensions        mysql_setpermission
mysqlaccess                 mysqld_safe                 mysqlhotcopy                mysqlshow
mysqladmin                  mysqld_safe_helper          mysqlimport                 mysqlslap
mysqlbinlog                 mysqldump                   mysql_install_db            mysql_tzinfo_to_sql
mysqlcheck                  mysqldumpslow               mysql_plugin                mysql_upgrade
mysql_convert_table_format  mysql_find_rows             mysql_secure_installation   mysql_waitpid
[root@localhost ~]# 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
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!
后面的全选择YES
--------------------------------------------
登录数据库
[root@localhost ~]# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.3.32-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)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> \q
Bye
导入数据
[root@localhost ~]# rpm -ql zabbix-sql-scripts 
/usr/share/doc/zabbix-sql-scripts
/usr/share/doc/zabbix-sql-scripts/AUTHORS
/usr/share/doc/zabbix-sql-scripts/COPYING
/usr/share/doc/zabbix-sql-scripts/ChangeLog
/usr/share/doc/zabbix-sql-scripts/NEWS
/usr/share/doc/zabbix-sql-scripts/README
/usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz
/usr/share/doc/zabbix-sql-scripts/mysql/double.sql
/usr/share/doc/zabbix-sql-scripts/mysql/schema.sql.gz
/usr/share/doc/zabbix-sql-scripts/postgresql/create.sql.gz
/usr/share/doc/zabbix-sql-scripts/postgresql/double.sql
/usr/share/doc/zabbix-sql-scripts/postgresql/schema.sql.gz
/usr/share/doc/zabbix-sql-scripts/postgresql/timescaledb.sql.gz
/usr/share/doc/zabbix-sql-scripts/sqlite3/schema.sql.gz
[root@localhost ~]# cd /usr/share/doc/zabbix-sql-scripts/mysql/
[root@localhost mysql]# ll
total 2492
-rw-r--r-- 1 root root 2529922 Apr  4 20:17 create.sql.gz
-rw-r--r-- 1 root root     282 Apr  4 20:17 double.sql
-rw-r--r-- 1 root root   14827 Apr  4 20:17 schema.sql.gz

[root@localhost mysql]# zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbix -pzabbix zabbix
[root@localhost mysql]# mysql -uzabbix -pzabbix zabbix
MariaDB [zabbix]> show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
..........................
| valuemap_mapping           |
| widget                     |
| widget_field               |
+----------------------------+
166 rows in set (0.001 sec)

MariaDB [zabbix]> \q
Bye

7. 为zabbix server配置数据库

[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf

修改下两项即可
### Option: DBHost
#       Database host name.
#       If set to localhost, socket is used for MySQL.
#       If set to empty string, socket is used for PostgreSQL.
#       If set to empty string, the Net Service Name connection method is used to connect to Oracle database; also see
#       the TNS_ADMIN environment variable to specify the directory where the tnsnames.ora file is located.
#
# Mandatory: no
# Default:
DBHost=localhost

### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=zabbix

过滤查看
[root@localhost ~]# grep ^DB /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix


8.启动服务,web界面安装

[root@localhost ~]# systemctl enable --now httpd.service php-fpm.service zabbix-server.service zabbix-agent2.service
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-server.service → /usr/lib/systemd/system/zabbix-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent2.service → /usr/lib/systemd/system/zabbix-agent2.service.

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

[root@localhost ~]# ll /usr/share/zabbix/assets/fonts/
total 0
lrwxrwxrwx 1 root root 33 Jul 28 19:33 graphfont.ttf -> /etc/alternatives/zabbix-web-font
[root@localhost ~]# ll /etc/alternatives/zabbix-web-font
lrwxrwxrwx 1 root root 38 Jul 28 19:33 /etc/alternatives/zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttf
[root@localhost ~]# cd /usr/share/fonts/dejavu
进入本地电脑     C:\Windows\Fonts   本文用的 “仿宋 常规“  复制到桌面再用xshell传
[root@localhost dejavu]# rz -E
rz waiting to receive.

在这里插入图片描述

[root@localhost dejavu]# ll
total 15848
-rw-r--r-- 1 root root   641716 May 17  2015 DejaVuSans-BoldOblique.ttf
-rw-r--r-- 1 root root   704128 May 17  2015 DejaVuSans-Bold.ttf
-rw-r--r-- 1 root root   610260 May 17  2015 DejaVuSansCondensed-BoldOblique.ttf
-rw-r--r-- 1 root root   663468 May 17  2015 DejaVuSansCondensed-Bold.ttf
-rw-r--r-- 1 root root   597708 May 17  2015 DejaVuSansCondensed-Oblique.ttf
-rw-r--r-- 1 root root   679256 May 17  2015 DejaVuSansCondensed.ttf
-rw-r--r-- 1 root root   355204 May 17  2015 DejaVuSans-ExtraLight.ttf
-rw-r--r-- 1 root root   633836 May 17  2015 DejaVuSans-Oblique.ttf
-rw-r--r-- 1 root root   756072 May 17  2015 DejaVuSans.ttf
-rw-r--r-- 1 root root 10578152 Oct 15  2019 simfang.ttf
[root@localhost dejavu]# mv DejaVuSans.ttf{,.bak}
[root@localhost dejavu]# mv simfang.ttf DejaVuSans.ttf

在这里插入图片描述

二、安装zabbix-agent监控linux和windows。

监控linux

客户端

启用一台centos7

关闭防火墙和selinux
[root@localhost ~]# getenforce 
Disabled
[root@localhost ~]# firewall-cmd --state
not running

下载7版本的zabbix
[root@localhost ~]# yum localinstall https://repo.huaweicloud.com/zabbix/zabbix/5.4/rhel/7/x86_64/zabbix-agent2-5.4.0-8.el7.x86_64.rpm

[root@localhost ~]# vim /etc/zabbix/zabbix_agent2.conf
### Option: Server
#       List of comma delimited IP addresses, optionally in CIDR notation, or DNS names of Zabbix servers and Zabbix proxies.
#       Incoming connections will be accepted only from the hosts listed here.
#       If IPv6 support is enabled then '127.0.0.1', '::127.0.0.1', '::ffff:127.0.0.1' are treated equally
#       and '::/0' will allow any IPv4 or IPv6 address.
#       '0.0.0.0/0' can be used to allow any IPv4 address.
#       Example: Server=127.0.0.1,192.168.1.0/24,::1,2001:db8::/32,zabbix.example.com
#
# Mandatory: yes, if StartAgents is not explicitly set to 0
# Default:
# Server=

Server=192.168.43.116
-------------------------------------------------------------------------------------------------------------------------------------------------------------
### Option: ServerActive
#       List of comma delimited IP:port (or DNS name:port) pairs of Zabbix servers and Zabbix proxies for active checks.
#       If port is not specified, default port is used.
#       IPv6 addresses must be enclosed in square brackets if port for that host is specified.
#       If port is not specified, square brackets for IPv6 addresses are optional.
#       If this parameter is not specified, active checks are disabled.
#       Example: ServerActive=127.0.0.1:20051,zabbix.domain,[::1]:30051,::1,[12fc::1]
#
# Mandatory: no
# Default:
# ServerActive=

ServerActive=192.168.43.116
-------------------------------------------------------------------------------------------------------------------------------------------------------------
### Option: Hostname
#       List of comma delimited unique, case sensitive hostnames.
#       Required for active checks and must match hostnames as configured on the server.
#       Value is acquired from HostnameItem if undefined.
#
# Mandatory: no
# Default:
# Hostname=

Hostname=localhost

==========================================================================================
启动服务并设置为开机自起
[root@localhost ~]# systemctl enable --now zabbix-agent2.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent2.service to /usr/lib/systemd/system/zabbix-agent2.service.
[root@localhost ~]# netstat -lnupt | grep 10050
tcp6       0      0 :::10050                :::*                    LISTEN      1489/zabbix_agent2

服务端

[root@localhost ~]# dnf install zabbix-get.x86_64

在这里插入图片描述

监控windows

  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2022-08-06 11:16:52  更:2022-08-06 11:17:54 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/15 11:57:56-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码