Zabbix server(離線版)安裝手冊

由於zabbix server需要依賴MySQL及PHP的相關依賴,因此需要先安裝好MySQL及PHP的相關依賴後方可安裝zabbixserver。

安裝MySQL

目錄mysql下的rpm

1.新建mysql用戶

useradd mysql;

passwd mysql;

2.用root用戶

先查看有沒有衝突,rpm -qa|grep mysql 如果已經有了卸載 rpm -e --nodeps

rpm -ivh mysql-community-common-5.7.9-1.el6.x86_64.rpm

rpm -ivh mysql-community-libs-5.7.9-1.el6.x86_64.rpm

rpm -ivh mysql-community-libs-compact-

rpm -ivh mysql-community-client-5.7.9-1.el6.x86_64.rpm

rpm -ivh mysql-community-server-5.7.9-1.el6.x86_64.rpm

rpm -ivh mysql-community-dev*

全安裝方式ls *|xargs rpm -ivh

3.按照自己規劃的目錄修改。

使用root修改/etc/my.cnf

datadir=/home/mysql/datadir

log-error=/home/mysql/logs/mysqld.log

pid-file=/home/mysql/mysqld/mysqld.pid

使用mysql用戶創建上述目錄 datadir logs及mysqld

//chown -R mysql:mysql /home/mysql/datadir

//chown -R mysql:mysql /home/mysql/logs/

//chown -R mysql:mysql /home/mysql/mysqld/

//根據/etc/my.cnf創建相應的文件,並授權

//mkdir -p /var/run/mysql

//mkdir -p /var/log/mysql

//chown -R mysql:mysql /var/log/mysql

//chown -R mysql:mysql /var/run/mysql

//注:/etc/my.cnf中沒有basedir路徑,需要添加

//basedir=/usr/local/mysql

4初始化數據庫

使用root用戶

cd /usr/bin

4.1創建一個有隨機密碼的root賬戶, 

mysqld --initialize --user=mysql

初始化成功後,查看該隨機密碼vi /home/mysql/logs/mysqld.log,最後一行記錄了密碼

使用mysql -u root -p,輸入隨機密碼就可以登錄

4.2 創建一個沒有密碼的root賬戶

mysqld --initialize-insecure --user=mysql

使用命令mysql -u root--skip-password 登錄

注:初始化時,mysqld服務會檢查數據目錄是否存在:

如果數據目錄不存在,mysqld則會創建它。

如果數據目錄存在,且不是空目錄(即包含有文件或子目錄),mysqld會顯示一條錯誤信息並中止:

       [ERROR] --initialize specified but thedata

        directory exists. Aborting.

解決方案: 將數據目錄重命名後,重新再初始化一次 mv /var/lib/mysql  /var/lib/mysql.bak8. 

4.配置mysql服務開機自動啓動

#檢查自啓動項列表中沒有mysqld這個,如果沒有就添加mysqld:

chkconfig --list mysqld

chkconfig --add mysqld

#設置開機啓動

chkconfig mysqld on

5.關閉SELinux(安全控制模塊)

查看是否關閉getenforce 或者sestatus -v

如果沒有執行命令 setenforce 0 命令設置臨時關閉,不用重啓生效

或者vi /etc/sysconfig/selinux 永久關閉 SELINUX=disabled

5.啓動mysql

#啓動mysqld服務

service mysqld start

#檢查mysqld是否已經啓動

service mysqld status

6修改mysql用戶密碼(初始root密碼文件在/home/mysql/log/mysqld.log)

mysql -u root -p 

mysql -u root --skip-password

mysql>alter user 'root'@'localhost' identified by 'unicom';

7.已root用戶身份登錄

mysql -uroot -punicom

8.賦權 (若已含有zabbix_new則需要,否則不需要執行)

grant all on zabbix_new.* to zabbix

安裝PHP及相關依賴

1.檢查gcc 及g++編譯器(make 時需要,centos編譯器目錄)

gcc -v

g++ -v

如果沒有g++

rpm -ivh libstdc-++**

rpm -ivh gcc-c++**

可以強制安裝(慎用):

rpm -ivh --force gcc-2.96-110.i386.rpm

rpm -ivh --nodeps --replacefilesgcc-c++-4.4.7-4.el6.x86_64.rpm (不依賴替代升級)

2.安裝openssl(httpd需要),httpd依賴目錄

檢查rpm -qa|grep-i openssl

如果沒有需要安裝

rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm

