Zabbix Server 3.0.7 Centos6.5編譯安裝

前言

服務器上線對於雲服務商來說已經做得非常的完成,各種主機的監控數據。直觀的反應服務器的運行狀態、負載等,如AWS、Aliyun等。有時候需要對具體的程序進行監控如JVM MySQL Redis等,嘗試了Zabbix 、Negios這兩個監控解決方案,在此記錄下編譯安裝過程。

環境

-系統:centos6.5
-軟件:Zabbix 3.0.7 源碼

前提

  • selinux狀態關閉
vi /etc/selinux/config
SELINUX=disabled
#重啓服務器
  • 下載zabbix 3.0.7 安裝包
cd /tmp
wget http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.7/zabbix-3.0.7.tar.gz
tar -zxvf zabbix-3.0.7.tar.gz
#配置my.cnf
[mysqld]
innodb_file_per_table=1
  • 編譯環境
yum -y install gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel
  • 安裝PHP5.6 及Httpd
rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm

yum -y install httpd php56w php56w-gd php56w-mysqlnd php56w-bcmath php56w-mbstring php56w-xml php56w-ldap

#配置php.ini
vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
always_populate_raw_post_data = -1

#配置httpd.conf
vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
DirectoryIndex index.html index.html.var index.php

Zabbix Installation

  • 創建zabbix 用戶組和用戶
groupadd zabbix
useradd -g zabbix zabbix
  • 編譯及安裝
    將zabbix 安裝到/usr/local/zabbix下
cd /tmp/zabbix-3.0.7/

./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --enable-java --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --prefix=/usr/local/zabbix

make install
  • 修改配置文件zabbix_server.conf
vim /usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
  • 安裝前端Web
#創建前端Web文件
mkdir /var/www/html/zabbix

cd /tmp/zabbix-3.0.7/frontends/php/
cp -a . /var/www/html/zabbix/

#設置apache的執行和所有者
chown -R apache:apache /var/www/html/zabbix

#賦予可執行權限
chmod +x /var/www/html/zabbix/conf/
  • 添加Zabbix服務器和Zabbix代理啓動腳本
cp /tmp/zabbix-3.0.7/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
cp /tmp/zabbix-3.0.7/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd

#修改 /etc/init.d/zabbix_server /etc/init.d/zabbix_agentd的BASEDIR=/usr/local/爲BASEDIR=/usr/local/zabbix
  • 導入數據庫
    登錄數據庫,創建zabbix用戶並導入模板db
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| zabbix             |
+--------------------+

use zabbix;

source /tmp/zabbix-3.0.7/database/mysql/schema.sql;
source /tmp/zabbix-3.0.7/database/mysql/data.sql;
source /tmp/zabbix-3.0.7/database/mysql/images.sql;

show tables;
+----------------------------+
| Tables_in_zabbix           |
+----------------------------+
| acknowledges               |
| actions                    |
| alerts                     |
| application_discovery      |
| application_prototype      |
| application_template       |
| applications               |
| auditlog                   |
| auditlog_details           |
| autoreg_host               |
| conditions                 |
| config                     |
| dbversion                  |
| dchecks                    |
| dhosts                     |
| drules                     |
| dservices                  |
| escalations                |
| events                     |
| expressions                |
| functions                  |
| globalmacro                |
| globalvars                 |
| graph_discovery            |
| graph_theme                |
| graphs                     |
| graphs_items               |
| group_discovery            |
| group_prototype            |
| groups                     |
| history                    |
| history_log                |
| history_str                |
| history_text               |
| history_uint               |
| host_discovery             |
| host_inventory             |
| hostmacro                  |
| hosts                      |
| hosts_groups               |
| hosts_templates            |
| housekeeper                |
| httpstep                   |
| httpstepitem               |
| httptest                   |
| httptestitem               |
| icon_map                   |
| icon_mapping               |
| ids                        |
| images                     |
| interface                  |
| interface_discovery        |
| item_application_prototype |
| item_condition             |
| item_discovery             |
| items                      |
| items_applications         |
| maintenances               |
| maintenances_groups        |
| maintenances_hosts         |
| maintenances_windows       |
| mappings                   |
| media                      |
| media_type                 |
| opcommand                  |
| opcommand_grp              |
| opcommand_hst              |
| opconditions               |
| operations                 |
| opgroup                    |
| opinventory                |
| opmessage                  |
| opmessage_grp              |
| opmessage_usr              |
| optemplate                 |
| profiles                   |
| proxy_autoreg_host         |
| proxy_dhistory             |
| proxy_history              |
| regexps                    |
| rights                     |
| screen_user                |
| screen_usrgrp              |
| screens                    |
| screens_items              |
| scripts                    |
| service_alarms             |
| services                   |
| services_links             |
| services_times             |
| sessions                   |
| slides                     |
| slideshow_user             |
| slideshow_usrgrp           |
| slideshows                 |
| sysmap_element_url         |
| sysmap_url                 |
| sysmap_user                |
| sysmap_usrgrp              |
| sysmaps                    |
| sysmaps_elements           |
| sysmaps_link_triggers      |
| sysmaps_links              |
| timeperiods                |
| trends                     |
| trends_uint                |
| trigger_depends            |
| trigger_discovery          |
| triggers                   |
| users                      |
| users_groups               |
| usrgrp                     |
| valuemaps                  |
+----------------------------+
113 rows in set (0.00 sec)

exit
  • 啓動及開機自啓動
#啓動
/etc/init.d/httpd start
/etc/init.d/zabbix_server start
/etc/init.d/zabbix_agentd start

# 開機自啓動
chkconfig httpd on
chkconfig --add /etc/init.d/zabbix_server
chkconfig --add /etc/init.d/zabbix_agentd
chkconfig zabbix_server on
chkconfig zabbix_agentd on

安裝完成後,登陸:
用戶名:Admin
密碼:zabbix

至此,Zabbix Server和本地agent已經安裝完成。登錄後進行簡單的配置,就可以清楚的看到本臺機器的相關監控信息。

參考:http://www.cnblogs.com/zzzhfo/p/5820321.html
http://www.linuxidc.com/Linux/2016-07/132897.htm
http://blog.chinaunix.net/uid-25266990-id-3380929.html

發佈了193 篇原創文章 · 獲贊 115 · 訪問量 71萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章