监控服务zabbix部署

一、zabbix介绍

zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。

zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。

通知机制:

  • 邮件
  • 微信(公众号)
  • 短信
  • 电话
  • 人工
  • 声音

zabbix由2部分构成,zabbix server与可选组件zabbix agent(代理)。

zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Ubuntu,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。

zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。

zabbix server可以单独监视远程服务器的服务状态;同时也可以与zabbix agent配合,可以轮询zabbix agent主动接收监视数据(agent方式),同时还可被动接收zabbix agent发送的数据(trapping方式)。
另外zabbix server还支持SNMP (v1,v2),可以与SNMP软件(例如:net-snmp)等配合使用。

常用的监控软件:

  • cacti 擅长画图(流量图、架构图)
  • nagios 擅长报警,配置复杂
  • zabbix+grafana 结合了cacti和nagios的特点
  • prometheus 普罗米修斯

二、zabbix特点

zabbix的主要特点:

  • 安装与配置简单,学习成本低
  • 支持多语言(包括中文)
  • 免费开源
  • 自动发现服务器与网络设备 分
  • 布式监视以及WEB集中管理功能
  • 可以无agent监视
  • 用户安全认证和柔软的授权方式
  • 通过WEB界面设置或查看监视结果
  • email等通知功能

Zabbix主要功能:

  • CPU负荷
  • 内存使用
  • 磁盘使用
  • 网络状况
  • 端口监视
  • 日志监视

三、zabbix配置文件

zabbix配置文件有两种:

  • 服务器端配置文件(/usr/local/etc/zabbix_server.conf)
  • 客户端配置文件(/usr/local/etc/zabbix_agentd.conf)
  • zabbix代理配置文件(/usr/local/etc/zabbix_proxy.conf)

服务器端配置文件zabbix_server.conf常用配置参数:

参数作用
LogFile设置服务端日志文件存放路径
ListenIP设置服务端监听IP
ListenPort设置服务端监听的端口号
PidFile设置服务端进程号文件存放路径
DBHost指定zabbix的数据库服务器IP
DBName指定zabbix使用的数据库库名
DBUser指定zabbix数据库登录用户
DBPassword指定zabbix数据库登录密码
DBPort指定zabbix数据库端口号
User设置zabbix以什么用户的身份运行
AlertScriptsPath设置告警脚本存放路径
ExternalScripts外部脚本存放路径

客户端配置文件zabbix_agentd.conf常用配置参数:

