zabbix原始碼安裝

dbasdk發表於2017-04-24

zabbix 介紹

zabbix由2部分構成,zabbix server與可選元件zabbix agent。

  • zabbix server可以透過SNMP,zabbix agent,ping,埠監視等方法提供對遠端伺服器/網路狀態的監視,資料收集等功能,它可以執行在Linux, Solaris, HP-UX, AIX, Free BSD, Open BSD, OS X等平臺上。
  • zabbix agent需要安裝在被監視的目標伺服器上,它主要完成對硬體資訊或與作業系統有關的記憶體,CPU等資訊的收集。zabbix agent可以執行在Linux ,Solaris, HP-UX, AIX, Free BSD, Open BSD, OS X, Tru64/OSF1, Windows NT4.0, Windows 2000/2003/XP/Vista)等系統之上。

zabbix 安裝

安裝zabbix依賴包
shell> yum install net-snmp-devel curl-devel

建立zabbix使用者
shell> groupadd zabbix
shell> useradd -r -g zabbix zabbix

解壓zabbix安裝包
shell> tar zxvf zabbix-2.4.5.tar.gz 
shell> cd zabbix-2.4.5/

建立zabbix資料庫庫並匯入初始化資料
mysql> create database zabbix character set utf8;
Query OK, 1 row affected (0.02 sec)

mysql> grant all on zabbix.* to zabbix@localhost identified by '123@qwe';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

shell> mysql -u zabbix -p zabbix < database/mysql/schema.sql
shell> mysql -u zabbix -p zabbix < database/mysql/images.sql
shell> mysql -u zabbix -p zabbix < database/mysql/data.sql

編譯安裝zabbix
shell> ./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent \
--with-mysql=/db/mysql/bin/mysql_config --with-net-snmp --with-libcurl

shell> make && make install

shell> ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
shell> ln -s /usr/local/zabbix/bin/* /usr/local/bin/

zabbix 配置

新增zabbix server埠
shell> grep zabbix /etc/services 
zabbix-agent    10050/tcp               # Zabbix Agent
zabbix-agent    10050/udp               # Zabbix Agent
zabbix-trapper  10051/tcp               # Zabbix Trapper
zabbix-trapper  10051/udp               # Zabbix Trapper

更改zabbix-server.conf配置檔案中關於資料庫部分。
shell> vi /usr/local/zabbix/etc/zabbix_server.conf
==============================================================
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123@qwe
DBSocket=/tmp/mysql.sock
DBPort=3306
ListenIP=127.0.0.1
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts
==============================================================

更改zabbix_agent.conf配置檔案中關於資料庫部分
shell> vi /usr/local/zabbix/etc/zabbix_agentd.conf
==============================================================
Include=/usr/local/etc/zabbix_agentd.conf.d/
UnsafeUserParameters=1
==============================================================

啟動執行zabbix

複製zabbix前端到web目錄下
shell> cp -a frontends/php/* /usr/local/nginx/html/zabbix/
shell> chown -R nginx.nginx /usr/local/nginx/html/

新增zabbix到開機啟動指令碼並修改
shell> cp misc/init.d/fedora/zabbix_agentd /etc/init.d/
shell> cp misc/init.d/fedora/zabbix_server /etc/init.d/
修改/etc/init.d/zabbix_server、/etc/init.d/zabbix_agentd中BASEDIR=/usr/local/zabbix

shell> /etc/init.d/zabbix_agentd start
Starting zabbix_agentd:                                    [確定]

shell> /etc/init.d/zabbix_server start
Starting zabbix_server:                                    [確定]

配置web站點

修改php配置檔案引數
shell> vi /usr/local/php/lib/php.ini
==============================================================
date.timezone = Asia/Shanghai
post_max_size =32M
max_execution_time =300
max_input_time =300
==============================================================

啟動php-fpm、nginx
shell> /usr/local/php/sbin/php-fpm 
shell> /usr/local/nginx/nginx

透過web頁面配置zabbix

在瀏覽器中輸入會顯示

  1. Welcome ---> next
  2. Check of pre-requisites ---> next,如檢查不透過可能需要修改php配置檔案或動態擴充套件編譯php
  3. Configure DB connection ---> 輸入資料庫使用者資訊,Test connection, nest
  4. Zabbix server details ---> next
  5. Pre-Installation summary ---> next
  6. Install ---> Finish

使用預設賬號:admin 密碼:zabbix 登入

參考:
https://www.zabbix.com/documentation/2.4/manual/installation/install

整理自網路

Svoid
2015-07-02

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29734436/viewspace-2137840/,如需轉載,請註明出處,否則將追究法律責任。

相關文章