rpm -ivh keyutils-libs-devel-1.4-4.el6.x86_64.rpm

rpm -ivh libcom_err-devel-1.41.12-18.el6.x86_64.rpm

rpm -ivh libsepol-devel-2.0.41-4.el6.x86_64.rpm

rpm -ivh libselinux-devel-2.0.94-5.3.el6_4.1.x86_64.rpm

rpm -ivh krb5-devel-1.10.3-10.el6_4.6.x86_64.rpm

rpm -ivh openssl-devel-1.0.1e-15.el6.x86_64.rpm

全安裝ls *|xargs rpm -ivh

3.安裝libmcrypt

解壓包    tar -xzvf libmcrypt-2.5.8.tar.gz

cdlibmcrypt-2.5.8

./configure --prefix=/usr/local/libmcrypt/ --with-zlib=/usr/local/zlib/

make

make install

4.安裝httpd

httpd-2.2.29.tar.gz解壓

./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-ssl--with-ssl=/usr/lib64/ --enable-cgi

make

make install

修改/etc/httpd/conf/httpd.conf在httpd.conf 里加入如下幾句

AddTypeapplication/x-httpd-PHP .php

LoadModulephp5_module modules/libphp5 .so

<IfModulemod_php5.c>

       AddType application/x-httpd-php .php

       AddType application/x-httpd-php-source .phps

       </IfModule>

        做軟連接

ln -s /usr/local/apache2/modules/libphp5.so /usr/lib64/httpd/modules/libphp5.so(php安裝完了之後纔有)

5.安裝libxml2 及 libxml2-devel是否安裝了(php需要)

檢測是否安裝了 rpm -qa|grep libxml2

rpm -ivh rpm -ivh libxml2-devel-2.7.6-14.el6.x86_64.rpm

檢查/usr/lib/下是否有libxml2,若沒有按如下方式加入軟連接

ln -s /usr/lib64/libxml2.so   /usr/lib/libxml2.so

6.安裝libcurl-devel ,libidn, automake

在php依賴包的libcurl-devel目錄下

檢查是否已安裝:rpm-qa|grep libcurl-devel

libcurl-devel安裝

rpm -ivh autoconf-2.63-5.1.el6.noarch.rpm

rpm -ivh automake-1.11.1-4.el6.noarch.rpm

rpm -ivh libidn-devel-1.18-2.el6.x86_64.rpm

rpm -ivh libcurl-devel-7.19.7-37.el6_4.x86_64.rpm

7.檢查在/usr/lib 下mysql目錄是否存在,不存在建軟連接(已完成)

ln -s /usr/lib64/mysql   /usr/lib/mysql

8.安裝zlib

zlib-1.2.3.tar.gz

CFLAGS="-O3-fPIC" ./configure --prefix=/usr/local/zlib/

make

注:需要將目錄下的.a文件刪掉重新編譯才能使用。切記

make install

9.安裝libpng

libpng-1.5.13.tar.xz

./configure --prefix=/usr/local/libpng

xz -d *.xz

make

make install

安裝libpng-devel

rpm -ivh libpng-devel-1.2.49-1.el6_2.x86_64.rpm

10.安裝jpeg

jpegsrc.v6b.tar.gz

./configure --prefix=/usr/local/jpeg

mkdir -p /usr/local/jpeg/bin

mkdir -p /usr/local/jpeg/man/man1/

make

make install

需要自己建立目錄

查找jpeglib.h,沒有裝libjpeg-devel相關包

rpm -ivh libjpeg-turbo-devel-1.2.1-1.el6.x86_64.rpm

11.安裝freetype

freetype-2.1.10.tar

./configure --prefix=/usr/local/freetype

make

make install

先安裝vpx

rpm-ivh libvpx-1.3.0-5.el6_5.x86_64.rpm --nodeps

13.phpconfig ,按照實際情況修改/usr/local/apache2/bin/apxs,curl地址

php-5.6.21.tar

//MySQL安裝指定到/usr/local/mysql版

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql --with-mysqli=/usr/bin/mysql_config--with-iconv-dir=/usr/local --with-freetype-dir=/usr/local/freetype/--with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/libpng/--with-zlib=/usr/local/zlib/ --with-libxml-dir=/usr/local/libxml2 --enable-xml--disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl--with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect--enable-mbstring --with-mcrypt=/usr/local/libmcrypt/ --with-openssl  --with-mhash --enable-pcntl --enable-sockets--enable-opcache=no --with-ldap-sasl --with-xmlrpc--with-apxs2=/usr/local/apache2/bin/apxs --enable-gettext --enable-soap --without-pear--enable-bcmath --with-xpm-dir=/usr/lib64 --with-mysql=/usr/--with-mysqli=/usr/bin/mysql_config --with-vpx-dir=/usr/lib64/

 

