2018年第五週-centos7安裝zabbix-server(源碼安裝方式)

前期準備:
安裝mysql5.6和php5.6(本文後面有講如何安裝php),想知道怎麼裝mysql的請出門左轉(在centos7安裝mysql6php

  1. 下載zabbix源碼zabbix-3.4.6.tar.gz,網頁地址:https://www.zabbix.com/downlo...
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.6/zabbix-3.4.6.tar.gz
  1. 解壓進入目錄
tar -zxvf zabbix-3.4.6.tar.gz
cd zabbix-3.4.6
  1. 建立zabbix用戶(否則啓動zabbix服務或zabbix代理是不給的)
groupadd zabbix
useradd -g zabbix zabbix
  1. 配置源碼,zabbix分爲服務端zabbix_server和zabbix_agentd,如下配置時服務端的配置
./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
  1. 編譯安裝
make install
  1. zabbix分爲服務端zabbix_server和zabbix_agentd,安裝好服務端後,就修改服務端的配置 /usr/local/etc/zabbix_server.conf
### Option: DBHost  數據庫地址
#    Database host name.
#    If set to localhost, socket is used for MySQL.
#    If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
DBHost=localhost

### Option: DBName  數據庫名稱
#    Database name.
#    For SQLite3 path to database file must be provided. DBUser and DBPassword are ignored.
#
# Mandatory: yes
# Default:
# DBName=

DBName=zabbix


### Option: DBUser  數據庫帳號
#    Database user. Ignored for SQLite.
#
# Mandatory: no
# Default:
# DBUser=

DBUser=zabbix

### Option: DBPassword 數據庫密碼
#    Database password. Ignored for SQLite.
#    Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
DBPassword=zabbix
  1. 運行數據庫腳本zabbix支持mysqMySQL、PostgreSQL、Oracle、IBM DB2和SQLite數據庫,咱們就挑最經常使用的mysql
shell> mysql -uroot -p<password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
mysql> quit;
shell> cd database/mysql
shell> mysql -uzabbix -p<password> zabbix < schema.sql
# stop here if you are creating database for Zabbix proxy
shell> mysql -uzabbix -p<password> zabbix < images.sql
shell> mysql -uzabbix -p<password> zabbix < data.sql
  1. 啓動服務端
zabbix_server
  1. 新建zabbix的頁面目錄
mkdir /var/www/html/zabbix
  1. 複製zabbix的php目錄到剛剛建立的目錄裏
cd frontends/php
cp -a . /var/www/html/zabbix
  1. 訪問頁面,開始配置數據庫等信息(注意,這是頁面接口,跟剛剛zabbix_server是兩回事,不要覺得剛剛配置的zabbix_server.conf配置了數據庫就沒事了)
http://192.168.31.190/zabbix
  1. 這時候訪問頁面會發現zabbix檢查到一些依賴沒配置好:
Minimum required size of PHP post is 16M (configuration option "post_max_size").
Minimum required limit on execution time of PHP scripts is 300 (configuration option "max_execution_time").
Minimum required limit on input parse time for PHP scripts is 300 (configuration option "max_input_time").
Time zone for PHP is not set (configuration parameter "date.timezone").
PHP bcmath extension missing (PHP configuration parameter --enable-bcmath).
PHP option "always_populate_raw_post_data" must be set to "-1"
  1. 此時須要修改 /etc/php.ini把上述配置修改好
date.timezone = Asia/Shanghai
extension=bcmath.so
  1. 重啓httpd
systemctl restart httpd
  1. 而後在從新訪問zabbix頁面,就沒fail的檢查,而後下一步,配置數據庫信息,再下一步,設置zabbix_server的域名和zabbix_server的監聽端口(再次提醒,zabbix_server和php頁面是兩回事,不是同一個東西),若是zabbix_server的域名和端口配置錯誤,在zabbix的dashboard裏顯示Zabbix server is running是no
  2. 頁面生成一個php的配置文件zabbix.conf.php,下載下來,而後放在/var/www/html/zabbix/conf/目錄下面。
  3. 這樣zabbix就安裝成功了,默認帳號密碼(name is Admin, password zabbix),剩下的就是配置agentd節點了。

安裝apache和php

安裝apache和php,能夠參考《centos6.7下搭配apache php mysql環境》,注意那篇文章安裝的多是php5.3,若是是5.3會報錯:html

syntax error, unexpected '[' in /var/www/html/zabbix/index.php on line 32

官網說https://support.zabbix.com/br...
須要php5.4以上。因而卸載了php5.3,從新安裝5.6mysql

yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-xml.x86_64 php56w-bcmath.x86_64

若是鏡像沒有,需先安裝鏡像linux

Centos 5.X
    rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm
  CentOs 6.x
    rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
  CentOs 7.X
    rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

TroubleShoot

  1. MySQL library not found
yum install mysql-devel -y
  1. LIBXML2 not found
yum install libxml2-devel -y
  1. Invalid Net-SNMP directory - unable to find net-snmp-config
yum install net-snmp-devel -y
  1. Unable to use libevent (libevent check failed)
yum install libevent-devel -y
  1. Curl library not found
yum install curl-devel -y
  1. WARNING: 'aclocal-1.15' is missing on your system.
6.1安裝 autoconf-2.63-5.1.el6.noarch.rpmautomake-1.11.1-4.el6.noarch.rpm
6.2 運行
autoreconf -ivf
相關文章
相關標籤/搜索