都須要監控什麼呢?php
CPU,內存,硬盤,服務等等等,你想監控什麼就監控什麼,用本身的腳本寫出來html
yum install ipmitool -yjava
htop須要安裝,epel源(很強大)mysql
yum install htop -ynginx
沒有的都yum install一下web
zabbix有兩個部分構成,zabbix server和zabbix agent 可選組件zabbix proxysql
zabbix的官網 :https://www.zabbix.com/數據庫
搭建LNMP環境apache
配置環境vim
yum install pcre pcre-devel openssl-devel zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel mhash mcrypt -y
(我這裏直接使用本身定製的RPM包安裝了)
編譯安裝zabbix
安裝依賴包(數據庫若是是二進制安裝的 須要加上 mysql-devel)
yum install fping net-snmp-devel unixODBC-devel openssl-devel OpenIPMI-devel java-devel -y
建立zabbix用戶
useradd zabbix -s /sbin/nologin mkdir - p /application/tools cd /application/tools/
下載zabbix
wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.15/zabbix-3.0.15.tar.gz
解壓安裝
tar xf zabbix-3.0.15.tar.gz cd zabbix-3.0.15 ./configure --prefix=/application/zabbix-3.0.15 --enable-server --enable-agent --enable-java --enable-ipv6 --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc --with-openssl make && make install ln -s /application/zabbix-3.0.15/ /application/zabbix
對數據庫操做
建立zabbix數據庫,並制定字符集 create database zabbix character set utf8 collate utf8_bin; 建立用戶 grant all on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'zabbix'; 刷新權限 flush privileges;
找到路徑*(在zabbix壓縮包裏),下面有三個SQL文件
/application/tools/zabbix-3.0.15/database/mysql
導入數據文件(數據庫裏操做,肯定路徑,順序不要錯)
use zabbix source /application/tools/zabbix-3.0.15/database/mysql/schema.sql #表結構,首先導入 source /application/tools/zabbix-3.0.15/database/mysql/images.sql #圖形,其次導入 source /application/tools/zabbix-3.0.15/database/mysql/data.sql #數據,最後導入
建立站點目錄
mkdir -p /application/nginx/html/zabbix
拷貝源碼包裏的PHP文件到 站點(tar解壓出來的包)
cp -a /application/tools/zabbix-3.0.15/frontends/php/* /application/nginx/html/zabbix/ chown -R www.www /application/nginx/html/zabbix/
修改配置PHP文件(修改後的)
egrep -n "^post_max_size|^max_execution|^max_input_time|^date.timezone" /application/php/lib/php.ini 372:max_execution_time = 300 382:max_input_time = 300 660:post_max_size = 16M 910:date.timezone = Asia/Shanghai
重啓
pkill php /application/php/sbin/php-fpm
配置nginx文件
cat >/application/nginx/conf/nginx.conf<<EOF worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.php index.html index.htm; } location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } access_log logs/zabbix.log; } } EOF
重啓
/application/nginx/sbin/nginx -s reload
配置zabbix文件
vim /application/zabbix/etc/zabbix_server.conf 修改77行,指定數據庫的IP地址 77 DBHost=127.0.0.1 111行指定數據庫密碼 111 DBPassword=zabbix
拷貝啓動腳本
cp /application/tools/zabbix-3.0.15/misc/init.d/fedora/core/zabbix_{server,agentd} /etc/init.d/ ls /etc/init.d/zabbix_* /etc/init.d/zabbix_agentd /etc/init.d/zabbix_server 修改啓動腳本 sed -i "s#BASEDIR=/usr/local#BASEDIR=/application/zabbix#g" /etc/init.d/zabbix_{server,agentd}
啓動
/etc/init.d/zabbix_server start Starting zabbix_server: /application/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory [失敗] 沒有libmysqlclient.so.18庫文件 ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
/etc/init.d/zabbix_server start
Starting zabbix_server: [肯定]
能夠訪問
http://192.168.70.134/zabbix/
要裝這個模塊,要否則用不了中文
找到PHP源碼包(tar.gz的包)
在裏面找到
cd /home/daxian/tools/php-5.5.32/ext cd gettext/ (必定要在這個目錄下執行) /application/php/bin/phpize ./configure --with-php-config=/application/php/bin/php-config make && make install echo "extension = gettext.so" >>/application/php/lib/php.ini 查看是否加入進去 /application/php/bin/php -m 重啓PHP pkill php /application/php/sbin/php-fpm
提示:若是以前是二進制安裝數據庫,最好把mysqli也裝一下
cd mysqli/ /application/php/bin/phpize ./configure --with-php-config=/application/php/bin/php-config make && make install echo "extension = mysqli.so" >>/application/php/lib/php.ini /application/php/bin/php -m|grep mysqli mysqli
搭建好了
==============客戶端搭建===============
直接在zabbix端啓動(先監控本身)
/etc/init.d/zabbix_agentd start
鏈接一臺web服務器,安裝客戶端
下載客戶端
wget https://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/6/x86_64/zabbix-agent-3.0.14-1.el6.x86_64.rpm
安裝(解決依賴關係)
yum localinstall zabbix-agent-3.0.14-1.el6.x86_64.rpm
修改配置文件
vim /etc/zabbix/zabbix_agentd.conf
95 Server=192.168.70.134
啓動
/etc/init.d/zabbix-agent start
查看數據
解決亂碼問題
服務端操做
下載字體包
yum install wqy-microhei-fonts -y
替換字體
cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /application/nginx/html/zabbix/fonts/DejaVuSans.ttf wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
解決了