//MySQL默認安裝rpm版

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config--with-iconv-dir=/usr/local --with-freetype-dir=/usr/local/freetype/--with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/libpng/--with-zlib=/usr/local/zlib/ --with-libxml-dir=/usr/local/libxml2 --enable-xml--disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl--with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm--enable-force-cgi-redirect --enable-mbstring --with-mcrypt=/usr/local/libmcrypt/--with-openssl  --with-mhash--enable-pcntl --enable-sockets --enable-opcache=no --with-ldap-sasl--with-xmlrpc --with-apxs2=/usr/local/apache2/bin/apxs --enable-gettext--enable-soap --without-pear --enable-bcmath --with-xpm-dir=/usr/lib64--with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config--with-vpx-dir=/usr/lib64/

 

//內存小於1G版

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config --with-iconv-dir=/usr/local--with-freetype-dir=/usr/local/freetype/ --with-jpeg-dir=/usr/local/jpeg/--with-png-dir=/usr/local/libpng/ --with-zlib=/usr/local/zlib/--with-libxml-dir=/usr/local/libxml2 --enable-xml --disable-rpath--enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop--enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers--enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect--enable-mbstring --with-mcrypt=/usr/local/libmcrypt/ --with-openssl  --with-mhash --enable-pcntl --enable-sockets--enable-opcache=no --with-ldap-sasl --with-xmlrpc--with-apxs2=/usr/local/apache2/bin/apxs --enable-gettext --enable-soap--without-pear --enable-bcmath --with-xpm-dir=/usr/lib64 --with-mysql=/usr/--with-mysqli=/usr/bin/mysql_config --with-vpx-dir=/usr/lib64/--disable-fileinfo

 

//內存小於1G最終版

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config--with-iconv-dir=/usr/local --with-freetype-dir=/usr/local/freetype/--with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/libpng/--with-zlib=/usr/local/zlib/ --with-libxml-dir=/usr/ --enable-xml--disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl--with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm--enable-force-cgi-redirect --enable-mbstring--with-mcrypt=/usr/local/libmcrypt/ --with-openssl  --with-mhash --enable-pcntl --enable-sockets--enable-opcache=no --with-ldap-sasl --with-xmlrpc--with-apxs2=/usr/local/apache2/bin/apxs --enable-gettext --enable-soap--without-pear --enable-bcmath --with-xpm-dir=/usr/lib64 --with-mysql=/usr/--with-mysqli=/usr/bin/mysql_config --with-vpx-dir=/usr/lib64/--disable-fileinfo

 

//內存大於1G最終版

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc--with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config--with-iconv-dir=/usr/local --with-freetype-dir=/usr/local/freetype/ --with-jpeg-dir=/usr/local/jpeg/--with-png-dir=/usr/local/libpng/ --with-zlib=/usr/local/zlib/--with-libxml-dir=/usr/ --enable-xml --disable-rpath --enable-discard-path--enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem--enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex--enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring--with-mcrypt=/usr/local/libmcrypt/ --with-openssl  --with-mhash --enable-pcntl --enable-sockets--enable-opcache=no --with-ldap-sasl --with-xmlrpc--with-apxs2=/usr/local/apache2/bin/apxs --enable-gettext --enable-soap--without-pear --enable-bcmath --with-xpm-dir=/usr/lib64 --with-mysql=/usr/--with-mysqli=/usr/bin/mysql_config --with-vpx-dir=/usr/lib64/

 

make

make install

14.配置php.ini,拷貝到/usr/local/php/etc下,可以使用<?php phpinfo(); ?>檢測路徑

修改php.ini-development

max_execution_time =300

post_max_size =32M

max_input_time =300

date.timezone=PRC

always_populate_raw_post_data=-1

cp php.ini-development /usr/local/php/etc/php.ini

12.安裝gd(php安裝完成後再安裝)

cd /root/software/php-5.6.21/ext/gd

執行:

/usr/local/php/bin/phpize(php安裝完後增加擴展時使用)

#./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg=/usr/local/jpeg--with-png=/usr/local/libpng --with-freetype=/usr/local/freetype

./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir=/usr/local/jpeg--with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype

