- Zabbix監控架構至少須要server,agent,web模塊。mysql、web部分和server安裝在同一臺機器上。
- Zabbix安裝前服務器要作時間同步(ntp)
1.建立用戶和用戶組(Zabbix默認使用Zabbix用戶)php
groupadd zabbix
adduser zabbix
adduser zabbix zabbix
sudo apt-get install libxml2-dev sudo apt-get install libxml2 sudo apt-get install make sudo apt-get install zlib1g.dev sudo apt-get install zlib1g sudo apt-get install libcurl4-openssl-dev sudo apt-get install libjpeg-dev sudo apt-get install libpng-dev
- 發生這個錯誤,缺乏BZip2
解決辦法:下載 bzip2-1.0.6.tar.gz
make && sudo make installhtml
#安裝編譯套件 sudo apt-get install build-essential #安裝php前端須要的包 sudo apt-get install libmysqlclient15-dev php5-gd php5-mysql libfreetype6-dev #安裝zabbix須要的包,snmp\curl\ssl\fping sudo apt-get install snmp libsnmp-dev snmpd libcurl4-openssl-dev fping sudo apt-get install php5-fpm
- 下載PHP
wget http://cn2.php.net/get/php-5.5.35.tar.gz/from/this/mirror
- 安裝編譯
mv mirror php-5.5.35.tar.gz && tar xvf php-5.5.35.tar.gz && cd php-5.5.35 ./configure --prefix=/usr/local/product/php-5.5.35 --with-config-file-path=/usr/local/product/php-5.5.35/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 make && make install ln -s /usr/local/product/php-5.5.35 /usr/local/php cp php.ini-production /usr/local/php/etc/php.ini cd /usr/local/php/etc/ cp php-fpm.conf.default php-fpm.conf
- 修改PHP參數,可使用find命令查看
find / -name php.ini -print
sudo vim /etc/php5/cgi/php.ini
- 作如下修改
sudo vim /etc/php5/apache2/php.ini修改項: post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone = "Asia/Shanghai"
mysql> use mysql; mysql>create database zabbix character set utf8; mysql>grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix'; mysql>flush privileges;
- 導入數據庫表
cd zabbix-3.2.6/database/mysql mysql -uroot -proot zabbix < schema.sql mysql -uroot -proot zabbix < images.sql mysql -uroot -proot zabbix < data.sql
網址:前端
tar -xvzf zabbix-3.2.6.tar.gz cd zabbix-3.2.6/ sudo ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql --with-net-snmp --with-libcurl --enable-java make -j4 make install
執行完上述命令,zabbix就安裝成功了,位置在/usr/local/zabbix,而且–enable-server和–enable-agent是同時開啓server和agent,而且後面的參數對於server來講都要加上java
- 修改配置server文件
mkdir -p /etc/zabbix cp -r zabbix-3.2.6/conf/* /etc/zabbix/ chown -R zabbix:zabbix /etc/zabbix vim /etc/zabbix/zabbix_server.conf
- 作如下修改
LogFile=/tmp/zabbix_server.log PidFile=/tmp/zabbix_server.pid DBName=zabbix DBUser=zabbix DBPassword=zabbix DBPort=3306
進入zabbix的安裝目錄下,sbin/zabbix_server啓功server,關閉用kill
vim /etc/zabbix/zabbix_agentd.conf
node
- 設置zabbix開機啓動
sudo cp misc/init.d/debian/zabbix-server /etc/init.d sudo cp misc/init.d/debian/zabbix-agent /etc/init.d cd !$ sudo chmod 755 zabbix-* sudo update-rc.d zabbix-server defaults sudo update-rc.d zabbix-agent defaults
- 作如下修改
Server=127.0.0.1 #容許server獲取數據(改爲serverIP) ServerActive=127.0.0.1 #主動給server推送數據(改爲serverIP) Hostname=Zabbix server
- 只安裝agent
tar -xvzf zabbix-3.2.6.tar.gz cd zabbix-3.2.6/ ./configure --prefix=/opt/zabbix --enable-agent make make install groupadd zabbix # sudo adduser zabbix useradd -g zabbix zabbix #sudo gpasswd -a zabbix zabbix mkdir -p /etc/zabbix cp -r zabbix-3.2.6/conf/* /etc/zabbix/ chown -R zabbix:zabbix /etc/zabbix vim /etc/zabbix/zabbix_agent.conf Server=192.168.0.157 ServerActive=192.168.0.157 Hostname=bigdata2(起一個惟一的名字)
- 歸置一下zabbix的web服務,以便nginx訪問
sudo mkdir /usr/share/nginx/html/zabbix/ cd zabbix-3.2.6/frontends/ sudo cp -r php/* /usr/share/nginx/html/zabbix # /usr/share/nginx/html/zabbix/conf/zabbix.conf.php 保存zabbix鏈接信息
- 修改nginx配置文件
sudo vim /etc/nginx/nginx.conf user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; server { listen 8088; server_name localhost; # access_log /var/log/nginx/zabbix.log main; root /usr/share/nginx/html/zabbix/; index index.php; location /{ try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; } } }
1.安裝servermysql
wget http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.0-1+trusty_all.deb dpkg -i zabbix-release_3.0-1+trusty_all.deb apt-get update apt-get install php5 zabbix-frontend-php php5-mysql sudo apt-get install zabbix-server-mysql #會安裝MySQL sudo vim /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix
# 配置PHP sudo vim /etc/php5/apache2/php.ini修改項: post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone = "Asia/Shanghai" 修改完成後重啓apache2 /etc/init.d/apache2 restart 配置數據庫 首先mysql配置 cd /etc/mysql sudo vim my.cnf 註釋掉下面這行 #bind-address = 127.0.0.1 mysql>create database zabbix character set utf8 collate utf8_bin; mysql>grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; mysql> flush privileges; sudo apt-get install zabbix-frontend-php(數據庫root,root,root) sudo cp -r /usr/share/zabbix /var/www/html/zabbix
cd /usr/share/doc/zabbix-server-mysql
ls
gunzip create.sql.gz
mysql -uzabbix -pzabbix zabbix <create.sql
sudo /etc/init.d/zabbix-server stop
sudo /etc/init.d/zabbix-server start
wget http://repo.zabbix.com/zabbix/3.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.0-1+trusty_all.deb dpkg -i zabbix-release_3.0-1+trusty_all.deb apt-get install zabbix-agent
sudo vim /etc/zabbix/zabbix_agentd.conf 作如下修改 Server=192.168.0.157 ServerActive=192.168.0.157 Hostname=bigdata2
sudo service zabbix-agent restart
首先啓用中文 sudo vim /usr/share/zabbix/include/locales.inc.php 把zh_CN後面參數寫true,而後安裝中文包 sudo apt-get install language-pack-zh-hant language-pack-zh-hans 接着,配置相關環境變量: vi /etc/environment 在文件中增長語言和編碼的設置: LANG="zh_CN.UTF-8" LANGUAGE="zh_CN:zh:en_US:en" 接着,從新設置本地配置: dpkg-reconfigure locales 最後重啓apache,server服務
sudo find / -name defines.inc.php -print
1. 到網上下載simkai.ttf文件,上傳到/usr/share/zabbix/fonts目錄下nginx
2. 修改配置sudo vim /usr/share/zabbix/include/defines.inc.php
web
重啓web服務。sql
sudo service php5-fpm restart