博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Zabbix 安装
阅读量:5086 次
发布时间:2019-06-13

本文共 20871 字,大约阅读时间需要 69 分钟。

 

 

 

安装文档

1 rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm 2 cd /etc/yum.repos.d/ 3 ls 4 vim zabbix.repo  5 vi zabbix.repo 6 yum install zabbix-server-mysql zabbix-web-mysql -y 7 cd 8 yum install mariadb-server -y 9 systemctl start mariadb10 systemctl enable mariadb11 netstat -lntup12 mysql_secure_installation 13 mysql14 mysql -uzabbix -pzabbix zabbix15 rpm -ql zabbix-server-mysql16 cd /usr/share/doc/zabbix-server-mysql-3.0.20/17 ls18 zcat create.sql.gz 19 zcat create.sql.gz |mysql -uzabbix -pzabbix zabbix20 mysql -uzabbix -p123456 zabbix -e "show tables;"21 vi /etc/zabbix/zabbix_server.conf 22 systemctl start zabbix-server23 systemctl status zabbix-server24 systemctl start httpd25 systemctl enable httpd26 vi /etc/httpd/conf.d/zabbix.conf 27 systemctl restart httpd

 

在数据库中进行配置

mysql -e 'create database zabbix character set utf8 collate utf8_bin;'mysql -e "grant all on zabbix.* to zabbix@localhost identified by 'zabbix';" #部分内容调整
sed -i 's#\# php_value date.timezone Europe/Riga#php_value date.timezone Asia/Shanghai#g' /etc/httpd/conf.d/zabbix.confroot@db01 create]# sed -i 's#\# php_value date.timezone Europe/Riga#php_value date.timezone Asia/Shanghai#g' /etc/httpd/conf.d/zabbix.confroot@db01 create]# grep Shanghai /etc/httpd/conf.d/zabbix.conf        php_value date.timezone Asia/Shanghai        1  初始化zabbixroot@db01 create]# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.oldboy.oriroot@db01 create]# sed -i 's@# DBPassword=@DBPassword=zabbix@g' /etc/zabbix/zabbix_server.conf[root@db01 create]# grep DBPassword= /etc/zabbix/zabbix_server.conf[root@db01 create]# sed -i 's@# DBHost=localhost@DBHost=localhost@g' /etc/zabbix/zabbix_server.conf

zabbix.repo有部分内容要修改

请参照

1 [zabbix] 2 name=Zabbix Official Repository - $basearch 3 baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.0/rhel/7/x86_64/ 4 enabled=1 5 gpgcheck=1 6 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX 7  8 [zabbix-non-supported] 9 name=Zabbix Official Repository non-supported - $basearch 10 baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/x86_64/11 enabled=112 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX13 gpgcheck=1
View Code

 

 

修改完毕的配置文件