創建擴展,需要在/usr/local/php/etc/php.ini配置擴展

make

make install

然後打開/usr/local/php/etc/php.ini

找到;extension=/path/to/extension/msql.so增加一條:

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/gd.so

安裝gettext

cd /root/software/php-5.6.21/ext/gettext

執行:

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

然後打開/usr/local/php/etc/php.ini

創建擴展,需要在/usr/local/php/etc/php.ini配置擴展

extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/gettext.so

在/var/www/html/下,建立test.php文件測試擴展包是否正確

<?php

php info();

?>

php -r "phpinfo()"

15.啓動hppted

service httpd start

安裝zabbix

1.安裝依賴包(net-snmp*.rpm) (已完成)

rpm -ivh elfutils-libelf-devel-0.152-1.el6.x86_64.rpm

rpm -ivh elfutils-devel-0.152-1.el6.x86_64.rpm

rpm -ivh lm_sensors-devel-3.1.1-17.el6.x86_64.rpm

rpm -ivh tcp_wrappers-devel-7.6-57.el6.x86_64.rpm

rpm -ivh file-devel-5.04-15.el6.x86_64.rpm

rpm -ivh popt-devel-1.13-7.el6.x86_64.rpm

rpm -ivh rpm-devel-4.8.0-37.el6.x86_64.rpm

rpm -ivh net-snmp-devel-5.5-49.el6.x86_64.rpm

2.安裝zabbix

zabbix-3.0.2.tar.gz

./configure --prefix=/home/zabbix --enable-server --enable-agent --enable-proxy--with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl--with-libxml2

make

make install

3.創建zabbix用戶及相應目錄

//檢查是否已創建完成zabbix用戶

useradd zabbix

passwd zabbix

mkdir -p /var/log/zabbix/

chown -R zabbix:zabbix /var/log/zabbix

4.創建zabbix數據庫

CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

5.創建mysql用戶

grantall privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix';

flush privileges;

6.在zabbix的database目錄下導入數據庫,數據文件

cd /root/software/zabbix-3.0.2/database/mysql

mysql -uroot -punicom zabbix < schema.sql;

mysql -uroot -punicom zabbix < images.sql;

mysql -uroot -punicom zabbix < data.sql;

7.需要關閉iptables

查看防火牆狀態:

[root@centos6~]# service iptables status

iptables:未運行防火牆。

開啓防火牆:

[root@centos6~]# service iptables start

關閉防火牆:

[root@centos6~]# service iptables stop

配置防火牆,開啓80端口、3306端口

vi /etc/sysconfig/iptables #編輯防火牆配置文件

#Firewall configuration written by system-config-firewall

#Manual customization of this file is not recommended.

*filter

:INPUTACCEPT [0:0]

:FORWARDACCEPT [0:0]

:OUTPUTACCEPT [0:0]

-AINPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

-AINPUT -p icmp -j ACCEPT

-AINPUT -i lo -j ACCEPT

-AINPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

-AINPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

-AINPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

-AINPUT -j REJECT --reject-with icmp-host-prohibited

-AFORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

8.拷貝界面到www目錄下

#根據自己設置的目錄來

cp -rf /root/software/zabbix-3.0.2/frontends/php /var/www/html/zabbix

cp -rf /root/software/zabbix-3.0.2/frontends/php /usr/local/apache2/htdocs/zabbix(必須要設置,否則看不到)

service httpd restart

9.配置服務端服務

#根據實際安裝路徑來

cp /usr/local/src/zabbix-2.2.6/misc/init.d/fedora/core/zabbix_server/etc/rc.d/init.d/zabbix_server #服務端

cp /usr/local/src/zabbix-2.2.6/misc/init.d/fedora/core/zabbix_agentd/etc/rc.d/init.d/zabbix_agentd #客戶端

chmod +x /etc/rc.d/init.d/zabbix_server #添加腳本執行權限

chmod +x /etc/rc.d/init.d/zabbix_agentd #添加腳本執行權限

chkconfig zabbix_server on #添加開機啓動

10.查看zabbix_server.config配置是否正確

zabbix_server.config信息

vi /home/zabbix/etc/zabbix_server.conf

注:主要配置數據庫信息

詳細查閱:

http://blog.csdn.net/csolo/article/details/53083033

servicezabbix_server start  啓動zabbix-server

11設置/etc/systemd/logind.confRemoveIPC=no

訪問zabbix地址

http://ip/zabbix/setup.php

注:具體安裝路徑需以實際安裝路徑爲準

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章