zabbix安装配置.docx
《zabbix安装配置.docx》由会员分享,可在线阅读,更多相关《zabbix安装配置.docx(15页珍藏版)》请在冰豆网上搜索。
zabbix安装配置
Zabbix
一安装配置:
环境搭建:
ØVMware®Workstation12Pro(12.0.0build-2985596)
ØCentOS-7-x86_64-DVD-1511.iso(user:
rootpassword:
toor00)
Øzabbix-3.0.3.tar
安装过程:
Installationfromsources
YoucangettheverylatestversionofZabbixbycompilingitfromthesources.
Astep-by-steptutorialforinstallingZabbixfromthesourcesisprovidedhere.
1InstallingZabbixdaemons
1Downloadthesourcearchive
GototheZabbixdownloadpageanddownloadthesourcearchive.Oncedownloaded,extractthesources,byrunning:
$tar-zxvfzabbix-3.0.0.tar.gz
EnterthecorrectZabbixversioninthecommand.Itmustmatchthenameofthedownloadedarchive.
2Createuseraccount
ForalloftheZabbixdaemonprocesses,anunprivilegeduserisrequired.IfaZabbixdaemonisstartedfromanunprivilegeduseraccount,itwillrunasthatuser.
However,ifadaemonisstartedfroma'root'account,itwillswitchtoa'zabbix'useraccount,whichmustbepresent.Tocreatesuchauseraccount(initsowngroup,“zabbix”)onLinuxsystems,run:
groupaddzabbix
useradd-gzabbixzabbix
AseparateuseraccountisnotrequiredforZabbixfrontendinstallation.
IfZabbixserverandagentarerunonthesamemachineitisrecommendedtouseadifferentuserforrunningtheserverthanforrunningtheagent.Otherwise,ifbotharerunasthesameuser,theagentcanaccesstheserverconfigurationfileandanyAdminleveluserinZabbixcanquiteeasilyretrieve,forexample,thedatabasepassword.
RunningZabbixasroot,bin,oranyotheraccountwithspecialrightsisasecurityrisk.
3CreateZabbixdatabase
ForZabbixserverandproxydaemons,aswellasZabbixfrontend,adatabaseisrequired.ItisnotneededtorunZabbixagent.
SQLscriptsareprovidedforcreatingdatabaseschemaandinsertingthedataset.ZabbixproxydatabaseneedsonlytheschemawhileZabbixserverdatabaserequiresalsothedatasetontopoftheschema.
HavingcreatedaZabbixdatabase,proceedtothefollowingstepsofcompilingZabbix.
4Configurethesources
WhenconfiguringthesourcesforaZabbixserverorproxy,youmustspecifythedatabasetypetobeused.Onlyonedatabasetypecanbecompiledwithaserverorproxyprocessatatime.
Toseeallofthesupportedconfigurationoptions,insidetheextractedZabbixsourcedirectoryrun:
./configure--help
ToconfigurethesourcesforaZabbixserverandagent,youmayrunsomethinglike:
./configure--enable-server--enable-agent--with-mysql--enable-ipv6--with-net-snmp--with-libcurl--with-libxml2
ac_default_prefix=/usr/local
ac_default_prefix=/usr/local/bin
--with-libcurlconfigurationoptionwithcURL7.20.0orhigherisrequiredforSMTPauthentication,supportedsinceZabbix3.0.0.
--with-libcurland--with-libxml2configurationoptionsarerequiredforvirtualmachinemonitoring,supportedsinceZabbix2.2.0.
ToconfigurethesourcesforaZabbixserver(withPostgreSQLetc.),youmayrun:
./configure--enable-server--with-postgresql--with-net-snmp
ToconfigurethesourcesforaZabbixproxy(withSQLiteetc.),youmayrun:
./configure--prefix=/usr--enable-proxy--with-net-snmp--with-sqlite3--with-ssh2
ToconfigurethesourcesforaZabbixagent,youmayrun:
./configure--enable-agent
Youmayusethe--enable-staticflagtostaticallylinklibraries.Ifyouplantodistributecompiledbinariesamongdifferentservers,youmustusethisflagtomakethesebinariesworkwithoutrequiredlibraries.Notethat--enable-staticdoesnotworkunderSolaris.
Using--enable-staticoptionisnotrecommendedwhenbuildingserver.
Inordertobuildtheserverstaticallyyoumusthaveastaticversionofeveryexternallibraryneeded.Thereisnostrictcheckforthatinconfigurescript.
Command-lineutilitieszabbix_getandzabbix_senderarecompiledif--enable-agentoptionisused.
Use--with-ibm-db2flagtospecifylocationoftheCLIAPI.
Use--with-oracleflagtospecifylocationoftheOCIAPI.
ForencryptionsupportseeCompilingZabbixwithencryptionsupport
5Makeandinstalleverything
IfinstallingfromSVN,itisrequiredtorunfirst:
$makedbschema
makeinstall
Thisstepshouldberunasauserwithsufficientpermissions(commonly'root',orbyusingsudo).
Runningmakeinstallwillbydefaultinstallthedaemonbinaries(zabbix_server,zabbix_agentd,zabbix_proxy)in/usr/local/sbinandtheclientbinaries(zabbix_get,zabbix_sender)in/usr/local/bin.
Tospecifyadifferentlocationthan/usr/local,usea--prefixkeyinthepreviousstepofconfiguringsources,forexample--prefix=/home/zabbix.Inthiscasedaemonbinarieswillbeinstalledunder/sbin,whileutilitiesunder/bin.Manpageswillbeinstalledunder/share.
6Reviewandeditconfigurationfiles
edittheZabbixagentconfigurationfile/usr/local/etc/zabbix_agentd.conf
Youneedtoconfigurethisfileforeveryhostwithzabbix_agentdinstalled.
YoumustspecifytheZabbixserverIPaddressinthefile.Connectionsfromotherhostswillbedenied.
edittheZabbixserverconfigurationfile/usr/local/etc/zabbix_server.conf
Youmustspecifythedatabasename,userandpassword(ifusingany).
WithSQLitethefullpathtodatabasefilemustbespecified;DBuserandpasswordarenotrequired.
Therestoftheparameterswillsuityouwith
theirdefaultsifyouhaveasmallinstallation(uptotenmonitoredhosts).YoushouldchangethedefaultparametersifyouwanttomaximizetheperformanceofZabbixserver(orproxy)though.Seetheperformancetuningsectionformoredetails.
ifyouhaveinstalledaZabbixproxy,edittheproxyconfigurationfile/usr/local/etc/zabbix_proxy.conf
YoumustspecifytheserverIPaddressandproxyhostname(mustbeknowntotheserver),aswellasthedatabasename,userandpassword(ifusingany).
WithSQLitethefullpathtodatabasefilemustbespecified;DBuserandpasswordarenotrequired.
7Startupthedaemons
Runzabbix_serverontheserverside.
shell>zabbix_server
Makesurethatyoursystemallowsallocationof36MB(orabitmore)ofsharedmemory,otherwisetheservermaynotstartandyouwillsee“Cannotallocatesharedmemoryfor.”intheserverlogfile.ThismayhappenonFreeBSD,Solaris8.
Seethe"Seealso"sectionatthebottomofthispagetofindouthowtoconfiguresharedmemory.
Runzabbix_agentdonallthemonitoredmachines.
shell>zabbix_agentd
Makesurethatyoursystemallowsallocationof2MBofsharedmemory,otherwisetheagentmaynotstartandyouwillsee“Cannotallocatesharedmemoryforcollector.”intheagentlogfile.ThismayhappenonSolaris8.
IfyouhaveinstalledZabbixproxy,runzabbix_proxy.
shell>zabbix_proxy
2InstallingZabbixwebinterface
CopyingPHPfiles
ZabbixfrontendiswritteninPHP,sotorunitaPHPsupportedwebserverisneeded.InstallationisdonebysimplycopyingthePHPfilesfromfrontends/phptothewebserverHTMLdocumentsdirectory.
CommonlocationsofHTMLdocumentsdirectoriesforApachewebserversinclude:
/usr/local/apache2/htdocs(defaultdirectorywheninstallingApachefromsource)
/srv/www/htdocs(OpenSUSE,SLES)
/var/www/html(Fedora,RHEL,CentOS)
/var/www(Debian,Ubuntu)
ItissuggestedtouseasubdirectoryinsteadoftheHTMLroot.TocreateasubdirectoryandcopyZabbixfrontendfilesintoit,executethefollowingcommands,replacingtheactualdirectory:
mkdir/zabbix
cdfrontends/php
cp-a./zabbix
IfinstallingfromSVNandplanningtouseanyotherlanguagethanEnglish,youmustgeneratetranslationfiles.Todoso,run:
locale/make_mo.sh
msgfmtutilityfromgettextpackageisrequired.
Additionally,touseanyotherlanguagethanEnglish,itslocaleshouldbeinstalledonthewebserver.Seethe"Seealso"sectioninthe“Userprofile”pagetofindouthowtoinstallitifrequired.
Installingfrontend
Step1
Inyourbrowser,openZabbixURL:
Youshouldseethefirstscreenofthefrontendinstallationwizard.
Step2
Makesurethatallsoftwareprerequisitesaremet.
通过修改/etc/php.ini
post_max_size=16M
max_execution_time=300
max_input_time=300
date.timezone=PRC
post_max_size=32M
时区问题:
修改php.ini文件,查找;date.timezone=,把前面的分号去掉在“=”后面加上时区。
比如:
Asia/Chongqing(重庆),Asia/Shanghai(上海),Asia/Urumqi(乌鲁木齐),Asia/Macao(澳门),Asia/Hong_Kong(香港),Asia/Taipei(台北),PRC
例
;date.timezone=
改成:
date.timezone=Asia/Shanghai
Pre-requisite
Minimumvalue
Description
PHPversion
5.4.0
PHPmemory_limitoption
128MB
Inphp.ini:
memory_limit=128M
PHPpost_max_sizeoption
16MB
Inphp.ini:
post_max_size=16M
PHPupload_max_filesizeoption
2MB
Inphp.ini:
upload_max_filesize=2M
PHPmax_execution_timeoption
300seconds(values0and-1areallowed)
Inphp.ini:
max_execution_time=300
PHPmax_input_timeoption
300seconds(values0and-1areallowed)
Inphp.ini:
max_input_time=300
PHPsession.auto_startoption
mustbedisabled
Inphp.ini:
session.auto_start=0
Databasesupport
Oneof:
IBMDB2,MySQL,Oracle,PostgreSQL,SQLite
Oneofthefollowingmodulesmustbeinstalled:
ibm_db2,mysql,oci8,pgsql,sqlite3
bcmath
php-bcmath
mbstring
php-mbstring
PHPmbstring.func_overloadoption
mustbedisabled
Inphp.ini:
mbstring.func_overload=0
PHPalways_populate_raw_post_dataoption
mustbedisabled
RequiredonlyforPHPversions5.6.0ornewer.
Inphp.ini:
always_populate_raw_post_data=-1
sockets
php-net-socket.Requiredforuserscriptsupport.
gd
2.0orhigher
php-gd.PHPGDextensionmustsupportPNGimages(--with-png-dir),JPEG(--with-jpeg-dir)imagesandFreeType2(--with-freetype-dir).
libxml
2.6.1