1 # This is a configuration file for Zabbix server daemon  2 # To get more information about Zabbix, visit http://www.zabbix.com  3   4 ############ GENERAL PARAMETERS #################  5   6 ### Option: ListenPort  7 #    Listen port for trapper.  8 #  9 # Mandatory: no 10 # Range: 1024-32767 11 # Default: 12 # ListenPort=10051 13  14 ### Option: SourceIP 15 #    Source IP address for outgoing connections. 16 # 17 # Mandatory: no 18 # Default: 19 # SourceIP= 20  21 ### Option: LogType 22 #    Specifies where log messages are written to: 23 #        system  - syslog 24 #        file    - file specified with LogFile parameter 25 #        console - standard output 26 # 27 # Mandatory: no 28 # Default: 29 # LogType=file 30  31 ### Option: LogFile 32 #    Log file name for LogType 'file' parameter. 33 # 34 # Mandatory: no 35 # Default: 36 # LogFile= 37  38 LogFile=/var/log/zabbix/zabbix_server.log 39  40 ### Option: LogFileSize 41 #    Maximum size of log file in MB. 42 #    0 - disable automatic log rotation. 43 # 44 # Mandatory: no 45 # Range: 0-1024 46 # Default: 47 # LogFileSize=1 48  49 LogFileSize=0 50  51 ### Option: DebugLevel 52 #    Specifies debug level: 53 #    0 - basic information about starting and stopping of Zabbix processes 54 #    1 - critical information 55 #    2 - error information 56 #    3 - warnings 57 #    4 - for debugging (produces lots of information) 58 #    5 - extended debugging (produces even more information) 59 # 60 # Mandatory: no 61 # Range: 0-5 62 # Default: 63 # DebugLevel=3 64  65 ### Option: PidFile 66 #    Name of PID file. 67 # 68 # Mandatory: no 69 # Default: 70 # PidFile=/tmp/zabbix_server.pid 71  72 PidFile=/var/run/zabbix/zabbix_server.pid 73  74 ### Option: DBHost 75 #    Database host name. 76 #    If set to localhost, socket is used for MySQL. 77 #    If set to empty string, socket is used for PostgreSQL. 78 # 79 # Mandatory: no 80 # Default: 81 DBHost=localhost 82  83 ### Option: DBName 84 #    Database name. 85 #    For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored. 86 # 87 # Mandatory: yes 88 # Default: 89 # DBName= 90  91 DBName=zabbix 92  93 ### Option: DBSchema 94 #    Schema name. Used for IBM DB2 and PostgreSQL. 95 # 96 # Mandatory: no 97 # Default: 98 # DBSchema= 99 100 ### Option: DBUser101 #    Database user. Ignored for SQLite.102 #103 # Mandatory: no104 # Default:105 # DBUser=106 107 DBUser=zabbix108 109 ### Option: DBPassword110 #    Database password. Ignored for SQLite.111 #    Comment this line if no password is used.112 #113 # Mandatory: no114 # Default:115 DBPassword=zabbix116 117 ### Option: DBSocket118 #    Path to MySQL socket.119 #120 # Mandatory: no121 # Default:122 # DBSocket=/tmp/mysql.sock123 124 ### Option: DBPort125 #    Database port when not using local socket. Ignored for SQLite.126 #127 # Mandatory: no128 # Range: 1024-65535129 # Default (for MySQL):130 # DBPort=3306131 132 ############ ADVANCED PARAMETERS ################133 134 ### Option: StartPollers135 #    Number of pre-forked instances of pollers.136 #137 # Mandatory: no138 # Range: 0-1000139 # Default:140 # StartPollers=5141 142 ### Option: StartIPMIPollers143 #    Number of pre-forked instances of IPMI pollers.144 #145 # Mandatory: no146 # Range: 0-1000147 # Default:148 # StartIPMIPollers=0149 150 ### Option: StartPollersUnreachable151 #    Number of pre-forked instances of pollers for unreachable hosts (including IPMI and Java).152 #    At least one poller for unreachable hosts must be running if regular, IPMI or Java pollers153 #    are started.154 #155 # Mandatory: no156 # Range: 0-1000157 # Default:158 # StartPollersUnreachable=1159 160 ### Option: StartTrappers161 #    Number of pre-forked instances of trappers.162 #    Trappers accept incoming connections from Zabbix sender, active agents and active proxies.163 #    At least one trapper process must be running to display server availability and view queue164 #    in the frontend.165 #166 # Mandatory: no167 # Range: 0-1000168 # Default:169 # StartTrappers=5170 171 ### Option: StartPingers172 #    Number of pre-forked instances of ICMP pingers.173 #174 # Mandatory: no175 # Range: 0-1000176 # Default:177 # StartPingers=1178 179 ### Option: StartDiscoverers180 #    Number of pre-forked instances of discoverers.181 #182 # Mandatory: no183 # Range: 0-250184 # Default:185 # StartDiscoverers=1186 187 ### Option: StartHTTPPollers188 #    Number of pre-forked instances of HTTP pollers.189 #190 # Mandatory: no191 # Range: 0-1000192 # Default:193 # StartHTTPPollers=1194 195 ### Option: StartTimers196 #    Number of pre-forked instances of timers.197 #    Timers process time-based trigger functions and maintenance periods.198 #    Only the first timer process handles the maintenance periods.199 #200 # Mandatory: no201 # Range: 1-1000202 # Default:203 # StartTimers=1204 205 ### Option: StartEscalators206 #    Number of pre-forked instances of escalators.207 #208 # Mandatory: no209 # Range: 0-100210 # Default:211 # StartEscalators=1212 213 ### Option: JavaGateway214 #    IP address (or hostname) of Zabbix Java gateway.215 #    Only required if Java pollers are started.216 #217 # Mandatory: no218 # Default:219 # JavaGateway=220 221 ### Option: JavaGatewayPort222 #    Port that Zabbix Java gateway listens on.223 #224 # Mandatory: no225 # Range: 1024-32767226 # Default:227 # JavaGatewayPort=10052228 229 ### Option: StartJavaPollers230 #    Number of pre-forked instances of Java pollers.231 #232 # Mandatory: no233 # Range: 0-1000234 # Default:235 # StartJavaPollers=0236 237 ### Option: StartVMwareCollectors238 #    Number of pre-forked vmware collector instances.239 #240 # Mandatory: no241 # Range: 0-250242 # Default:243 # StartVMwareCollectors=0244 245 ### Option: VMwareFrequency246 #    How often Zabbix will connect to VMware service to obtain a new data.247 #248 # Mandatory: no249 # Range: 10-86400250 # Default:251 # VMwareFrequency=60252 253 ### Option: VMwarePerfFrequency254 #    How often Zabbix will connect to VMware service to obtain performance data.255 #256 # Mandatory: no257 # Range: 10-86400258 # Default:259 # VMwarePerfFrequency=60260 261 ### Option: VMwareCacheSize262 #    Size of VMware cache, in bytes.263 #    Shared memory size for storing VMware data.264 #    Only used if VMware collectors are started.265 #266 # Mandatory: no267 # Range: 256K-2G268 # Default:269 # VMwareCacheSize=8M270 271 ### Option: VMwareTimeout272 #    Specifies how many seconds vmware collector waits for response from VMware service.273 #274 # Mandatory: no275 # Range: 1-300276 # Default:277 # VMwareTimeout=10278 279 ### Option: SNMPTrapperFile280 #    Temporary file used for passing data from SNMP trap daemon to the server.281 #    Must be the same as in zabbix_trap_receiver.pl or SNMPTT configuration file.282 #283 # Mandatory: no284 # Default:285 # SNMPTrapperFile=/tmp/zabbix_traps.tmp286 287 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log288 289 ### Option: StartSNMPTrapper290 #    If 1, SNMP trapper process is started.291 #292 # Mandatory: no293 # Range: 0-1294 # Default:295 # StartSNMPTrapper=0296 297 ### Option: ListenIP298 #    List of comma delimited IP addresses that the trapper should listen on.299 #    Trapper will listen on all network interfaces if this parameter is missing.300 #301 # Mandatory: no302 # Default:303 # ListenIP=0.0.0.0304 305 # ListenIP=127.0.0.1306 307 ### Option: HousekeepingFrequency308 #    How often Zabbix will perform housekeeping procedure (in hours).309 #    Housekeeping is removing outdated information from the database.310 #    To prevent Housekeeper from being overloaded, no more than 4 times HousekeepingFrequency311 #    hours of outdated information are deleted in one housekeeping cycle, for each item.312 #    To lower load on server startup housekeeping is postponed for 30 minutes after server start.313 #    With HousekeepingFrequency=0 the housekeeper can be only executed using the runtime control option.314 #    In this case the period of outdated information deleted in one housekeeping cycle is 4 times the315 #    period since the last housekeeping cycle, but not less than 4 hours and not greater than 4 days.316 #317 # Mandatory: no318 # Range: 0-24319 # Default:320 # HousekeepingFrequency=1321 322 ### Option: MaxHousekeeperDelete323 #    The table "housekeeper" contains "tasks" for housekeeping procedure in the format:324 #    [housekeeperid], [tablename], [field], [value].325 #    No more than 'MaxHousekeeperDelete' rows (corresponding to [tablename], [field], [value])326 #    will be deleted per one task in one housekeeping cycle.327 #    SQLite3 does not use this parameter, deletes all corresponding rows without a limit.328 #    If set to 0 then no limit is used at all. In this case you must know what you are doing!329 #330 # Mandatory: no331 # Range: 0-1000000332 # Default:333 # MaxHousekeeperDelete=5000334 335 ### Option: SenderFrequency336 #    How often Zabbix will try to send unsent alerts (in seconds).337 #338 # Mandatory: no339 # Range: 5-3600340 # Default:341 # SenderFrequency=30342 343 ### Option: CacheSize344 #    Size of configuration cache, in bytes.345 #    Shared memory size for storing host, item and trigger data.346 #347 # Mandatory: no348 # Range: 128K-8G349 # Default:350 # CacheSize=8M351 352 ### Option: CacheUpdateFrequency353 #    How often Zabbix will perform update of configuration cache, in seconds.354 #355 # Mandatory: no356 # Range: 1-3600357 # Default:358 # CacheUpdateFrequency=60359 360 ### Option: StartDBSyncers361 #    Number of pre-forked instances of DB Syncers.362 #363 # Mandatory: no364 # Range: 1-100365 # Default:366 # StartDBSyncers=4367 368 ### Option: HistoryCacheSize369 #    Size of history cache, in bytes.370 #    Shared memory size for storing history data.371 #372 # Mandatory: no373 # Range: 128K-2G374 # Default:375 # HistoryCacheSize=16M376 377 ### Option: HistoryIndexCacheSize378 #    Size of history index cache, in bytes.379 #    Shared memory size for indexing history cache.380 #381 # Mandatory: no382 # Range: 128K-2G383 # Default:384 # HistoryIndexCacheSize=4M385 386 ### Option: TrendCacheSize387 #    Size of trend cache, in bytes.388 #    Shared memory size for storing trends data.389 #390 # Mandatory: no391 # Range: 128K-2G392 # Default:393 # TrendCacheSize=4M394 395 ### Option: ValueCacheSize396 #    Size of history value cache, in bytes.397 #    Shared memory size for caching item history data requests.398 #    Setting to 0 disables value cache.399 #400 # Mandatory: no401 # Range: 0,128K-64G402 # Default:403 # ValueCacheSize=8M404 405 ### Option: Timeout406 #    Specifies how long we wait for agent, SNMP device or external check (in seconds).407 #408 # Mandatory: no409 # Range: 1-30410 # Default:411 # Timeout=3412 413 Timeout=4414 415 ### Option: TrapperTimeout416 #    Specifies how many seconds trapper may spend processing new data.417 #418 # Mandatory: no419 # Range: 1-300420 # Default:421 # TrapperTimeout=300422 423 ### Option: UnreachablePeriod424 #    After how many seconds of unreachability treat a host as unavailable.425 #426 # Mandatory: no427 # Range: 1-3600428 # Default:429 # UnreachablePeriod=45430 431 ### Option: UnavailableDelay432 #    How often host is checked for availability during the unavailability period, in seconds.433 #434 # Mandatory: no435 # Range: 1-3600436 # Default:437 # UnavailableDelay=60438 439 ### Option: UnreachableDelay440 #    How often host is checked for availability during the unreachability period, in seconds.441 #442 # Mandatory: no443 # Range: 1-3600444 # Default:445 # UnreachableDelay=15446 447 ### Option: AlertScriptsPath448 #    Full path to location of custom alert scripts.449 #    Default depends on compilation options.450 #451 # Mandatory: no452 # Default:453 # AlertScriptsPath=${datadir}/zabbix/alertscripts454 455 AlertScriptsPath=/usr/lib/zabbix/alertscripts456 457 ### Option: ExternalScripts458 #    Full path to location of external scripts.459 #    Default depends on compilation options.460 #461 # Mandatory: no462 # Default:463 # ExternalScripts=${datadir}/zabbix/externalscripts464 465 ExternalScripts=/usr/lib/zabbix/externalscripts466 467 ### Option: FpingLocation468 #    Location of fping.469 #    Make sure that fping binary has root ownership and SUID flag set.470 #471 # Mandatory: no472 # Default:473 # FpingLocation=/usr/sbin/fping474 475 ### Option: Fping6Location476 #    Location of fping6.477 #    Make sure that fping6 binary has root ownership and SUID flag set.478 #    Make empty if your fping utility is capable to process IPv6 addresses.479 #480 # Mandatory: no481 # Default:482 # Fping6Location=/usr/sbin/fping6483 484 ### Option: SSHKeyLocation485 #    Location of public and private keys for SSH checks and actions.486 #487 # Mandatory: no488 # Default:489 # SSHKeyLocation=490 491 ### Option: LogSlowQueries492 #    How long a database query may take before being logged (in milliseconds).493 #    Only works if DebugLevel set to 3, 4 or 5.494 #    0 - don't log slow queries.495 #496 # Mandatory: no497 # Range: 1-3600000498 # Default:499 # LogSlowQueries=0500 501 LogSlowQueries=3000502 503 ### Option: TmpDir504 #    Temporary directory.505 #506 # Mandatory: no507 # Default:508 # TmpDir=/tmp509 510 ### Option: StartProxyPollers511 #    Number of pre-forked instances of pollers for passive proxies.512 #513 # Mandatory: no514 # Range: 0-250515 # Default:516 # StartProxyPollers=1517 518 ### Option: ProxyConfigFrequency519 #    How often Zabbix Server sends configuration data to a Zabbix Proxy in seconds.520 #    This parameter is used only for proxies in the passive mode.521 #522 # Mandatory: no523 # Range: 1-3600*24*7524 # Default:525 # ProxyConfigFrequency=3600526 527 ### Option: ProxyDataFrequency528 #    How often Zabbix Server requests history data from a Zabbix Proxy in seconds.529 #    This parameter is used only for proxies in the passive mode.530 #531 # Mandatory: no532 # Range: 1-3600533 # Default:534 # ProxyDataFrequency=1535 536 ### Option: AllowRoot537 #    Allow the server to run as 'root'. If disabled and the server is started by 'root', the server538 #    will try to switch to the user specified by the User configuration option instead.539 #    Has no effect if started under a regular user.540 #    0 - do not allow541 #    1 - allow542 #543 # Mandatory: no544 # Default:545 # AllowRoot=0546 547 ### Option: User548 #    Drop privileges to a specific, existing user on the system.549 #    Only has effect if run as 'root' and AllowRoot is disabled.550 #551 # Mandatory: no552 # Default:553 # User=zabbix554 555 ### Option: Include556 #    You may include individual files or all files in a directory in the configuration file.557 #    Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.558 #559 # Mandatory: no560 # Default:561 # Include=562 563 # Include=/usr/local/etc/zabbix_server.general.conf564 # Include=/usr/local/etc/zabbix_server.conf.d/565 # Include=/usr/local/etc/zabbix_server.conf.d/*.conf566 567 ### Option: SSLCertLocation568 #    Location of SSL client certificates.569 #    This parameter is used only in web monitoring.570 #571 # Mandatory: no572 # Default:573 # SSLCertLocation=${datadir}/zabbix/ssl/certs574 575 ### Option: SSLKeyLocation576 #    Location of private keys for SSL client certificates.577 #    This parameter is used only in web monitoring.578 #579 # Mandatory: no580 # Default:581 # SSLKeyLocation=${datadir}/zabbix/ssl/keys582 583 ### Option: SSLCALocation584 #    Override the location of certificate authority (CA) files for SSL server certificate verification.585 #    If not set, system-wide directory will be used.586 #    This parameter is used only in web monitoring and SMTP authentication.587 #588 # Mandatory: no589 # Default:590 # SSLCALocation=591 592 ####### LOADABLE MODULES #######593 594 ### Option: LoadModulePath595 #    Full path to location of server modules.596 #    Default depends on compilation options.597 #598 # Mandatory: no599 # Default:600 # LoadModulePath=${libdir}/modules601 602 ### Option: LoadModule603 #    Module to load at server startup. Modules are used to extend functionality of the server.604 #    Format: LoadModule=
605 # The modules must be located in directory specified by LoadModulePath.606 # It is allowed to include multiple LoadModule parameters.607 #608 # Mandatory: no609 # Default:610 # LoadModule=611 612 ####### TLS-RELATED PARAMETERS #######613 614 ### Option: TLSCAFile615 # Full pathname of a file containing the top-level CA(s) certificates for616 # peer certificate verification.617 #618 # Mandatory: no619 # Default:620 # TLSCAFile=621 622 ### Option: TLSCRLFile623 # Full pathname of a file containing revoked certificates.624 #625 # Mandatory: no626 # Default:627 # TLSCRLFile=628 629 ### Option: TLSCertFile630 # Full pathname of a file containing the server certificate or certificate chain.631 #632 # Mandatory: no633 # Default:634 # TLSCertFile=635 636 ### Option: TLSKeyFile637 # Full pathname of a file containing the server private key.638 #639 # Mandatory: no640 # Default:641 # TLSKeyFile=
View Code

 