参数作用
Server指定zabbix服务器的IP或域名
ServerActive指定zabbix服务器的IP或域名
Hostname指定本机的主机名,此项必须与web界面配置项一致
UnsafeUserParameters是否启用自定义监控项,可选值为{1
UserParameter指定自定义监控脚本参数
LogFile设置客户端日志文件存放路径

监控指标:

系统监控
内存、CPU、硬盘
网络监控
网卡、网络设备(路由器、交换机)
业务监控
进程、端口、日志
硬件监控(IPMI传感器)
数量、温度

四、部署zabbix

环境说明:

环境IP要安装的应用
服务器192.168.47.128lamp架构
zabbix server
zabbix agent
客户端192.168.47.129zabbix agent

因为zabbix是用php语言开发的,所以必须先部署lamp架构,使其能够支持运行php网页

安装httpd

//下载和解压httpd、apr以及apr-util
[root@localhost src]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.49.tar.gz
[root@localhost src]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-1.7.0.tar.gz
[root@localhost src]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
[root@localhost src]# tar xf httpd-2.4.49.tar.gz 
[root@localhost src]# tar xf apr-util-1.6.1.tar.gz 
[root@localhost src]# tar xf apr-1.7.0.tar.gz 
[root@localhost apr-1.7.0]# vim configure
31878     cfgfile=${ofile}T
31879     trap "$RM \"$cfgfile\"; exit 1" 1 2 15
31880     # $RM "$cfgfile"    将此行加上注释,或者删除此行
31881 
31882     cat <<_LT_EOF >> "$cfgfile"

// 安装EPEL rpm[root@localhost apr-1.7.0]# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
[root@localhost apr-1.7.0]# ls /etc/yum.repos.d/
epel-modular.repo     epel-testing-modular.repo  wjj.repo
epel-playground.repo  epel-testing.repo
epel.repo             redhat.repo
[root@localhost apr-1.7.0]# yum clean all    //清理缓存
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
33 文件已删除
[root@localhost apr-1.7.0]# yum makecache   //重新建立缓存
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Extra Packages for Enterprise Linux  563 kB/s | 955 kB     00:01    
Extra Packages for Enterprise Linux  616 kB/s |  10 MB     00:17    
BaseOS                               164 MB/s | 2.3 MB     00:00    
AppStream                            126 MB/s | 5.8 MB     00:00    
元数据缓存已建立。

// 安装开发工具包
[root@localhost apr-1.7.0]# yum groups mark install 'Development Tools' -y
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:01:26 前,执行于 2021年09月23日 星期四 17时49分10秒。
依赖关系解决。
=====================================================================
 软件包         架构          版本              仓库            大小
=====================================================================
安装组:
 Development Tools
                                                                    

事务概要
=====================================================================

完毕!

// 创建apache服务的用户和组
[root@localhost src]# useradd -r -M -s /sbin/nologin apache

// 安装依赖包
[root@localhost src]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make

// 编译安装apr-1.7.0、apr-util-1.6.1、httpd-2.4.49
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.7.0]# make && make install
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.6.1]# make && make install
[root@localhost httpd-2.4.49]# ./configure --prefix=/usr/local/apache \
> --enable-so \
> --enable-ssl \
> --enable-cgi \
> --enable-rewrite \
> --with-zlib \
> --with-pcre \
> --with-apr=/usr/local/apr/ \
> --with-apr-util=/usr/local/apr-util/ \
> --enable-modules=most \
> --enable-mpms-shared=all \
> --with-mpm=prefork
[root@localhost httpd-2.4.49]# make && make install

