在講安裝過程之前需要先把zabbix的工作流程簡單的講一遍:zabbix是個開源監控軟件,通過web才能更直觀的監控我們想要監控的主機,同時,zabbix從被監控主機獲取到的信息需要存放在數據庫中,因此zabbix+nginx/apache+php+mysql是常用的組合方式。nginx/apache提供web服務器,zabbix的web監控是由php寫的,因此需要php環境,最后mysql提供存儲。
mysql、nginx、php之前都說過如何編譯安裝,在此我就只講編譯參數了。
php:
./configure --prefix=/usr/local/php-5.5.0 --with-config-file-path=/usr/local/php-5.5.0/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath --with-openssl --enable-mbstring
mysql:
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1
nginx:
--prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre
zabbix:
安裝zabbix前需要修改php.ini的幾個參數
max_execution_time = 300
修改完畢可以開始編譯安裝zabbix了
/configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --enable-proxy --with-mysql --with-net-snmp --with-libcurl --with-libxml2
所有軟件安裝完畢后開始配置
1、mysql中添加zabbix數據庫
在zabbix的源碼目錄下有個database目錄,里面對應不同的數據庫
我們使用的是mysql數據庫,因此表結構從mysql中導入,一共有3個表,mysql,images和schema
mysql>create database zabbix character set utf8;
mysql>grant all privileges on zabbix.* to root@'localhost' identified by '123';
mysql>mysql -uroot -pmysql zabbix < schema.sql #導入這三個表必須按照此順序
mysql>mysql -uroot -pmysql zabbix < images.sql
mysql>mysql -uroot -pmysql zabbix < data.sql
2、配置zabbix-server
# vim /usr/local/zabbix/zabbix_server.conf
DBSocket=/data/mysql3306/mysql.sock
使用zabbix_agentd啟動,查看10050端口是否開啟。
3、配置zabbix管理網站
cp -rp /usr/local/src/zabbix-2.2.13/frontends/php/* /www/zabbix
#vim /usr/local/nginx/conf/nginx.conf
server { listen 80; index index.html index.php index.html; root /www; location / { try_files $uri $uri/ /index.php?$args; } location ~ ^(.+.php)(.*)$ { fastcgi_split_path_info ^(.+.php)(.*)$; include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
配置完畢啟動nginx,瀏覽器輸入localhost/zabbix即可在線配置zabbix的網頁,配置完網頁即可在網頁上監控agent
提示:想要開啟zabbix網頁,nginx,php-fpm,mysql都要開啟,缺一不可。