轉載於http://www.cnblogs.com/xqzt/p/5124894.html,更正了部分錯誤,並增長了個別問題處理辦法。php
zabbix是一個基於WEB界面的提供分佈式系統監視以及網絡監視功能的企業級的開源解決方案。zabbix能監視各類網絡參數,保證服務器系統的安全運營;並提供靈活的通知機制以讓系統管理員快速定位/解決存在的各類問題。html
下面是Centos7上yum安裝zabbix的步驟。java
本文檔在同一臺機器上安裝了zabbix-server 和zabbix-agent 本身監控本身。mysql
參照下面的連接linux
Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7sql
Zabbix在CentOS基本源裏不可得到,所以必須配置EPEL 和Zabbix 官方repository數據庫
安裝EPEL repositoryapache
yum install epel-release
配置ZabbixZone package repository and GPG keycentos
rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX rpm -Uv http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
安裝Zabbix server and agent:(配置本身監控本身,因此安裝了zabbix-agent)
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway
編輯 file /etc/httpd/conf.d/zabbix:
vi /etc/httpd/conf.d/zabbix.conf
更新時區:
php_value date.timezone Asia/Shanghai
重啓httpd
systemctl restart httpd
登陸MariaDB:
mysql –u root –p
建立一個數據庫‘zabbixdb’和數據庫用戶‘zabbix’
MariaDB [(none)]> create database zabbix character set utf8; MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix'; MariaDB [(none)]> flush privileges;
使用數據庫用戶zabbix登陸數據庫
mysql –uzabbix –p
切換到zabbix數據庫
use zabbix
導入模板數據
MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.8/create/schema.sql MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.8/create/images.sql MariaDB [zabbix]> source /usr/share/doc/zabbix-server-mysql-2.4.8/create/data.sql
編輯文件/etc/zabbix/zabbix_server.conf,
vi /etc/zabbix/zabbix_server.conf
配置下面的三個參數
[...]
DBName=zabbix
[...]
DBUser=zabbix
[...]
DBPassword=zabbix
[...]
vi /etc/zabbix/zabbix_agentd.conf
配置zabbix server 的ip
[...] ## Line 85 - Specify Zabbix server ## Server=127.0.0.1 [...] ## Line 126 - Specify Zabbix server ## ServerActive=127.0.0.1 [...] ## Line 137 - Specify Zabbix server Hostname or IP address ## Hostname=127.0.0.1 [...]
修改php.ini爲zabbix 建議的設置
編輯文件 php.ini,
vi /etc/php.ini
設置下面的參數.
max_execution_time = 600
max_input_time = 600
memory_limit = 256
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Shanghai
開放zabbix端口10050 and 10051.
firewall-cmd --permanent --add-port=10050/tcp firewall-cmd --permanent --add-port=10051/tcp
重啓firewall
systemctl restart firewalld
若是使用 SELinux, 運行如下命令使 Apache 能夠和 Zabbix通訊
setsebool -P httpd_can_connect_zabbix=1
編輯文件 /etc/httpd/conf.d/zabbix.conf,
vi /etc/httpd/conf.d/zabbix.conf
添加容許訪問 zabbix web interface的ip段. 若是設置 ‘Allow from All’, 這能夠容許所有能夠訪問
# # Zabbix monitoring system php web frontend # Alias /zabbix /usr/share/zabbix <Directory "/usr/share/zabbix"> Options FollowSymLinks AllowOverride None Require all granted <IfModule mod_php5.c> php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value date.timezone Asia/Shanghai </IfModule> </Directory> <Directory "/usr/share/zabbix/conf"> Require all denied </Directory> <Directory "/usr/share/zabbix/include"> Require all denied </Directory>
啓動zabbix-server 和zabbix-agent。重啓httpd,,並設置zabbix-server和zabbix-agent開機自動啓動
systemctl start zabbix-server systemctl start zabbix-agent systemctl restart httpd systemctl restart mariadb systemctl enable zabbix-server systemctl enable zabbix-agent ---- (可選)
瀏覽器訪問http://ip-address/zabbix
檢查包的完整性和參數配置
數據zabbix數據庫名、數據庫用戶和密碼,並測試
這一步可能會出錯誤——
Error connecting database:can't connect to local MySQL server through socket 'var/lib/mysql/mysql.sock'
輸入Server name(可選)
預安裝summary
點擊完成,完成安裝
安裝完成後,重定向到zabbix控制檯登陸頁面. 輸入用戶名和密碼,默認的用戶名和密碼爲admin/zabbix.
管理儀表盤頁面以下
http://www.unixmen.com/how-to-install-zabbix-server-on-centos-7/