// 安装后配置
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@localhost ~]# source /etc/profile.d/httpd.sh 
[root@localhost ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
[root@localhost ~]# vim /etc/man_db.conf 
20 MANDATORY_MANPATH                       /usr/man
21 MANDATORY_MANPATH                       /usr/share/man
22 MANDATORY_MANPATH                       /usr/local/share/man
23 MANDATORY_MANPATH                       /usr/local/apache/man     // 把apache加进去

//取消ServerName前面的注释
[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf
203 ServerName www.example.com:80

//启动apache
[root@localhost ~]# apachectl start

// 配置开机自启
[root@localhost ~]# cp /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/httpd.service
[root@localhost ~]# vim /usr/lib/systemd/system/httpd.service
[root@localhost ~]# cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=Httpd server daemon
Documentation=man:httpd(8)
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecStop=/usr/local/apache/bin/apachectl stop
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
[root@localhost ~]# systemctl daemon-reload 
[root@localhost ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl status httpd.service 
● httpd.service - Httpd server daemon
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; v>
   Active: active (running) since Thu 2021-09-23 18:47:11 CST; 10s a>
     Docs: man:httpd(8)

安装mysql

// 安装依赖包
[root@localhost ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel

// 下载mysql软件包
[root@localhost src]# ls
apr-1.7.0              httpd-2.4.49
apr-1.7.0.tar.gz       httpd-2.4.49.tar.gz
apr-util-1.6.1         kernels
apr-util-1.6.1.tar.gz  mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
debug

//创建用户和组
[root@localhost ~]# useradd -r -M -s /sbin/nologin mysql

//解压软件至/usr/local/
[root@localhost src]# tar xf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# cd /usr/local/
[root@localhost local]# mv mysql-5.7.34-linux-glibc2.12-x86_64/ mysql

//修改目录/usr/local/mysql的属主属组
[root@localhost local]# chown -R mysql.mysql mysql/

//添加环境变量
[root@localhost ~]# echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost ~]# source /etc/profile.d/mysql.sh 
[root@localhost ~]# vim /etc/man_db.conf
20 MANDATORY_MANPATH                       /usr/man
21 MANDATORY_MANPATH                       /usr/share/man
22 MANDATORY_MANPATH                       /usr/local/share/man
23 MANDATORY_MANPATH                       /usr/local/apache/man
24 MANDATORY_MANPATH                       /usr/local/mysql/man      //把mysql加进去
[root@localhost ~]# ln -s /usr/local/mysql/include/ /usr/include/mysql/

// 写一个配置文件,告诉库文件lib在/usr/local/mysql下面
[root@localhost ~]# cat /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[root@localhost ~]# ldconfig 

//建立数据存放目录
[root@localhost ~]# ldconfig 
[root@localhost ~]# mkdir /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/

//初始化数据库
[root@localhost ~]# mysqld --initialize-insecure --user mysql --datadir /opt/data
2021-09-23T11:04:41.643189Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-09-23T11:04:41.799190Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-09-23T11:04:41.821815Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-09-23T11:04:41.875518Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 0d6341e8-1c5e-11ec-b0eb-000c29f6d306.
2021-09-23T11:04:41.876088Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-09-23T11:04:42.525643Z 0 [Warning] CA certificate ca.pem is self signed.
2021-09-23T11:04:42.602903Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

//配置mysql
[root@localhost ~]# cat /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve

//配置服务启动脚本
[root@localhost ~]# vim /usr/local/mysql/support-files/mysql.server
 46 basedir=/usr/local/mysql
 47 datadir=/opt/data
[root@localhost ~]# cp /usr/lib/systemd/system/httpd.service /usr/lib/systemd/system/mysqld.service
[root@localhost ~]# cat /usr/lib/systemd/system/mysqld.service
[Unit]
Description=mysql server daemon
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecStop=/usr/local/mysql/support-files/mysql.server stop
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

//启动mysql
[root@localhost ~]# systemctl daemon-reload 
[root@localhost ~]# systemctl enable --now mysqld.service
[root@localhost ~]# ss -antl
State   Recv-Q  Send-Q     Local Address:Port     Peer Address:Port  
LISTEN  0       80                     *:3306                *:*   
[root@localhost ~]# systemctl status mysqld.service 
● mysqld.service - mysql server daemon
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; >
   Active: active (running) since Thu 2021-09-23 19:14:13 CST; 13s a>
  Process: 673923 ExecStart=/usr/local/mysql/support-files/mysql.ser>
 Main PID: 673945 (mysqld_safe)

//修改密码
[root@localhost ~]# yum -y install ncurses-compat-libs
[root@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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> set password = password('wjj!');
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> exit
Bye

安装php

//安装依赖包
[root@localhost ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel openldap-devel  pcre-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel
[root@localhost ~]# yum -y install php-mysqlnd

// 在php.net网站上下载php软件包,然后传到/usr/src下面去,再解压
[root@localhost src]# ls
apr-1.7.0              httpd-2.4.49
apr-1.7.0.tar.gz       httpd-2.4.49.tar.gz
apr-util-1.6.1         kernels
apr-util-1.6.1.tar.gz  mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
debug                  php-7.4.24.tar.gz
[root@localhost src]# tar xf php-7.4.24.tar.gz

//编译安装php
// 先把oniguruma-6.9.4.tar.gz这个包从网上下载到本地,然后直接拉进/usr/src目录下面去,再去做下面操作
[root@localhost php-7.4.24]# yum -y install libsqlite3x-devel
[root@localhost src]# yum install autoconf automake libtool -y
[root@localhost src]# wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz  
[root@localhost src]# tar xf oniguruma-6.9.4.tar.gz  
[root@localhost src]# cd oniguruma-6.9.4/
[root@localhost oniguruma-6.9.4]# ./autogen.sh && ./configure --prefix=/usr
[root@localhost oniguruma-6.9.4]# make && make install
[root@localhost php-7.4.24]# yum -y install libzip-devel
[root@localhost php-7.4.24]# ./configure --prefix=/usr/local/php7  \
> --with-config-file-path=/etc \
> --enable-fpm \
> --disable-debug \
> --disable-rpath \
> --enable-shared \
> --enable-soap \
> --with-openssl \
> --enable-bcmath \
> --with-iconv \
> --with-bz2 \
> --enable-calendar \
> --with-curl \
> --enable-exif  \
> --enable-ftp \
> --enable-gd \
> --with-jpeg \
> --with-zlib-dir \
> --with-freetype \
> --with-gettext \
> --enable-mbstring \
> --enable-pdo \
> --with-mysqli=mysqlnd \
> --with-pdo-mysql=mysqlnd \
> --with-readline \
> --enable-shmop \
> --enable-simplexml \
> --enable-sockets \
> --with-zip \
> --enable-mysqlnd-compression-support \
> --with-pear \
> --enable-pcntl \
> --enable-posix
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.
[root@localhost php-7.4.24]# make && make install
//安装后配置
[root@localhost ~]# echo 'export PATH=/usr/local/php8/bin:$PATH' > /etc/profile.d/php.sh
[root@localhost ~]# source /etc/profile.d/php.sh 
[root@localhost php-7.4.24]# yum -y install php-cli
[root@localhost php-7.4.24]# php -v
PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
[root@localhost php-7.4.24]# which php
/usr/bin/php

//配置php-fpm
[root@localhost php-7.4.24]# cp php.ini-production /etc/php.ini 
cp:是否覆盖'/etc/php.ini'? y
[root@localhost php-7.4.24]# cd sapi/
[root@localhost sapi]# cp fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost sapi]# chmod +x /etc//init.d/php-fpm 
[root@localhost sapi]# cd
[root@localhost ~]# cd /usr/src/php-7.4.24/
[root@localhost php-7.4.24]# cd /usr/local/php7/
[root@localhost php7]# cd etc/
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# cd php-fpm.d/
[root@localhost php-fpm.d]# cp www.conf.default www.conf

//启动php-fpm
[root@localhost ~]# cp /usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/php-fpm.service
[root@localhost ~]# vim /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=php server daemon
After=network.target

[Service]
Type=forking
ExecStart=/etc/init.d/php-fpm start
ExecStop=/etc/init.d/php-fpm stop
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

[root@localhost ~]# systemctl daemon-reload 
[root@localhost ~]# systemctl enable --now php-fpm

配置apache

// 启用httpd的相关模块
[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf
119 #LoadModule remoteip_module modules/mod_remoteip.so
120 LoadModule proxy_module modules/mod_proxy.so   // 取消注释
121 #LoadModule proxy_connect_module modules/mod_proxy_connect.so
122 #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
123 #LoadModule proxy_http_module modules/mod_proxy_http.so
124 LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so      // 取消注释
125 #LoadModule proxy_scgi_module modules/mod_proxy_scgi.so

//创建虚拟主机目录并生成php测试页面
[root@localhost ~]# cd /usr/local/apache/
[root@localhost apache]# cd htdocs/
[root@localhost htdocs]# mkdir wjj
[root@localhost htdocs]# cat wjj/index.php
<?php
    phpinfo();
?>
[root@localhost apache]# chown -R apache.apache /usr/local/apache/htdocs/

[root@localhost apache]# vim conf/httpd.conf
//在配置文件的最后加入以下内容
514 <VirtualHost *:80>
515     DocumentRoot "/usr/local/apache/htdocs/wjj"
516     ServerName www.wjj.com
517     ProxyRequests Off
518     ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/a    pache/htdocs/wjj/$1
519     <Directory "/usr/local/apache/htdocs/wjj">
520         Options none
521         AllowOverride none
522         Require all granted
523     </Directory>

524 </VirtualHost>

//搜索AddType,添加以下内容
397     AddType application/x-compress .Z
398     AddType application/x-gzip .gz .tgz
399     AddType application/x-httpd-php .php     //把这一行内容添加进去
400     AddType application/x-httpd-php-source .phps    //把这一行内容添加进去

260 <IfModule dir_module>
261     DirectoryIndex index.php index.html    //加上index.php
262 </IfModule>

//重启apache服务
[root@localhost apache]# systemctl restart httpd.service

访问
在这里插入图片描述

1、zabbix服务端安装

//安装依赖包
[root@localhost ~]# yum -y install net-snmp-devel libevent-devel

//下载zabbix
[root@localhost ~]# cd /usr/src/
[root@localhost src]# ls
 apr-1.7.0               debug                 mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz    php-7.4.24
 apr-1.7.0.tar.gz        httpd-2.4.49          oniguruma-6.9.4                               php-7.4.24.tar.gz
 apr-util-1.6.1          httpd-2.4.49.tar.gz   oniguruma-6.9.4.tar.gz                        zabbix-5.4.4.tar.gz
 apr-util-1.6.1.tar.gz   kernels              'oniguruma-devel-6.8.2-2.el8.x86_64 (1).rpm'

//解压
[root@localhost src]# tar xf zabbix-5.4.4.tar.gz -C /usr/local/

//创建zabbix用户和组
[root@localhost ~]# useradd -r -M -s /sbin/nolong zabbix

//配置zabbix数据库
[root@localhost ~]# mysql -uroot -pwjj!
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.34 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.02 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!';
Query OK, 0 rows affected, 2 warnings (0.02 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)

mysql> quit
Bye

// 导入数据库
[root@localhost ~]# cd /usr/local/zabbix-5.4.4/database/mysql/
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.

//编译安装zabbix
[root@localhost mysql]# cd /usr/local/zabbix-5.4.4/
[root@localhost zabbix-5.4.4]# ./configure --enable-server \
> --enable-agent \
> --with-mysql \
> --with-net-snmp \
> --with-libcurl \
> --with-libxml2
······编译过程省略

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************

[root@localhost zabbix-5.4.4]# make install

2、zabbix服务端配置

[root@localhost zabbix-5.4.4]# ls /usr/local/etc/
zabbix_agentd.conf  zabbix_agentd.conf.d  zabbix_server.conf  zabbix_server.conf.d

//修改服务端配置文件
//设置数据库信息
[root@localhost zabbix-5.4.4]# vim /usr/local/etc/zabbix_server.conf
121 # Mandatory: no
122 # Default:
123 DBPassword=zabbix123! //取消注释,设置zabbix数据库连接密码

//启动zabbix_server和zabbix_agentd
[root@localhost ~]# mkdir /var/lib/mysql
[root@localhost ~]# ln -s /tmp/mysql.sock /var/lib/mysql/
[root@localhost ~]# zabbix_server
[root@localhost ~]# zabbix_agentd
[root@localhost ~]# ss -antl
State   Recv-Q  Send-Q   Local Address:Port      Peer Address:Port  
LISTEN  0       128            0.0.0.0:10050          0.0.0.0:*     
LISTEN  0       128            0.0.0.0:10051          0.0.0.0:*     
LISTEN  0       128          127.0.0.1:9000           0.0.0.0:*     
LISTEN  0       128            0.0.0.0:111            0.0.0.0:*     
LISTEN  0       128            0.0.0.0:80             0.0.0.0:*     
LISTEN  0       32       192.168.122.1:53             0.0.0.0:*     
LISTEN  0       128            0.0.0.0:22             0.0.0.0:*     
LISTEN  0       5            127.0.0.1:631            0.0.0.0:*     
LISTEN  0       80                   *:3306                 *:*     
LISTEN  0       128               [::]:111               [::]:*     
LISTEN  0       128               [::]:22                [::]:*     
LISTEN  0       5                [::1]:631               [::]:*   

3、zabbix服务端web界面安装与配置

zabbix web界面安装前配置

//修改/etc/php.ini的配置并重启php-fpm
[root@localhost ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@localhost ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@localhost ~]#  sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@localhost ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@localhost ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done

[root@localhost ~]# cd /usr/local/zabbix-5.4.4/
[root@localhost zabbix-5.4.4]# mkdir /usr/local/apache/htdocs/zabbix
[root@localhost zabbix-5.4.4]# cp ui/* /usr/local/apache/htdocs/zabbix/ -r
[root@localhost zabbix-5.4.4]# chown -R apache.apache /usr/local/apache/htdocs

//配置apache虚拟主机
[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf 
//在配置文件的末尾加如下内容
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/zabbix"
    ServerName zabbix.wjj.com
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
    <Directory "/usr/local/apache/htdocs/zabbix">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>

//设置zabbix/conf目录的权限,让zabbix有权限生成配置文件zabbix.conf.php
[root@localhost ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[root@localhost ~]#  apachectl -t
Syntax OK

//重启apache
[root@localhost ~]# apachectl stop
[root@localhost ~]# apachectl start
[root@localhost ~]# chmod 755 /usr/local/apache/htdocs/zabbix/conf

安装zabbix web界面

在浏览器上访问域名进行安装:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值