作为一个完全开源免费的企业级监控解决方案,Zabbix在IT基础监控、网络监控、Server监控和云监控等排名第一(PeerSpot)。
zabbix是一个监控软件,其可以监控各种网络参数,保证企业服务架构安全运营,同时支持灵活的告警机制,可以使得运维人员快速定位故障、解决问题。zabbix支持分布式功能,支持复杂架构下的监控解决方案,也支持web页面,为主机监控提供了良好直观的展现。
zabbix官网地址为,页面如下所示:
zabbix架构ZabbixServer:负责接收Agent发送的报告信息,组织所有配置、数据和操作。
DatabaseStorage:存储配置信息以及收集到的数据。
WebInterface:Zabbix的GUI接口,通常与Server运行在同一台机器上。
Proxy:可选组件,常用于分布式监控环境中。
Agent:部署在被监控主机上,负责收集数据发送给Server。
Zabbix的工作流程Agent获取被监控端数据,发送给Server。
Server记录所接收到的数据,存储在Database中并按照策略进行相应操作。
如果是分布式,Server会将数据传送一份到上级Server中。
WebInterface将收集到的数据和操作信息显示给用户。
Zabbix安装部署
Zabbix基础依赖程序安装安装步骤需要依次完成,包括以下步骤:
安装前准备
Apache2安装
PHP安装
该步骤使用安装文件包括:
安装前准备安装前准备包括以下安装步骤:
防火墙配置
RPM配置
专属用户创建
防火墙配置防火墙配置依次完成以下操作:
关闭防火墙
使用命令
执行顺序
命令
说明
1
systemctlstopfirewalld
关闭防火墙
执行示意
[root@fuwuqi01~]systemctldisablefirewalld
执行顺序
命令
说明
1
sed-i's/SELINUX=enforcing/SELINUX=disabled/g'/etc/selinux/config
关闭操作系统强制访问控制系统,禁用SELinux
关闭操作系统强制访问控制系统
执行示意
[root@fuwuqi01~]mount-tiso9660-oloop/tmp/_64-/mnt
创建_64-文件yum源文件配置
使用命令
执行顺序
命令
说明
1
vi/etc//
在/etc/文件目录下创建_64-文件的yum源配置文件
2
[RHEL76]
name=RHEL76
baseurl=file:///mnt
enabled=1
gpgcheck=0
yumlist
需要输入的内容
执行示意
[root@fuwuqi01~]yumcleanall
yuminstallmysql-develgccnet-snmp-develcurl-develperl-DBIlibxml2-develunixODBClibtoolgcc-c++bisonlibaio-develcmakelibnl*
Loadedplugins:langpacks,product-id,search-disabled-repos,subscription-
:manager
RHEL76|4.3kB00:00
(1/2):RHEL76/group_gz|146kB00:00
(2/2):RHEL76/primary_db|4.2MB00:00
_64alreadyinstalledandlatestversion
_64alreadyinstalledandlatestversion
_3.x86_64alreadyinstalledandlatestversion
Packagegcc-c++-4.8.5-36._64alreadyinstalledandlatestversion
_64alreadyinstalledandlatestversion
_64alreadyinstalledandlatestversion
_64alreadyinstalledandlatestversion
_64alreadyinstalledandlatestversion
ResolvingDepencies
--Runningtransactioncheck
---_640:2.8.12.2-2.el7willbeinstalled
---_640:0.3.109-13.el7willbeinstalled
---_640:7.29.0-51.el7willbeinstalled
RHEL76/filelists_db|3.4MB00:00
---_640:1.1.4-3.el7willbeinstalled
---_640:2.9.1-6.el7_2.3willbeinstalled
--ProcessingDepency:xz-develforpackage:_2.3.x86_64
--ProcessingDepency:zlib-develforpackage:_2.3.x86_64
---_641:5.5.60-1.el7_5willbeinstalled
--ProcessingDepency:openssl-devel(x86-64)forpackage:1:_5.x86_64
---_641:5.7.2-37.el7willbeinstalled
--ProcessingDepency:elfutils-develforpackage:1:_64
--ProcessingDepency:elfutils-libelf-develforpackage:1:_64
--ProcessingDepency:lm_sensors-develforpackage:1:_64
--ProcessingDepency:rpm-develforpackage:1:_64
--ProcessingDepency:tcp_wrappers-develforpackage:1:_64
---_640:2.3.1-11.el7willbeinstalled
--Runningtransactioncheck
---_640:0.172-2.el7willbeinstalled
---_640:0.172-2.el7willbeinstalled
---Packagelm__640:3.4.0-6.20160601
---_641:1.0.2
--ProcessingDepency:krb5-devel(x86-64)forpackage:1:_64
---_640:4.11.3-35.el7willbeinstalled
--ProcessingDepency:popt-devel(x86-64)forpackage:_64
---Packagetcp__640:7.6-77.el7willbeinstalled
---_640:5.2.2-1.el7willbeinstalled
---_640:1.2.7-18.el7willbeinstalled
--Runningtransactioncheck
---_640:1.15.1-34.el7willbeinstalled
--ProcessingDepency:keyutils-libs-develforpackage:_64
--ProcessingDepency:libcom_err-develforpackage:_64
--ProcessingDepency:libselinux-develforpackage:_64
--ProcessingDepency:libverto-develforpackage:_64
---_640:1.13-16.el7willbeinstalled
--Runningtransactioncheck
---_640:1.5.8-3.el7willbeinstalled
---Packagelibcom__640:1.42.9-13.el7willbeinstalled
---_640:2.5-14.1.el7willbeinstalled
--ProcessingDepency:libsepol-devel(x86-64)=2.5-10forpackage:_64
--ProcessingDepency:pkgconfig(libpcre)forpackage:_64
--ProcessingDepency:pkgconfig(libsepol)forpackage:_64
---_640:0.2.5-4.el7willbeinstalled
--Runningtransactioncheck
---_640:2.5-10.el7willbeinstalled
---_640:8.32-17.el7willbeinstalled
--FinishedDepencyResolution
DepenciesResolved
================================================================================
PackageArchVersionRepository
Size
================================================================================
Installing:
cmakex86_642.8.12.2-2.
libaio-develx86_640.3.109-13.el7RHEL7613k
libcurl-develx86_647.29.0-51.el7RHEL76302k
libnl-develx86_641.1.4-3.el7RHEL76621k
libxml2-develx86_642.9.1-6.el7_2.3
mariadb-develx86_641:5.5.60-1.el7_5RHEL76754k
net-snmp-develx86_641:5.7.2-37.el7RHEL76250k
unixODBCx86_642.3.1-11.el7RHEL76413k
Installingfordepencies:
elfutils-develx86_640.172-2.el7RHEL7687k
elfutils-libelf-develx86_640.172-2.el7RHEL7639k
keyutils-libs-develx86_641.5.8-3.el7RHEL7637k
krb5-develx86_641.15.1-34.el7RHEL76271k
libcom_err-develx86_641.42.9-13.el7RHEL7631k
libselinux-develx86_642.5-14.1.el7RHEL76187k
libsepol-develx86_642.5-10.el7RHEL7677k
libverto-develx86_640.2.5-4.el7RHEL7612k
lm_sensors-develx86_643.4.0-6.20160601
openssl-develx86_641:1.0.2
pcre-develx86_648.32-17.el7RHEL76480k
popt-develx86_641.13-16.el7RHEL7622k
rpm-develx86_644.11.3-35.el7RHEL76107k
tcp_wrappers-develx86_647.6-77.el7RHEL7617k
xz-develx86_645.2.2-1.el7RHEL7646k
zlib-develx86_641.2.7-18.el7RHEL7650k
TransactionSummary
================================================================================
Install8Packages(+16Depentpackages)
Totaldownloadsize:13M
Installedsize:56M
界面显示“Isthisok[y/d/N]:”时输入y然后回车,安装继续进行。
Isthisok[y/d/N]:y
Downloadingpackages:
--------------------------------------------------------------------------------
Total219MB/s|13MB00:00
Runningtransactioncheck
Runningtransactiontest
Transactiontestsucceeded
Runningtransaction
Installing:_641/24
Installing:_642/24
Installing:_643/24
Installing:_644/24
Installing:tcp__645/24
Installing:_646/24
Installing:_647/24
Installing:_648/24
Installing:_649/24
Installing:lm__6410/24
Installing:_6411/24
Installing:libcom__6412/24
Installing:_6413/24
Installing:_6414/24
Installing:_6415/24
Installing:1:_6416/24
Installing:1:_5.x86_6417/24
Installing:1:_6418/24
Installing:_2.3.x86_6419/24
Installing:_6420/24
Installing:_6421/24
Installing:_6422/24
Installing:_6423/24
Installing:_6424/24
RHEL76/productid|1.6kB00:00
Verifying:_641/24
Verifying:_2.3.x86_642/24
Verifying:_643/24
Verifying:libcom__644/24
Verifying:_645/24
Verifying:_646/24
Verifying:_647/24
Verifying:_648/24
Verifying:lm__649/24
Verifying:_6410/24
Verifying:1:_5.x86_6411/24
Verifying:_6412/24
Verifying:_6413/24
Verifying:_6414/24
Verifying:_6415/24
Verifying:_6416/24
Verifying:_6417/24
Verifying:_6418/24
Verifying:_6419/24
Verifying:_6420/24
Verifying:_6421/24
Verifying:tcp__6422/24
Verifying:1:_6423/24
Verifying:1:_6424/24
Installed:
_640:2.8.12.2-2._640:0.3.109-13.el7
_640:7.29.0-51._640:1.1.4-3.el7
_640:2.9.1-6.el7_2.3_641:5.5.60-1.el7_5
_641:5.7.2-37._640:2.3.1-11.el7
DepencyInstalled:
_640:0.172-2.el7
_640:0.172-2.el7
_640:1.5.8-3.el7
_640:1.15.1-34.el7
libcom__640:1.42.9-13.el7
_640:2.5-14.1.el7
_640:2.5-10.el7
_640:0.2.5-4.el7
lm__640:3.4.0-6.20160601
_641:1.0.2
_640:8.32-17.el7
_640:1.13-16.el7
_640:4.11.3-35.el7
tcp__640:7.6-77.el7
_640:5.2.2-1.el7
_640:1.2.7-18.el7
Complete!
界面显示Complete!表示安装完成。
依赖包ncurses-devel安装
使用命令
执行顺序
命令
说明
1
yuminstallncurses-devel
安装ncurses-devel
执行示意
[root@fuwuqi01~]groupaddphp-fdm
[root@fuwuqi01~]mkdir-p/tmp/plugin/apache_php
然后通过FTP方式上传、、、。
安装APR依赖APR依赖安装介质为,为Apache2依赖包,安装路径为/opt/zabbix/service/apr。
使用命令
执行顺序
命令
说明
1
cd/tmp/plugin/apache_php
进入/tmp/plugin/apache_php
2
解压
3
进入目录
4
./configure--prefix=/opt/zabbix/service/apr
带--prefix参数执行configure命令
5
makemakeinstall
执行编译并安装
执行示意
[root@fuwuqi01~]
[root@fuwuqi01apache_php]./configure--prefix=/opt/zabbix/service/apr
[root@]cd/tmp/plugin/apache_php
[root@fuwuqi01apache_php]
[root@]makemakeinstall
安装PCRE依赖PCRE依赖安装介质为,为Apache2依赖包,安装路径为/opt/zabbix/service/pcre。
使用命令
执行顺序
命令
说明
1
cd/tmp/plugin/apache_php
进入/tmp/plugin/apache_php
2
解压
3
进入目录
4
./configure--prefix=/opt/zabbix/service/pcre
带--prefix参数执行configure命令
5
makemakeinstall
执行编译并安装
执行示意
[root@fuwuqi01~]
[root@fuwuqi01apache_php]./configure--prefix=/opt/zabbix/service/pcre
[root@]yumremovehttpd-tools
[root@fuwuqi01~]cd/tmp/plugin/apache_php
[root@fuwuqi01apache_php]
[root@]makemakeinstall
修改Apache2配置Apache2配置文件,位于/opt/zabbix/apache/conf/,需要修改三处内容,具体如下:
修改主机名为localhost,访问端口号为80;添加ServerNamelocalhost:80、修改Listen为80,ServerName和Listen行首不能有任何字符。
使用命令
执行顺序
命令
说明
1
vi/opt/zabbix/apache/conf/
使用vi编辑文件
2
Listen80
ServerNamelocalhost:80
在修改为Listen80、添加ServerNamelocalhost:80
3
在所在行添加
执行示意
[root@fuwuqi01~]:80
Listen80
ServerNamegivesthenameandportthattheserverusestoidentifyitself.
itexplicitlytopreventproblemsduringstartup.
Ifyourhostdoesn'thavearegisteredDNSname,enteritsIPaddresshere.
isrequested.
/opt/zabbix/apache/bin/apachectlstart
apachectl接收参数为start、restart、stop分别对应启动、重启、停止。
成功验证
通过netstat命令查看在2.2.5.1中配置的Listen端口80是否存在,Apache2启动之后的进程名称为httpd。
使用命令
执行顺序
命令
说明
1
netstat-tnlp|grep80
查看80
执行示意
[root@fuwuqi01~]cp/opt/zabbix/apache/bin/apachectl/etc//httpd
编辑启动脚本,在ACMD=”$1”所在行的上一行增加description:Apache。
使用命令
执行顺序
命令
说明
1
vi/etc//httpd
编辑Apache2启动脚本
2
description:Apache
添加内容
执行示意
[root@fuwuqi01~]
description:Apache
ACMD="$1"
ARGV="$@"
添加随系统自启动。
使用命令
执行顺序
命令
说明
1
chkconfig--addhttpd
添加Apache2启动随系统启动
2
chkconfig--level12345httpdon
修改Apache2启动级别
执行示意
[root@fuwuqi01~]chkconfig--level12345httpdon
PHP安装本操作完成PHP安装,PHP安装需要依次完成:
安装前准备
安装JPEG6依赖
安装LIBpng依赖
安装Freetype依赖
安装Zlib依赖
安装GD依赖
安装依赖
安装PHP
安装介质包包括:、、、、、、,位于安装介质包的apache_php文件目录下。
PHP安装目录为/opt/zabbix/php
安装前准备在/tmp/plugin目录创建apache_php目录,用于临时存放安装介质。
使用命令
执行顺序
命令
说明
1
mkdir-p/tmp/plugin/apache_php
在/tmp/plugin下创建apache_php目录
执行示意
[root@fuwuqi01~]mkdir-p/opt/zabbix/service/jpeg6
[root@fuwuqi01~]mkdir-p/opt/zabbix/service/jpeg6/lib
[root@fuwuqi01~]mkdir-p/opt/zabbix/service/jpeg6/man
[root@fuwuqi01~]mkdir-p/opt/zabbix/service/jpeg6/man/man1
[root@fuwuqi01~]
[root@fuwuqi01apache_php]echo"y"|cp-rf/usr/share/libtool/config/
[root@fuwuqi01jpeg-6b]CFLAGS="-O3-fPIC"./configure--prefix=/opt/zabbix/service/jpeg6/--enable-shared--enable-static
[root@fuwuqi01jpeg-6b]cd/tmp/plugin/apache_php
[root@fuwuqi01apache_php]
[root@]-g-DPNG_DEBUG=5行修改为CFLAGS=-o3-fPIC-I$(ZLIBINC)-O-g-DPNG_DEBUG=5所在行的=号后-I$前添加
3
makemakeinstall
执行编译并安装
执行示意
[root@]Wherethezliblibraryandincludefilesarelocated
ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib
CC=cc
CFLAGS=-o3-fPIC-I$(ZLIBINC)-ORANLIB=echo
RANLIB=ranlib
[root@]cd/tmp/plugin/apache_php
[root@fuwuqi01apache_php]
[root@]makemakeinstall
在执行configure命令时输出“make:Nothingtobedonefor`unix'.”请忽略。
安装Zlib依赖Zlib依赖安装介质为,为PHP依赖包,安装路径为/opt/zabbix/service/zlib。
Zlib安装中需要在执行configure命令之后,手工修改Makefile文件。
Zlib执行configure
使用命令
执行顺序
命令
说明
1
cd/tmp/plugin/apache_php
进入/tmp/plugin/apache_php
2
解压
3
进入目录
4
./configure--prefix=/opt/zabbix/service/zlib
带--prefix参数执行configure命令
执行示意
[root@fuwuqi01~]
[root@fuwuqi01apache_php]./configure--prefix=/opt/zabbix/service/zlib
修改makefile文件,将CFLAGS=-O-D_LARGEFILE64_SOURCE=1修改为CFLAGS=-O3-fPIC-D_LARGEFILE64_SOURCE=1。确认无误后保存,执行编译并安装。
使用命令
执行顺序
命令
说明
1
viMakefile
编辑Makefile
2
3-fPIC
在CFLAGS所在行将-O替换为-O3-fPIC
3
makemakeinstall
执行编译并安装
执行示意
[root@]CFLAGS=-O-DMAX_WBITS=14-DMAX_MEM_LEVEL=7
CFLAGS=-O3-Wall-Wwrite-strings-Wpointer-arith-Wconversion\
makemakeinstall
安装GD依赖GD依赖安装介质为,为PHP依赖包,安装路径为/opt/zabbix/service/gd2。
使用命令
执行顺序
命令
说明
1
cd/tmp/plugin/apache_php
进入/tmp/plugin/apache_php
2
解压
3
进入目录
4
./configure--prefix=/opt/zabbix/service/gd2/--with-jpeg=/opt/zabbix/service/jpeg6/--with-png=/opt/zabbix/service/libpng/--with-zlib=/opt/zabbix/service/zlib/--with-freetype=/opt/zabbix/service/freetype/
带—prefix、--with-jpeg、--with-png、--with-zlib、--with-freetype参数执行configure命令
5
makemakeinstall
执行编译并安装
执行示意
[root@fuwuqi01~]
[root@fuwuqi01apache_php]./configure--prefix=/opt/zabbix/service/gd2/--with-jpeg=/opt/zabbix/service/jpeg6/--with-png=/opt/zabbix/service/libpng/--with-zlib=/opt/zabbix/service/zlib/--with-freetype=/opt/zabbix/service/freetype/
[root@]cd/tmp/plugin/apache_php
[root@fuwuqi01apache_php]
[root@]
[root@]cd/tmp/plugin/apache_php
[root@fuwuqi01apache_php]
[root@fuwuqi01apache_php]./configure--prefix=/opt/zabbix/php--with-mysql=/usr--with-mysqli=/usr/lib64/mysql/mysql_config--with-config-file-path=/opt/zabbix/php/etc--enable-fpm--with-fpm-user=php-fpm--with-fpm-group=php-fpm--with-libxml-dir--with-gd--with-jpeg-dir=/opt/zabbix/service/jpeg6--with-png-dir=/opt/zabbix/service/libpng/lib--with-freetype-dir=/opt/zabbix/service/freetype--with-iconv-dir--with-zlib-dir=/opt/zabbix/service/zlib--enable-soap--enable-gd-native-ttf--enable-ftp--enable-mbstring--enable-exif--disable-ipv6--with-pear--with-curl--enable-bcmath--enable-sockets--with-gettext--with-apxs2=/opt/zabbix/apache/bin/apxs
[root@]vi/opt/zabbix/apache/conf/
AddTypeapplication/
AddTypeapplication/
AddTypeapplication/
AddTypeapplication/
创建默认的PHP配置文件不能满足Zabbix运行要求,需要将安装介质的conf文件夹下以FTP方式上传到php的安装目录下的etc目录,php安装目录如果存在则替换。
安装介质中路径/plugin/conf。
所在目录为/opt/zabbix/php/etc。
配置环境变量需要在操作系统上添加PHP环境变量PHPRC,环境变量取值为/opt/zabbix/php/etc。
使用命令
执行顺序
命令
说明
1
cat/etc/profileeof
exportPHPRC=/opt/zabbix/php/etc
eof
cat环境变量配置文件
2
source/etc/profile
使配置文件生效
执行示意
[root@fuwuqi01~]source/etc/profile
重启Apache2重启Apache2,使章节2.3.8.2、2.3.8.2、2.3.8.3、2.3.8.4修改的配置生效。
使用命令
执行顺序
命令
说明
1
servicehttpdstop
停止Apache2
2
servicehttpdstart
启动Apache2
执行示意
[root@fuwuqi01~]servicehttpdstart
验证Apache2支持PHP验证Apache2支持PHP需要在Apache2的htdocs目录下新建一个名为的文件。
使用命令
执行顺序
命令
说明
1
cd/opt/zabbix/apache/htdocs
进入/opt/zabbix/apache/htdocs目录
2
新建一个文件
3
4
?phpecho"hellophp!"?
在输入?phpecho"hellophp!"?
在浏览器地址输入,如下图所有显示“hellophp!”字样标识Apache2支持PHP配置成功。
Zabbix服务程序安装
Zabbix服务程序安装需要依次完成:
修改操作系统参数
安装Zabbix服务程序依赖RPM包
添加Zabbix用户组及用户
安装Zabbix采集服务程序
初始化Zabbix数据库
Zabbix服务接口程序配置
Zabbix采集服务程序配置
ZabbixAgent安装
安装介质包包括:zabbix_agents_3.0.4_20191122.、、_64.rpm,位于安装介质包的zabbix文件目录下,预装配置文件在安装介质conf目录下,包括。其中_64.rpm是Zabbix程序依赖程序包。
Zabbix采集服务程序安装目录为/opt/zabbix/server。
Zabbix采集服务代理程序安装目录为/opt/zabbix/proxy。采集服务代理和采集服务部署一台设备。
ZabbixAgent安装目录为/opt/zabbix/agent。
修改操作系统参数运行cat/etc/security/依次输入。
*softnofile65535
*hardnofile65536
*softnproc65535
*hardnproc65536
eof
[root@fuwuqi01~]mount-tiso9660-oloop/tmp/_64-/mnt
创建_64-文件yum源文件配置
使用命令
执行顺序
命令
说明
1
vi/etc//
在/etc/文件目录下创建_64-文件的yum源配置文件
2
[RHEL76]
name=RHEL76
baseurl=file:///mnt
enabled=1
gpgcheck=0
yumlist
需要输入的内容
执行示意
[root@fuwuqi01~]yumcleanall
yuminstallOpenIPMI*libssh2*libcurlnet-snmp*mysql-devel-y
Loadedplugins:langpacks,product-id,search-disabled-repos,subscription-manager
RHEL76|4.3kB00:00:00
_64alreadyinstalledandlatestversion
_64alreadyinstalledandlatestversion
Package1:_64alreadyinstalledandlatestversion
Package1:_64alreadyinstalledandlatestversion
Package1:_64alreadyinstalledandlatestversion
Package1:_64alreadyinstalledandlatestversion
Package1:_64alreadyinstalledandlatestversion
Package1:_5.x86_64alreadyinstalledandlatestversion
ResolvingDepencies
--Runningtransactioncheck
---_640:2.0.23-2.el7willbeinstalled
---_640:2.0.23-2.el7willbeinstalled
---_640:2.0.23-2.el7willbeinstalled
---_640:2.0.23-2.el7willbeinstalled
--FinishedDepencyResolution
DepenciesResolved
=============================================================================================================================================================================================================================================
PackageArchVersionRepositorySize
=============================================================================================================================================================================================================================================
Installing:
OpenIPMIx86_642.0.23-2.el7RHEL76300k
OpenIPMI-libsx86_642.0.23-2.el7RHEL76521k
OpenIPMI-modaliasx86_642.0.23-2.el7RHEL7616k
OpenIPMI-perlx86_642.0.23-2.el7RHEL76167k
TransactionSummary
=============================================================================================================================================================================================================================================
Install4Packages
Totaldownloadsize:1.0M
Installedsize:3.2M
界面显示“Isthisok[y/d/N]:”时输入y然后回车,安装继续进行。
Downloadingpackages:
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total182MB/s|1.0MB00:00:00
Runningtransactioncheck
Runningtransactiontest
Transactiontestsucceeded
Runningtransaction
Installing:_641/4
Installing:_642/4
Installing:_643/4
Installing:_644/4
Verifying:_641/4
Verifying:_642/4
Verifying:_643/4
Verifying:_644/4
Installed:
_640:2.0.23-2._640:2.0.23-2._640:2.0.23-2._640:2.0.23-2.el7
Complete!
界面显示Complete!表示安装完成。
安装libevent-devel,FTP方式上传_64.rpm到/tmp/plugin/。
使用命令
执行顺序
命令
说明
1
cd/tmp/plugin/
进入/tmp/plugin目录
2
_64.rpm
执行_64.rpm安装
执行示意
[root@fuwuqi01~]_64.rpm
warning:_64.rpm:HeaderV3RSA/SHA256Signature,keyIDf4a80eb5:NOKEY
Preparing[100%]
[root@fuwuqi01plugin]groupaddzabbix
[root@fuwuqi01~]mkdir/tmp/plugin/conf
然后以通过FTP方式上传zabbix_agents_3.0.4_20191122.、至/tmp/plugin目录、至/tmp/plugin/conf。
安装Zabbix采集服务程序其一采集服务程序安装,安装目录为/opt/zabbix/server。
使用命令
执行顺序
命令
说明
1
cd/tmp/plugin/
进入/tmp/plugin/apache_php
2
解压
3
进入
4
./configure--prefix=/opt/zabbix/server--enable-server--enable-agent--with-mysql--with-net-snmp--with-libcurl--with-libxml2
带--prefix、--enable-server、--enable-agent、--with-mysql、--with-net-snmp、--with-libcurl、--with-libxml2参数执行configure命令
5
makemakeinstall
执行编译并安装
执行示意
[root@fuwuqi01~]
[root@fuwuqi01plugin]./configure--prefix=/opt/zabbix/server--enable-server--enable-agent--with-mysql--with-net-snmp--with-libcurl--with-libxml2
[root@]./configure--prefix=/opt/zabbix/proxy--enable-proxy--with-mysql--with-net-snmp--with-libcurl--with-libxml2
[root@]cd/usr/local/mysql/bin
[root@fuwuqi01bin]mkdir/opt/zabbix/apache/htdocs/zabbix
[root@fuwuqi01~]cp/opt/zabbix/apache/htdocs/zabbix/conf//opt/zabbix/apache/htdocs/zabbix/conf/
[root@localhost~]$HISTORY['url']=[
'text'='http://localhost:9200'
$HISTORY['types']=['uint','text'];
重启Apache2
修改Zabbix服务程序配置文件之后,需要重启Apache2,使用命令
执行顺序
命令
说明
1
servicehttpdstop
停止Apache2
2
servicehttpdstart
启动Apache2
执行示意
[root@fuwuqi01~]servicehttpdstart
访问验证
在浏览器地址栏输入,看到如下界面标识zabbix服务接口程序启动成功。
Zabbix采集服务程序配置修改Zabbix采集服务程序配置Zabbix采集服务程序安装完成之后,会自动生成Zabbix采集服务程序配置,该配置文件位于/opt/zabbix/server/etc/zabbix_。
使用命令
执行顺序
命令
说明
1
vi/opt/zabbix/server/etc/zabbix_
编辑Zabbix采集服务程序
2
DBHost=localhost
DBPort=3306
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
参数及参数值设置
3
cd/opt/zabbix/server/sbin
进入Zabbix采集服务程序sbin目录
4
./zabbix_server
启动Zabbix采集服务程序
执行示意
[root@fuwuqi01~]cd/opt/zabbix/server/sbin
[root@fuwuqi01etc]cp/tmp/plugin//misc//fedora/core/zabbix_server/etc//zabbix_server
[root@fuwuqi01~]Variables
Zabbix-Directory
BASEDIR=/opt/zabbix/server
添加随系统自启动:
使用命令
执行顺序
命令
说明
1
chkconfig--addzabbix_server
添加Zabbix采集服务程序启动随系统启动
2
chkconfig--level12345zabbix_serveron
修改Zabbix采集服务程序启动级别
执行示意
[root@fuwuqi01~]chkconfig--level12345zabbix_serveron
ZabbixAgent安装
注意事项所有需要被监控的服务器上安装ZabbixAgent。
务必修改被管设备名,设备同名将不会被纳管。
安装AgentAgent安装已经以fuwuqi01服务器为例,另外三台服务器请参照该安装操作。
以fuwuqi01为Zabbix服务采集程序安装服务器,其IP地址为。
FTP方式上传zabbix_agents_3.0.4_20191122.到/tmp/plugin/。ZabbixAgent安装需要明确带上Zabbix采集服务程序所在主机IP地址。
使用命令
执行顺序
命令
说明
1
cd/tmp/plugin/
进入/tmp/plugin目录
2
tar-zxfzabbix_agents_3.0.4_20191122.
解压zabbix_agents_3.0.4_20191122.
3
cdzabbix_agents_3.0.4/
进入zabbix_agents_3.0.4目录
4
./install_zabbix_
执行agent安装,为Zabbix采集服务程序所在服务器的IP地址
执行示意
[root@fuwuqi01~]tar-zxfzabbix_agents_3.0.4_20191122.
[root@fuwuqi01plugin]./install_zabbix_
启动AgentZabbixAgent安装之后会随操作系统启动,若由于误操作关闭了ZabbixAgent,可通过servicezabbix_agentdstart命令启动。
[root@fuwuqi01~]#servicezabbix_agentdstart
启动主从master_log_file和master_log_pos参数来自7.4.2记录的File和Position。
登录数据库之后执行“changemastertomaster_host='',master_user='repl',master_password='repl',master_log_file='',master_log_pos=3042;”。
使用命令
执行顺序
命令
说明
1
cd/usr/local/mysql/bin
进入MySQL安装目录的bin目录下
2
./mysql-uroot-p
启动MySQL客户端
3
password
输入root账号密码,进入MySQL命令行客户端。
4
changemastertomaster_host='',master_user='repl',master_password='repl',master_log_file='',master_log_pos=194;
查看Master状态
5
startslave;
启动主从同步
执行示意
MySQL[(none)]changemastertomaster_host='',master_user='repl',master_password='repl',master_log_file='',master_log_pos=3042;
MySQL[(none)]startslave;
登录数据库之后执行“changemastertomaster_host='',master_user='repl',master_password='repl',master_log_file='',master_log_pos=3842;”。
使用命令
执行顺序
命令
说明
1
cd/usr/local/mysql/bin
进入MySQL安装目录的bin目录下
2
./mysql-uroot-p
启动MySQL客户端
3
password
输入root账号密码,进入MySQL命令行客户端。
4
changemastertomaster_host='',master_user='repl',master_password='repl',master_log_file='',master_log_pos=194;
查看Master状态
5
startslave;
启动主从同步
执行示意
MySQL[(none)]changemastertomaster_host='',master_user='repl',master_password='repl',master_log_file='',master_log_pos=3842;
MySQL[(none)]startslave;
验证主从状态登录数据库执行命令showslavestatus\G;,查看Slave_IO_Running、Slave_SQL_Running是否为Yes,为Yes表示主从正常执行。
执行命令:
showslavestatus\G;
MySQL[(none)]showslavestatus\G;
***************************1.row***************************
Slave_IO_State:Waitingformastertosevent
Master_Host:
Master_User:repl
Master_Port:3306
Connect_Retry:60
Master_Log_File:
Read_Master_Log_Pos:3842
Relay_Log_File:
Relay_Log_Pos:764
Relay_Master_Log_File:
Slave_IO_Running:Yes
Slave_SQL_Running:Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:0
Last_Error:
Skip_Counter:0
Exec_Master_Log_Pos:3842
Relay_Log_Space:967
Until_Condition:None
Until_Log_File:
Until_Log_Pos:0
Master_SSL_Allowed:No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:0
Master_SSL_Verify_Server_Cert:No
Last_IO_Errno:0
Last_IO_Error:
Last_SQL_Errno:0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:10
Master_UUID:15aa5540-31fc-11ea-9d2d-84139f30d4bd
Master_Info_File:_master_info
SQL_Delay:0
SQL_Remaining_Delay:NULL
Slave_SQL_Running_State:Slavehasreadallrelaylog;waitingformoreupdates
Master_Retry_Count:86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:15aa5540-31fc-11ea-9d2d-84139f30d4bd:13-14
Executed_Gtid_Set:15aa5540-31fc-11ea-9d2d-84139f30d4bd:13-14,
4a871e1c-31eb-11ea-81b2-84139f30d4f5:1-15
Auto_Position:0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1rowinset(0.00sec)
ERROR:Noqueryspecified
MySQL[(none)]
登录数据库执行命令showslavestatus\G;,查看Slave_IO_Running、Slave_SQL_Running是否为Yes,为Yes表示主从正常执行。
MySQL[(none)]showslavestatus\G;
***************************1.row***************************
Slave_IO_State:Waitingformastertosevent
Master_Host:
Master_User:repl
Master_Port:3306
Connect_Retry:60
Master_Log_File:
Read_Master_Log_Pos:3842
Relay_Log_File:
Relay_Log_Pos:1025
Relay_Master_Log_File:
Slave_IO_Running:Yes
Slave_SQL_Running:Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:0
Last_Error:
Skip_Counter:0
Exec_Master_Log_Pos:3842
Relay_Log_Space:1228
Until_Condition:None
Until_Log_File:
Until_Log_Pos:0
Master_SSL_Allowed:No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:0
Master_SSL_Verify_Server_Cert:No
Last_IO_Errno:0
Last_IO_Error:
Last_SQL_Errno:0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:1
Master_UUID:4a871e1c-31eb-11ea-81b2-84139f30d4f5
Master_Info_File:_master_info
SQL_Delay:0
SQL_Remaining_Delay:NULL
Slave_SQL_Running_State:Slavehasreadallrelaylog;waitingformoreupdates
Master_Retry_Count:86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:4a871e1c-31eb-11ea-81b2-84139f30d4f5:13-15
Executed_Gtid_Set:15aa5540-31fc-11ea-9d2d-84139f30d4bd:1-14,
4a871e1c-31eb-11ea-81b2-84139f30d4f5:13-15
Auto_Position:0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1rowinset(0.00sec)
ERROR:
Noqueryspecified
MySQL[(none)]