您好,登錄后才能下訂單哦!
一、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 -y install MariaDB-client MariaDB-server MariaDB-devel
2、配置數據庫
2.1 配置數據庫配置文件
[root@node7 ~]# vim /etc/my.cnf innodb_file_per_table = 1 skip_name_resolve = 1
2.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 zabbix
3.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-mysql
3.3 將zabbix數據導入數據庫
[root@node7 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.2.1/create.sql | mysql -uzabbix -pzabbix zabbix
3.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 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 # 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=<module.so> # The modules must be located in directory specified by LoadModulePath. # It is allowed to include multiple LoadModule parameters. # # Mandatory: no # Default: # LoadModule= 54、CA證書的路徑 ### Option: TLSCAFile # Full pathname of a file containing the top-level CA(s) certificates for # peer certificate verification. # # Mandatory: no # Default: # TLSCAFile= 55、吊銷證書的路徑 ### Option: TLSCRLFile # Full pathname of a file containing revoked certificates. # # Mandatory: no # Default: # TLSCRLFile= 56、服務器證書文件 ### Option: TLSCertFile # Full pathname of a file containing the server certificate or certificate chain. # # Mandatory: no # Default: # TLSCertFile= 57、服務器密鑰文件 ### Option: TLSKeyFile # Full pathname of a file containing the server private key. # # Mandatory: no # Default: # TLSKeyFile=
一般情況下,腳本路徑可更改使用外,其余高級配置默認即可;如有需要,可自行更改配置。
3.7 啟動zabbix-server
[root@node7 ~]# systemctl start zabbix-server
4、配置php,并啟動httpd服務
[root@node7 ~]# vim /etc/httpd/conf.d/zabbix.conf php_value date.timezone Asia/Shanghai [root@node7 ~]# systemctl start httpd.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連接數據庫
6.2 成功登錄
如有錯誤,敬請指正。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。