CentOS 安裝zabbix 2.0.5版本

來源:互聯網
上載者:User

作為一款優秀的監視軟體,zabbix不但在故障發生時給予警報,並且還可以產生相關的圖表,可以分析網路流量、CUP負載等狀況。

  1、下載並解壓以及yum相關環境

yum install  net-snmp-devel php-bcmath  #視實際情況系統內容,如果後面欠缺某些庫,可以再次yumwget http://superb-dca2.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.0.5/zabbix-2.0.5.tar.gztar xvf zabbix-2.0.5.tar.gzcd zabbix-2.0.5
  2、建立並匯入資料庫

  確保安裝好資料庫(這裡以mysql為例,zabbix支援mysql/DB2/oracle/postgresql/sqlite3等),匯入資料庫(可以給zabbix分配一個獨立的mysql帳號

#登入mysql後grant all on zabbix.* to zabbix@127.0.0.1 identified by 'zabbix123';#在shell下執行,zabbix為剛剛分配的mysql使用者mysql -uzabbix -p -h127.0.0.1 -e 'create database zabbix character set utf8'mysql -uzabbix -p -h127.0.0.1 zabbix < database/mysql/schema.sql mysql -uzabbix -p -h127.0.0.1 zabbix < database/mysql/images.sql mysql -uzabbix -p -h127.0.0.1 zabbix < database/mysql/data.sql

  3、編譯安裝zabbix

# --enable-server 為編譯服務端#--enable-agent 為編譯客戶商朝#--with-mysql=/usr/local/mysql/bin/mysql_config 為提供mysql環境資訊給zabbix./configure --prefix=/usr/local/zabbix \--enable-server \--with-mysql=/usr/local/mysql/bin/mysql_config \--with-net-snmp --with-libcurl --enable-agentmake install
  4、修改配置
  vi /usr/local/zabbix/etc/zabbix_server.conf

  以下為需要修改的資料庫資訊(注意不要有重複的,以免引起衝突)

DBHost=127.0.0.1DBName=zabbixDBUser=zabbixDBPassword=zabbix123DBPort=3306  #如果資料庫是用sock檔案的方式,這裡可以是sock檔案的路徑。
  zabbix提供的啟動指令碼是在安裝檔案的misc/init.d/目錄下,但2.0.5並沒有提供redhat(centOS)的版本。。。挺奇怪,這裡我是用舊版的啟動指令碼。
  zabbix_server.txt
  下載zabbix_server.txt檔案,並且改名為zabbix_server,複製到/etc/init.d目錄下,並給予可執行許可權chmod +x /etc/init.d/zabbix_server
  如果上面都按照我的安裝步驟,預設不用修改zabbix_server檔案了,否則需要修改BASEDIR PIDFILE 這兩項。
  到這裡,zabbix的服務端已經安裝好。開啟zabbix服務端
service zabbix_server start
  如果有error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
/etc/init.d/zabbix_server start: zabbix_server could not be started報錯,是因為找不到mysql庫,執行 ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18 即可。

  5、配置zabbix的WEB服務,
  cp -aR frontends/php/ /www/zabbix/
  chown www:www /www/zabbix/

  開啟php.ini檔案,找到date.timezone這一行,把時區設定為亞洲/上海,並且這三項至少要設定為:

date.timezone ='Asia/Shanghai' post_max_size = 16Mmax_execution_time = 300max_input_time = 300

  配置nginx(這裡是nginx+php-fpm的方式)

  開啟/usr/local/nginx/config/nginx.conf,加入一個新的server項

server {  listen 80;  server_name zabbix.test.com;#  allow 192.168.1.1;  #可以限制哪些IP可以訪問#  allow 192.168.1.2;#  deny all;  root /data/www/zabbix/;  location / {    index index.html index.htm index.php;  }  location ~ \.php$ {    fastcgi_pass 127.0.0.1:9000;    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;    include fastcgi_params;  }}

 如果是用apache,可以這樣

<VirtualHost *:80>    DocumentRoot "/www/zabbix/"    ServerName zabbix.test.com    <Directory />    Order allow,deny    Allow from all# Order deny,Allow# Allow from 192.168.1.1 192.168.1.2# Deny from all    </Directory></VirtualHost>
  配置好之後,重啟nginx或者httpd,開啟zabbix.test.com(網域名稱自己定義,有效就可以),便可以看到安裝頁面。

  按next一步步下去便可。如果提示不支援某php模組,假如php是rpm安裝,直接yum即可,如果php是原始碼安裝,需要進去PHP安裝檔案目錄,然後

cd ext/xxx #選擇進入需要安裝的模組目錄/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-config make && make install#之後會提示so檔案在哪個目錄,開啟php.ini檔案,加入一行,重啟php-fpm即可。extension = "xxx.so"
  WEB端安裝完成之後,通過WEB頁面登入zabbix,預設管理員帳號密碼為 admin zabbix
  6、用戶端安裝。

  上面的安裝已經包含用戶端安裝,如果在其它伺服器上安裝用戶端。只需要進入zabbix安裝目錄

./configure --prefix=/usr/local/zabbix --enable-agentmake install
  vi /usr/local/zabbi/etc/zabbix_agent.conf
修改Server=server_ip為對應的zabbix_server伺服器IP。
  zabbix_agent.txt
  下載zabbix_agent.txt檔案,改名為zabbix_agent,移到/etc/init.d/目錄下並給予可執行許可權chmod +x /etc/init.d/zabbix_agent
  啟動zabbix用戶端服務 service zabbix_agent start

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.