CentOS7以yum方式安装zabbix3.2及配置文件详解-创新互联
一、zabbix简介与环境准备
主要从事网页设计、PC网站建设(电脑版网站建设)、wap网站建设(手机版网站建设)、响应式网站开发、程序开发、微网站、小程序开发等,凭借多年来在互联网的打拼,我们在互联网网站建设行业积累了丰富的网站设计、网站建设、网络营销经验,集策划、开发、设计、营销、管理等多方位专业化运作于一体,具备承接不同规模与类型的建设项目的能力。简介详见 ---> 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 -y install MariaDB-client MariaDB-server MariaDB-devel2、配置数据库
2.1 配置数据库配置文件
[root@node7 ~]# vim /etc/my.cnf innodb_file_per_table = 1 skip_name_resolve = 12.2 创建zabbix库并授权普通用户远程访问
[root@node7 ~]# systemctl start mariadb [root@node7 ~]# mysql -e "grant all on *.* to 'root'@'localhost' identified by 'root';" [root@node7 ~]# mysql -uroot -proot Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 18 Server version: 5.5.50-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; Query OK, 0 rows affected (0.43 sec) MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by 'zabbix'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> grant all on zabbix.* to zabbix@192.168.1.20 identified by 'zabbix'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> \q Bye
3、安装zabbix
3.1 创建zabbix用户与组(普通用户)
[root@node7 ~]# groupadd zabbix [root@node7 ~]# useradd -g zabbix zabbix3.2 使用yum方式安装zabbix
[root@node7 ~]# rpm -ivh [root@node7 ~]# yum clean all [root@node7 ~]# yum makecache [root@node7 ~]# yum install zabbix zabbix-server zabbix-server-mysql zabbix-web zabbix-agent zabbix-sender zabbix-get zabbix-web-mysql3.3 将zabbix数据导入数据库
[root@node7 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.2.1/create.sql | mysql -uzabbix -pzabbix zabbix3.4 查看导入数据,并测试zabbix用户远程登录
[root@node7 ~]# mysql -uzabbix -pzabbix Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 21 Server version: 5.5.50-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | test | | zabbix | +--------------------+ 3 rows in set (0.00 sec) MariaDB [(none)]> use zabbix Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [zabbix]> show tables; 127 rows in set (0.00 sec) MariaDB [zabbix]> \q Bye3.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=33063.6 zabbix-server高级配置详解
1、server端拉取agent端的items,开启的空闲数默认为5 ### Option: StartPollers # Number of pre-forked instances of pollers. # # Mandatory: no # Range: 0-1000 # Default: # StartPollers=5 2、硬件级别的监控,默认启动空闲为0 ### Option: StartIPMIPollers # Number of pre-forked instances of IPMI pollers. # # Mandatory: no # Range: 0-1000 # Default: # StartIPMIPollers=0 3、对不可达主机拉取数据 ### Option: StartPollersUnreachable # are started. # # Mandatory: no # Range: 0-1000 # Default: # StartPollersUnreachable=1 4、陷阱机制,即对于中途加入的主机主动发送的数据进行保存,陷阱池默认为5个 ### Option: StartTrappers # Number of pre-forked instances of trappers. # in the frontend. # # Mandatory: no # Range: 0-1000 # Default: # StartTrappers=5 5、使用ICMP协议的ping对网络中主机进行在线状态检测 ### Option: StartPingers # Number of pre-forked instances of ICMP pingers. # # Mandatory: no # Range: 0-1000 # Default: # StartPingers=1 6、对网络中的主机ping主动扫描发现,对中途加入的主机进行上线。注意:主动发现很消耗带宽 ### Option: StartDiscoverers # Number of pre-forked instances of discoverers. # # Mandatory: no # Range: 0-250 # Default: # StartDiscoverers=1 7、使用http协议请求网页资源,探测主机web服务是否正常 ### Option: StartHTTPPollers # Number of pre-forked instances of HTTP pollers. # # Mandatory: no # Range: 0-1000 # Default: # StartHTTPPollers=1 8、对时序有关的监控项计时 ### Option: StartTimers # Number of pre-forked instances of timers. # Timers process time-based trigger functions and maintenance periods. # Only the first timer process handles the maintenance periods. # # Mandatory: no # Range: 1-1000 # Default: # StartTimers=1 9、 ### Option: StartEscalators # Number of pre-forked instances of escalators. # # Mandatory: no # Range: 0-100 # Default: # StartEscalators=1 10、监控java虚拟机 ### Option: JavaGateway # IP address (or hostname) of Zabbix Java gateway. # Only required if Java pollers are started. # # Mandatory: no # Default: # JavaGateway= 11、监控java开启的端口 ### Option: JavaGatewayPort # Port that Zabbix Java gateway listens on. # # Mandatory: no # Range: 1024-32767 # Default: # JavaGatewayPort=10052 12、server端拉取jdk的数据 ### Option: StartJavaPollers # Number of pre-forked instances of Java pollers. # # Mandatory: no # Range: 0-1000 # Default: # StartJavaPollers=0 13、监控VMware虚拟机的各项参数 ### Option: StartVMwareCollectors # Number of pre-forked vmware collector instances. # # Mandatory: no # Range: 0-250 # Default: # StartVMwareCollectors=0 14、监控VMware虚拟机的频率,默认60秒 ### Option: VMwareFrequency # How often Zabbix will connect to VMware service to obtain a new data. # # Mandatory: no # Range: 10-86400 # Default: # VMwareFrequency=60 15、监控VMware的服务 ### Option: VMwarePerfFrequency # How often Zabbix will connect to VMware service to obtain performance data. # # Mandatory: no # Range: 10-86400 # Default: # VMwarePerfFrequency=60 16、监控VMware的内存使用 ### Option: VMwareCacheSize # Size of VMware cache, in bytes. # Shared memory size for storing VMware data. # Only used if VMware collectors are started. # # Mandatory: no # Range: 256K-2G # Default: # VMwareCacheSize=8M 17、VMware的超时时间 ### Option: VMwareTimeout # # Mandatory: no # Range: 1-300 # Default: # VMwareTimeout=10 18、SNMP日志文件路径 ### Option: SNMPTrapperFile # Temporary file used for passing data from SNMP trap daemon to the server. # Must be the same as in zabbix_trap_receiver.pl or SNMPTT configuration file. # # Mandatory: no # Default: # SNMPTrapperFile=/tmp/zabbix_traps.tmp SNMPTrapperFile=/var/log/snmptrap/snmptrap.log 19、SNMP协议的陷阱机制,同上 ### Option: StartSNMPTrapper # If 1, SNMP trapper process is started. # # Mandatory: no # Range: 0-1 # Default: # StartSNMPTrapper=0 20、SNMP监听地址 ### Option: ListenIP # List of comma delimited IP addresses that the trapper should listen on. # Trapper will listen on all network interfaces if this parameter is missing. # # Mandatory: no # Default: # ListenIP=0.0.0.0 # ListenIP=127.0.0.1 21、从数据库中移除过期数据 ### Option: HousekeepingFrequency # How often Zabbix will perform housekeeping procedure (in hours). # Housekeeping is removing outdated information from the database. # # Mandatory: no # Range: 0-24 # Default: # HousekeepingFrequency=1 22、将上一项中的每一项任务删除 ### Option: MaxHousekeeperDelete # [housekeeperid], [tablename], [field], [value]. # will be deleted per one task in one housekeeping cycle. # # Mandatory: no # Range: 0-1000000 # Default: # MaxHousekeeperDelete=5000 23、对尚未发送的报警信息30秒重发送一次 ### Option: SenderFrequency # How often Zabbix will try to send unsent alerts (in seconds). # # Mandatory: no # Range: 5-3600 # Default: # SenderFrequency=30 24、配置缓存大小 ### Option: CacheSize # Size of configuration cache, in bytes. # Shared memory size for storing host, item and trigger data. # # Mandatory: no # Range: 128K-8G # Default: # CacheSize=8M 25、缓存刷新时间 ### Option: CacheUpdateFrequency # How often Zabbix will perform update of configuration cache, in seconds. # # Mandatory: no # Range: 1-3600 # Default: # CacheUpdateFrequency=60 26、数据库同步实例数 ### Option: StartDBSyncers # Number of pre-forked instances of DB Syncers. # # Mandatory: no # Range: 1-100 # Default: # StartDBSyncers=4 27、定义缓存的历史数据大小 ### Option: HistoryCacheSize # Size of history cache, in bytes. # Shared memory size for storing history data. # # Mandatory: no # Range: 128K-2G # Default: # HistoryCacheSize=16M 28、历史表单的缓存数据大小 ### Option: HistoryIndexCacheSize # Size of history index cache, in bytes. # Shared memory size for indexing history cache. # # Mandatory: no # Range: 128K-2G # Default: # HistoryIndexCacheSize=4M 29、趋势数据缓存大小 ### Option: TrendCacheSize # # Mandatory: no # Range: 128K-2G # Default: # TrendCacheSize=4M 30、用于缓存历史数据的大小,0为禁用 ### Option: ValueCacheSize # Size of history value cache, in bytes. # Shared memory size for caching item history data requests. # Setting to 0 disables value cache. # # 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 # Specifies how many seconds trapper may spend processing new data. # # Mandatory: no # Range: 1-300 # Default: # TrapperTimeout=300 33、定义主机不可达的超时时间 ### Option: UnreachablePeriod # After how many seconds of unreachability treat a host as unavailable. # # Mandatory: no # Range: 1-3600 # Default: # UnreachablePeriod=45 34、在主机不可用期间,定期检查主机的时间 ### Option: UnavailableDelay # How often host is checked for availability during the unavailability period, in seconds. # Mandatory: no # Range: 1-3600 # Default: # UnavailableDelay=60 35、在主机被监控期间检查的时间 ### Option: UnreachableDelay # How often host is checked for availability during the unreachability period, in seconds. # Mandatory: no # Range: 1-3600 # Default: # UnreachableDelay=15 36、自定义报警脚本的路径,默认值取决于编译选项 ### Option: AlertScriptsPath # Full path to location of custom alert scripts. # Default depends on compilation options. # # Mandatory: no # Default: # AlertScriptsPath=${datadir}/zabbix/alertscripts AlertScriptsPath=/usr/lib/zabbix/alertscripts 37、外部脚本的路径,默认值取决于编译选项 ### Option: ExternalScripts # Full path to location of external scripts. # Default depends on compilation options. # # Mandatory: no # Default: # ExternalScripts=${datadir}/zabbix/externalscripts ExternalScripts=/usr/lib/zabbix/externalscripts 38、执行ping检查时fping命令路径,fping可并行执行 ### Option: FpingLocation # Location of fping. # Make sure that fping binary has root ownership and SUID flag set. # # Mandatory: no # Default: # FpingLocation=/usr/sbin/fping 39、V6 ### Option: Fping6Location # Location of fping6. # Make sure that fping6 binary has root ownership and SUID flag set. # Make empty if your fping utility is capable to process IPv6 addresses. # # Mandatory: no # Default: # Fping6Location=/usr/sbin/fping6 40、使用密钥为SSH登录认证 ### Option: SSHKeyLocation # Location of public and private keys for SSH checks and actions. # # Mandatory: no # Default: # SSHKeyLocation= 41、数据库查询时间,0为不登录慢速查询 ### Option: LogSlowQueries # How long a database query may take before being logged (in milliseconds). # Only works if DebugLevel set to 3, 4 or 5. # 0 - don't log slow queries. # # Mandatory: no # Range: 1-3600000 # Default: # LogSlowQueries=0 LogSlowQueries=3000 42、临时目录 ### Option: TmpDir # Temporary directory. # # Mandatory: no # Default: # TmpDir=/tmp 43、代理服务器拉取数据 ### Option: StartProxyPollers # Number of pre-forked instances of pollers for passive proxies. # # Mandatory: no # Range: 0-250 # Default: # StartProxyPollers=1 44、用于被动模式的proxy,由sercer端发送配置信息 ### Option: ProxyConfigFrequency # How often Zabbix Server sends configuration data to a Zabbix Proxy in seconds. # This parameter is used only for proxies in the passive mode. # # Mandatory: no # Range: 1-3600*24*7 # Default: # ProxyConfigFrequency=3600 45、用于被动模式的proxy,由sercer端拉取数据 ### Option: ProxyDataFrequency # How often Zabbix Server requests history data from a Zabbix Proxy in seconds. # This parameter is used only for proxies in the passive mode. # # Mandatory: no # Range: 1-3600 # Default: # ProxyDataFrequency=1 46、禁止root用户运行zabbix,0为禁止 ### Option: AllowRoot # Allow the server to run as 'root'. If disabled and the server is started by 'root', the server # will try to switch to the user specified by the User configuration option instead. # Has no effect if started under a regular user. # 0 - do not allow # 1 - allow # # Mandatory: no # Default: # AllowRoot=0 47、禁止root用户后使用的普通用户 ### Option: User # Drop privileges to a specific, existing user on the system. # Only has effect if run as 'root' and AllowRoot is disabled. # # Mandatory: no # Default: # User=zabbix 48、yum安装zabbix时创建的目录 ### Option: Include # You may include individual files or all files in a directory in the configuration file. # Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time. # # 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 # Location of SSL client certificates. # This parameter is used only in web monitoring. # # Mandatory: no # Default: # SSLCertLocation=${datadir}/zabbix/ssl/certs 50、web监测时所用SSL协议密钥路径 ### Option: SSLKeyLocation # Location of private keys for SSL client certificates. # This parameter is used only in web monitoring. # # Mandatory: no # Default: # SSLKeyLocation=${datadir}/zabbix/ssl/keys 51、web监测或SMTP身份认证 ### Option: SSLCALocation # If not set, system-wide directory will be used. # This parameter is used only in web monitoring and SMTP authentication. # # Mandatory: no # Default: # SSLCALocation= ####### LOADABLE MODULES ####### 52、模块路径 ### Option: LoadModulePath # Full path to location of server modules. # Default depends on compilation options. # # Mandatory: no # Default: # LoadModulePath=${libdir}/modules 53、模块支持库的路径 ### Option: LoadModule # Format: LoadModule=一般情况下,脚本路径可更改使用外,其余高级配置默认即可;如有需要,可自行更改配置。
3.7 启动zabbix-server
[root@node7 ~]# systemctl start zabbix-server4、配置php,并启动httpd服务
[root@node7 ~]# vim /etc/httpd/conf.d/zabbix.conf php_value date.timezone Asia/Shanghai [root@node7 ~]# systemctl start httpd.service 此时确认iptanles规则放行或禁用,并关闭selinux5、配置agent端,最少指出其server端地址,server端可配置多个
[root@node7 ~]# vim /etc/zabbix/zabbix_agentd.conf Server=127.0.0.1,192.168.1.206、登录web界面http://192.168.1.20/zabbix,初始用户名密码admin/zabbix,看到如下界面,即配置成功
6.1 配置zabbix-web连接数据库
6.2 成功登录
如有错误,敬请指正。
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
当前标题:CentOS7以yum方式安装zabbix3.2及配置文件详解-创新互联
本文地址:http://cdiso.cn/article/dpoedi.html