CentOS 7以yum方式安装zabbix3.2及配置文件详解

前端之家收集整理的这篇文章主要介绍了CentOS 7以yum方式安装zabbix3.2及配置文件详解前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、zabbix简介与环境准备

简介详见 ---> zabbix简介


环境准备: CentOS 7(node7):zabbix-server,web,MysqL,agent

mariadb:5.5.50

zabbix组件:3.2.1

apache:2.4.6


二、安装与配置


1、安装数据库(mariadb),可直接yum安装

[root@node7~]#vim/etc/yum.repos.d/MariaDB.repo
[mariadb]
name=MariaDB
baseurl=http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
[root@node7~]#yum-yinstallMariaDB-clientMariaDB-serverMariaDB-devel

2、配置数据库

2.1 配置数据库配置文件

[root@node7~]#vim/etc/my.cnf
innodb_file_per_table=1
skip_name_resolve=1

2.2 创建zabbix库并授权普通用户远程访问

[root@node7~]#systemctlstartmariadb
[root@node7~]#MysqL-e"grantallon*.*to'root'@'localhost'identifiedby'root';"
[root@node7~]#MysqL-uroot-proot
WelcometotheMariaDBmonitor.Commandsendwith;or\g.
YourMariaDBconnectionidis18
Serverversion:5.5.50-MariaDBMariaDBServer

Copyright(c)2000,2016,Oracle,MariaDBCorporationAbandothers.

Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.

MariaDB[(none)]>createdatabasezabbixcharactersetutf8collateutf8_bin;
QueryOK,0rowsaffected(0.43sec)

MariaDB[(none)]>grantallonzabbix.*tozabbix@localhostidentifiedby'zabbix';
QueryOK,0rowsaffected(0.00sec)

MariaDB[(none)]>grantallonzabbix.*tozabbix@192.168.1.20identifiedby'zabbix';
QueryOK,0rowsaffected(0.00sec)

MariaDB[(none)]>flushprivileges;
QueryOK,0rowsaffected(0.00sec)

MariaDB[(none)]>\q
Bye


3、安装zabbix