注意要检查httpd服务有没有开启  语句 systemctl start httpd

如果开启在浏览器地址输入:10.0.0.34显示

 #至此进入网页界面进行配置

http://10.0.0.34/zabbix/setup.php

 

#压测 ab命令需要安装httpd后可以使用

ab -n 10000 -c 300 http://10.0.0.34/zabbix/index.php

#iostat 需要安装yum -y install sysstat

*/1 * * * * /usr/bin/sh /server/scripts/zabbix.sh >/dev/null 2>&1

脚本zabbix.sh

#!/bin/bash############################################################### File Name: 7_2.sh# Version: V1.0# Author: nod# Description:###############################################################获取当前的空闲内存FreeMem=`free -m | awk 'NR==2 {print $NF}'`#输出当前的字段CHARS="CURRENT MEMORY IS $FreeMem"if [ $FreeMem -lt 150 ]  #为方便测试此处写为2000 低于2000发送报警,实际生产场景可以进行调整then    echo $CHARS | tee /tmp/messages.txt #输出到屏幕和写入指定文件    mail -s "`date +%F-%T` $CHARS" 312051952@qq.com 

 

 

#agent安装

 

#安装agent

rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-agent-3.0.20-1.el7.x86_64.rpm

 

#修改配置文件

vim /etc/zabbix/zabbix_agentd.conf
Server=10.0.0.34   #此处修改你的zabbix-server地址

 