3.1 创建zabbix用户与组(普通用户

[root@node7~]#groupaddzabbix
[root@node7~]#useradd-gzabbixzabbix

3.2 使用yum方式安装zabbix

[root@node7~]#rpm-ivh
[root@node7~]#yumcleanall
[root@node7~]#yummakecache
[root@node7~]#yuminstallzabbixzabbix-serverzabbix-server-MysqLzabbix-webzabbix-agentzabbix-senderzabbix-getzabbix-web-MysqL

3.3 将zabbix数据导入数据库

[root@node7~]#zcat/usr/share/doc/zabbix-server-MysqL-3.2.1/create.sql|MysqL-uzabbix-pzabbixzabbix

3.4 查看导入数据,并测试zabbix用户远程登录

[root@node7~]#MysqL-uzabbix-pzabbix
WelcometotheMariaDBmonitor.Commandsendwith;or\g.
YourMariaDBconnectionidis21
Serverversion:5.5.50-MariaDBMariaDBServer

Copyright(c)2000,MariaDBCorporationAbandothers.

Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.

MariaDB[(none)]>showdatabases;
+--------------------+
|Database|
+--------------------+
|information_schema|
|test|
|zabbix|
+--------------------+
3rowsinset(0.00sec)

MariaDB[(none)]>usezabbix
Readingtableinformationforcompletionoftableandcolumnnames
Youcanturnoffthisfeaturetogetaquickerstartupwith-A

Databasechanged
MariaDB[zabbix]>showtables;
127rowsinset(0.00sec)

MariaDB[zabbix]>\q
Bye

3.5 配置zabbix-server

[root@node7~]#vim/etc/zabbix/zabbix_server.conf
##日志文件
LogFile=/var/log/zabbix/zabbix_server.log
##定义日志文件大小,到达上限即开始滚动
LogFileSize=0
##Pid文件
PidFile=/var/run/zabbix/zabbix_server.pid
##数据库地址
DBHost=localhost,192.168.1.20,127.0.0.1,##数据库名
DBName=zabbix
##zabbix登录数据库所用用户名
DBUser=zabbix
##登录数据库的密码
DBPassword=zabbix
##MysqL.sock文件路径
#DBSocket=/tmp/MysqL.sock此处路径为编译安装时路径
DBSocket=/var/lib/MysqL/MysqL.sock
##数据库监听的端口
#DBPort=3306

3.6 zabbix-server高级配置详解

1、server端拉取agent端的items,开启的空闲数默认为5
###Option:StartPollers
#Numberofpre-forkedinstancesofpollers.
#
#Mandatory:no
#Range:0-1000
#Default:
#StartPollers=5
2、硬件级别的监控,默认启动空闲为0
###Option:StartIPMIPollers
#Numberofpre-forkedinstancesofIPMIpollers.
#
#Mandatory:no
#Range:0-1000
#Default:
#StartIPMIPollers=0
3、对不可达主机拉取数据
###Option:StartPollersUnreachable
#arestarted.
#
#Mandatory:no
#Range:0-1000
#Default:
#StartPollersUnreachable=1
4、陷阱机制,即对于中途加入的主机主动发送的数据进行保存,陷阱池默认为5个
###Option:StartTrappers
#Numberofpre-forkedinstancesoftrappers.
#inthefrontend.
#
#Mandatory:no
#Range:0-1000
#Default:
#StartTrappers=5
5、使用ICMP协议的ping对网络中主机进行在线状态检测
###Option:StartPingers
#Numberofpre-forkedinstancesofICMPpingers.
#
#Mandatory:no
#Range:0-1000
#Default:
#StartPingers=1
6、对网络中的主机ping主动扫描发现,对中途加入的主机进行上线。注意:主动发现很消耗带宽
###Option:StartDiscoverers
#Numberofpre-forkedinstancesofdiscoverers.
#
#Mandatory:no
#Range:0-250
#Default:
#StartDiscoverers=1
7、使用http协议请求网页资源,探测主机web服务是否正常
###Option:StartHTTPPollers
#Numberofpre-forkedinstancesofHTTPpollers.
#
#Mandatory:no
#Range:0-1000
#Default:
#StartHTTPPollers=1
8、对时序有关的监控项计时
###Option:StartTimers
#Numberofpre-forkedinstancesoftimers.
#Timersprocesstime-basedtriggerfunctionsandmaintenanceperiods.
#Onlythefirsttimerprocesshandlesthemaintenanceperiods.
#
#Mandatory:no
#Range:1-1000
#Default:
#StartTimers=1
9、
###Option:StartEscalators
#Numberofpre-forkedinstancesofescalators.
#
#Mandatory:no
#Range:0-100
#Default:
#StartEscalators=1
10、监控java虚拟机
###Option:JavaGateway
#IPaddress(orhostname)ofZabbixJavagateway.
#OnlyrequiredifJavapollersarestarted.
#
#Mandatory:no
#Default:
#JavaGateway=
11、监控java开启的端口
###Option:JavaGatewayPort
#PortthatZabbixJavagatewaylistenson.
#
#Mandatory:no
#Range:1024-32767
#Default:
#JavaGatewayPort=10052
12、server端拉取jdk的数据
###Option:StartJavaPollers
#Numberofpre-forkedinstancesofJavapollers.
#
#Mandatory:no
#Range:0-1000
#Default:
#StartJavaPollers=0
13、监控VMware虚拟机的各项参数
###Option:StartVMwareCollectors
#Numberofpre-forkedvmwarecollectorinstances.
#
#Mandatory:no
#Range:0-250
#Default:
#StartVMwareCollectors=0
14、监控VMware虚拟机的频率,默认60秒
###Option:VMwareFrequency
#HowoftenZabbixwillconnecttoVMwareservicetoobtainanewdata.
#
#Mandatory:no
#Range:10-86400
#Default:
#VMwareFrequency=60
15、监控VMware的服务
###Option:VMwarePerfFrequency
#HowoftenZabbixwillconnecttoVMwareservicetoobtainperformancedata.
#
#Mandatory:no
#Range:10-86400
#Default:
#VMwarePerfFrequency=60
16、监控VMware的内存使用
###Option:VMwareCacheSize
#SizeofVMwarecache,inbytes.
#SharedmemorysizeforstoringVMwaredata.
#OnlyusedifVMwarecollectorsarestarted.
#
#Mandatory:no
#Range:256K-2G
#Default:
#VMwareCacheSize=8M
17、VMware的超时时间
###Option:VMwareTimeout
#
#Mandatory:no
#Range:1-300
#Default:
#VMwareTimeout=10
18、SNMP日志文件路径
###Option:SNMPTrapperFile
#TemporaryfileusedforpassingdatafromSNMPtrapdaemontotheserver.
#Mustbethesameasinzabbix_trap_receiver.plorSNMPTTconfigurationfile.
#
#Mandatory:no
#Default:
#SNMPTrapperFile=/tmp/zabbix_traps.tmp

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
19、SNMP协议的陷阱机制,同上
###Option:StartSNMPTrapper
#If1,SNMPtrapperprocessisstarted.
#
#Mandatory:no
#Range:0-1
#Default:
#StartSNMPTrapper=0
20、SNMP监听地址
###Option:ListenIP
#ListofcommadelimitedIPaddressesthatthetrappershouldlistenon.
#Trapperwilllistenonallnetworkinterfacesifthisparameterismissing.
#
#Mandatory:no
#Default:
#ListenIP=0.0.0.0

#ListenIP=127.0.0.1
21、从数据库中移除过期数据
###Option:HousekeepingFrequency
#HowoftenZabbixwillperformhousekeepingprocedure(inhours).
#Housekeepingisremovingoutdatedinformationfromthedatabase.
#
#Mandatory:no
#Range:0-24
#Default:
#HousekeepingFrequency=1
22、将上一项中的每一项任务删除
###Option:MaxHousekeeperDelete
#[housekeeperid],[tablename],[field],[value].
#willbedeletedperonetaskinonehousekeepingcycle.
#
#Mandatory:no
#Range:0-1000000
#Default:
#MaxHousekeeperDelete=5000
23、对尚未发送的报警信息30秒重发送一次
###Option:SenderFrequency
#HowoftenZabbixwilltrytosendunsentalerts(inseconds).
#
#Mandatory:no
#Range:5-3600
#Default:
#SenderFrequency=30
24、配置缓存大小
###Option:CacheSize
#Sizeofconfigurationcache,inbytes.
#Sharedmemorysizeforstoringhost,itemandtriggerdata.
#
#Mandatory:no
#Range:128K-8G
#Default:
#CacheSize=8M
25、缓存刷新时间
###Option:CacheUpdateFrequency
#HowoftenZabbixwillperformupdateofconfigurationcache,inseconds.
#
#Mandatory:no
#Range:1-3600
#Default:
#CacheUpdateFrequency=60
26、数据库同步实例数
###Option:StartDBSyncers
#Numberofpre-forkedinstancesofDBSyncers.
#
#Mandatory:no
#Range:1-100
#Default:
#StartDBSyncers=4
27、定义缓存的历史数据大小
###Option:HistoryCacheSize
#Sizeofhistorycache,inbytes.
#Sharedmemorysizeforstoringhistorydata.
#
#Mandatory:no
#Range:128K-2G
#Default:
#HistoryCacheSize=16M
28、历史表单的缓存数据大小
###Option:HistoryIndexCacheSize
#Sizeofhistoryindexcache,inbytes.
#Sharedmemorysizeforindexinghistorycache.
#
#Mandatory:no
#Range:128K-2G
#Default:
#HistoryIndexCacheSize=4M
29、趋势数据缓存大小
###Option:TrendCacheSize
#
#Mandatory:no
#Range:128K-2G
#Default:
#TrendCacheSize=4M
30、用于缓存历史数据的大小,0为禁用
###Option:ValueCacheSize
#Sizeofhistoryvaluecache,inbytes.
#Sharedmemorysizeforcachingitemhistorydatarequests.
#Settingto0disablesvaluecache.
#
#Mandatory:no
#Range:0,128K-64G
#Default:
#ValueCacheSize=8M
31、定义超时时间
###Option:Timeout
#
#Mandatory:no
#Range:1-30
#Default:
#Timeout=3
Timeout=4

32、陷阱机制的超时时间
###Option:TrapperTimeout
#Specifieshowmanysecondstrappermayspendprocessingnewdata.
#
#Mandatory:no
#Range:1-300
#Default:
#TrapperTimeout=300
33、定义主机不可达的超时时间
###Option:UnreachablePeriod
#Afterhowmanysecondsofunreachabilitytreatahostasunavailable.
#
#Mandatory:no
#Range:1-3600
#Default:
#UnreachablePeriod=45
34、在主机不可用期间,定期检查主机的时间
###Option:UnavailableDelay
#Howoftenhostischeckedforavailabilityduringtheunavailabilityperiod,inseconds.
#Mandatory:no
#Range:1-3600
#Default:
#UnavailableDelay=60
35、在主机被监控期间检查的时间
###Option:UnreachableDelay
#Howoftenhostischeckedforavailabilityduringtheunreachabilityperiod,inseconds.
#Mandatory:no
#Range:1-3600
#Default:
#UnreachableDelay=15
36、自定义报警脚本的路径,默认值取决于编译选项
###Option:AlertScriptsPath
#Fullpathtolocationofcustomalertscripts.
#Defaultdependsoncompilationoptions.
#
#Mandatory:no
#Default:
#AlertScriptsPath=${datadir}/zabbix/alertscripts

AlertScriptsPath=/usr/lib/zabbix/alertscripts
37、外部脚本的路径,默认值取决于编译选项
###Option:ExternalScripts
#Fullpathtolocationofexternalscripts.
#Defaultdependsoncompilationoptions.
#
#Mandatory:no
#Default:
#ExternalScripts=${datadir}/zabbix/externalscripts

ExternalScripts=/usr/lib/zabbix/externalscripts
38、执行ping检查时fping命令路径,fping可并行执行
###Option:FpingLocation
#Locationoffping.
#MakesurethatfpingbinaryhasrootownershipandSUIDflagset.
#
#Mandatory:no
#Default:
#FpingLocation=/usr/sbin/fping
39、V6
###Option:Fping6Location
#Locationoffping6.
#Makesurethatfping6binaryhasrootownershipandSUIDflagset.
#MakeemptyifyourfpingutilityiscapabletoprocessIPv6addresses.
#
#Mandatory:no
#Default:
#Fping6Location=/usr/sbin/fping6
40、使用密钥为SSH登录认证
###Option:SSHKeyLocation
#Locationofpublicandprivatekeysfo@R_301_470@Hchecksandactions.
#
#Mandatory:no
#Default:
#SSHKeyLocation=
41、数据库查询时间,0为不登录慢速查询
###Option:LogSlowQueries
#Howlongadatabasequerymaytakebeforebeinglogged(inmilliseconds).
#OnlyworksifDebugLevelsetto3,4or5.
#0-don'tlogslowqueries.
#
#Mandatory:no
#Range:1-3600000
#Default:
#LogSlowQueries=0

LogSlowQueries=3000
42、临时目录
###Option:TmpDir
#Temporarydirectory.
#
#Mandatory:no
#Default:
#TmpDir=/tmp
43、代理服务器拉取数据
###Option:StartProxyPollers
#Numberofpre-forkedinstancesofpollersforpassiveproxies.
#
#Mandatory:no
#Range:0-250
#Default:
#StartProxyPollers=1
44、用于被动模式的proxy,由sercer端发送配置信息
###Option:ProxyConfigFrequency
#HowoftenZabbixServersendsconfigurationdatatoaZabbixProxyinseconds.
#Thisparameterisusedonlyforproxiesinthepassivemode.
#
#Mandatory:no
#Range:1-3600*24*7
#Default:
#ProxyConfigFrequency=3600
45、用于被动模式的proxy,由sercer端拉取数据
###Option:ProxyDataFrequency
#HowoftenZabbixServerrequestshistorydatafromaZabbixProxyinseconds.
#Thisparameterisusedonlyforproxiesinthepassivemode.
#
#Mandatory:no
#Range:1-3600
#Default:
#ProxyDataFrequency=1
46、禁止root用户运行zabbix,0为禁止
###Option:AllowRoot
#Allowtheservertorunas'root'.Ifdisabledandtheserverisstartedby'root',theserver
#willtrytoswitchtotheuserspecifiedbytheUserconfigurationoptioninstead.
#Hasnoeffectifstartedunderaregularuser.
#0-donotallow
#1-allow
#
#Mandatory:no
#Default:
#AllowRoot=0
47、禁止root用户后使用的普通用户
###Option:User
#Dropprivilegestoaspecific,existinguseronthesystem.
#Onlyhaseffectifrunas'root'andAllowRootisdisabled.
#
#Mandatory:no
#Default:
#User=zabbix
48、yum安装zabbix时创建的目录
###Option:Include
#Youmayincludeindividualfilesorallfilesinadirectoryintheconfigurationfile.
#InstallingZabbixwillcreateincludedirectoryin/usr/local/etc,unlessmodifiedduringthecompiletime.
#
#Mandatory:no
#Default:
#Include=

#Include=/usr/local/etc/zabbix_server.general.conf
#Include=/usr/local/etc/zabbix_server.conf.d/
#Include=/usr/local/etc/zabbix_server.conf.d/*.conf
49、web监测时所用SSL协议证书路径
###Option:SSLCertLocation
#LocationofSSLclientcertificates.
#Thisparameterisusedonlyinwebmonitoring.
#
#Mandatory:no
#Default:
#SSLCertLocation=${datadir}/zabbix/ssl/certs
50、web监测时所用SSL协议密钥路径
###Option:SSLKeyLocation
#Locationofprivatekeysfo@R_301_470@Lclientcertificates.
#Thisparameterisusedonlyinwebmonitoring.
#
#Mandatory:no
#Default:
#SSLKeyLocation=${datadir}/zabbix/ssl/keys
51、web监测或SMTP身份认证
###Option:SSLCALocation
#Ifnotset,system-widedirectorywillbeused.
#ThisparameterisusedonlyinwebmonitoringandSMTPauthentication.
#
#Mandatory:no
#Default:
#SSLCALocation=

#######LOADABLEMODULES#######
52、模块路径
###Option:LoadModulePath
#Fullpathtolocationofservermodules.
#Defaultdependsoncompilationoptions.
#
#Mandatory:no
#Default:
#LoadModulePath=${libdir}/modules
53、模块支持库的路径
###Option:LoadModule
#Format:LoadModule=<module.so>
#ThemodulesmustbelocatedindirectoryspecifiedbyLoadModulePath.
#ItisallowedtoincludemultipleLoadModuleparameters.
#
#Mandatory:no
#Default:
#LoadModule=
54、CA证书的路径
###Option:TLSCAFile
#Fullpathnameofafilecontainingthetop-levelCA(s)certificatesfor
#peercertificateverification.
#
#Mandatory:no
#Default:
#TLSCAFile=
55、吊销证书的路径
###Option:TLSCRLFile
#Fullpathnameofafilecontainingrevokedcertificates.
#
#Mandatory:no
#Default:
#TLSCRLFile=
56、服务器证书文件
###Option:TLSCertFile
#Fullpathnameofafilecontainingtheservercertificateorcertificatechain.
#
#Mandatory:no
#Default:
#TLSCertFile=
57、服务器密钥文件
###Option:TLSKeyFile
#Fullpathnameofafilecontainingtheserverprivatekey.
#
#Mandatory:no
#Default:
#TLSKeyFile=

一般情况下,脚本路径可更改使用外,其余高级配置默认即可;如有需要,可自行更改配置。

3.7 启动zabbix-server

[root@node7~]#systemctlstartzabbix-server


4、配置PHP,并启动httpd服务

[root@node7~]#vim/etc/httpd/conf.d/zabbix.conf
PHP_valuedate.timezoneAsia/Shanghai

[root@node7~]#systemctlstarthttpd.service
此时确认iptanles规则放行或禁用,并关闭selinux


5、配置agent端,最少指出其server端地址,server端可配置多个

[root@node7~]#vim/etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1,192.168.1.20


6、登录web界面http://192.168.1.20/zabbix,初始用户名密码admin/zabbix,看到如下界面,即配置成功

6.1 配置zabbix-web连接数据库

wKiom1hEL1OB5IUiAAB_6hBH20w022.png-wh_50

6.2 成功登录

wKiom1hEMiTz6T5QAAGEF2sV0vc142.png-wh_50


如有错误,敬请指正。

猜你在找的CentOS相关文章