#检查状态
systemctl start zabbix-agent
setenforce 0
systemctl stop firewalld
systemctl start zabbix-agent
systemctl status zabbix-agent

 #补充假定监控的为centos6的主机

rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-agent-3.0.20-1.el6.x86_64.rpm

 

 

#zabbix服务端配置文件位置

1 [root@nod02 web]# cat zabbix.conf.php  2 
View Code

 

转载于:https://www.cnblogs.com/nodchen/p/9432360.html

你可能感兴趣的文章
python语句----->if语句,while语句,for循环
查看>>
javascript之数组操作
查看>>
LinkedList源码分析
查看>>
TF-IDF原理
查看>>
用JS制作博客页面背景随滚动渐变的效果
查看>>
JavaScript的迭代函数与迭代函数的实现
查看>>
一步步教你学会browserify
查看>>
Jmeter入门实例
查看>>
亲近用户—回归本质
查看>>
中文脏话识别的解决方案
查看>>
CSS之不常用但重要的样式总结
查看>>
Python编译错误总结
查看>>
URL编码与解码
查看>>
日常开发时遇到的一些坑(三)
查看>>
Eclipse 安装SVN插件
查看>>
深度学习
查看>>
TCP粘包问题及解决方案
查看>>
构建之法阅读笔记02
查看>>
添加按钮
查看>>
移动端页面开发适配 rem布局原理
查看>>