Zabbix2.4 升級到3.0


 

軟件

升級前

升級後

Php

5.3.3

5.6.6 (要求>5.4

Apache

2.2.15

2.2.15(不變)

Mysql

5.1.73

5.1.73(不變)

CentOS

CentOS 6.3 x86_64

CentOS 6.3 x86_64(不變)

Zabbix

2.4.4

3.0.4

 

 

前提:

zabbix2.4.4 正在運行中。 已有apache+mysql+php環境。

Centos6.3 yum安裝的php5.3 版本,故接下來採用編譯的方式安裝php5.6.6

Apachemysql無需升級。

在同一臺服務器上升級,升級期間的數據會丟失。

 

1.1 編譯php

1.1.1 安裝一些基礎軟件包

yum -y install bzip2-devel libxml2-devel libxml2 httpd-devel icu libicu libicu-devellibpnggcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel

 

1.1.2 編譯freetype

tar zxvf freetype-2.5.5.tar.gz

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

make && make install

 

1.1.3 編譯jpeg

tar zxvf jpegsrc.v8b.tar.gz 

cd jpeg

cd jpeg-8b/

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

make && make install


1.1.4 編譯zlib

tar zxvf zlib-1.2.8.tar.gz 

cd zlib-1.2.8

 ./configure 

make && make install 

 

1.1.5 編譯libpng

tar zxvf libpng-1.5.9.tar.gz 

cd libpng-1.5.9

--prefix=/usr/local/libpng

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

make

make install

 

1.1.6 編譯libgd

tar xvf libgd-2.2.2.tar

cd libgd-2.2.2

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

make && make install

 

 

1.1.7 編譯php:

tar jxvf php-5.6.6.tar.bz2

cd php-5.6.6

./configure --prefix=/usr/local/php --with-config-file-path=/etc/ --with-apxs2=/usr/sbin/apxs --with-bz2 --with-curl  --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --with-libxml-dir=/usr/local --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-gettext --with-zlib-dir=/usr/local/zlib --with-gd=/usr/local/gd2  --with-xpm-dir=/usr/lib64/ --enable-sockets --disable-ipv6 --enable-gd-native-ttf --enable-mbstring --enable-bcmath --enable-calendar --enable-dom --enable-xml --enable-fpm

make && make install

 

 

1.1.8 拷貝php執行文件

mv /usr/bin/php /usr/bin/php.bak

ln -s /usr/local/php/bin/php /usr/bin/php

 

1.1.9 查看版本

php -v 

wKioL1fl5DmywtmbAAA0jrks7ns009.png-wh_50

1.1.10 修改php.ini

always_populate_raw_post_data = On 改爲

always_populate_raw_post_data = -1

 

1.2 Zabbix3.0

1.2.1 編譯zabbix3.0

 

tar zxvf zabbix-3.0.4.tar.gz

./configure --prefix=/etc/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

make install

 

wKiom1fl5EeTN7zHAAAxAS5PdEs782.png-wh_50

 

1.2.2 配置zabbix

cd /var/www/html/

mv zabbix zabbix.bak

cp -r /root/zabbix-3.0.4/frontends/php zabbix

chown -R apache.apache zabbix

 

1.2.3 上傳中文字體

上傳字體(楷體常規)到/var/www/html/zabbix/fonts/ 

wKioL1fl5HzD1I6zAAAybYsy7oQ869.png-wh_50

sed -i 's/DejaVuSans/simkai/g' /var/www/html/zabbix/include/defines.inc.php

完成後看到如下:

//define('ZBX_FONT_NAME', 'DejaVuSans');

define('ZBX_FONT_NAME', ' simkai');

 

//define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); // font file name

define('ZBX_GRAPH_FONT_NAME', simkai'); // font file name

 

1.3 mysql

注:grant localhost 權限,但zabbix無法讀取到數據庫zabbix,後來改成ip,可以正常連接訪問。

雖然我使用了mysqldump備份。但因爲我的mysql是單機,dump的時候,鎖庫,導致數據也無法寫入。而且dump之後的sql文件source恢復非常慢。(花了2,3個小時,才source2,3G 數據。 線上mysql data總共15G左右。)不過還好zabbix能自動升級數據庫,只是丟了小部分時間的監控數據,影響不大。

1.3.1 mysql權限修改

mysql -p

grant all privileges on zabbix.* to [email protected] identified by 'zabbix';

flush privileges;

wKiom1fl5JWRMbmHAABXrlGX69I064.png-wh_50

1.3.2 修改zabbix.conf.php

vim /var/www/html/zabbix/conf/zabbix.conf.php

$DB['SERVER']   localhost改爲服務器ip

$DB['PASSWORD'] 由空改爲你的密碼

wKioL1fl5KWgQ08VAABO6XDBR8Y974.png-wh_50

1.4 Apache

重啓apache

Service httpd restart

 

1.5 啓動zabbix3.0.4

mv /usr/sbin/zabbix_server /usr/sbin/zabbix_server.bak2.4版本備份,或者刪除)

ln -s /root/zabbix-3.0.4/src/zabbix_server/zabbix_server /usr/sbin/zabbix_server

 

zabbix_server               //啓動zabbix

1.5.1 啓動並查看進程

wKioL1fl5POxPzqEAABk5e-qK9U310.png-wh_50

通過

1.5.2 通過日誌查看數據庫正常升級

[root@localhost conf]# tail -f /tmp/zabbix_server.log

wKiom1fl5YqDg-QJAACRO2CwHaM436.png-wh_50

 

1.6 配置zabbix開機自啓動

cp /root/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server

ln -s /usr/sbin/zabbix_server /usr/local/sbin/zabbix_server

service zabbix_server start

 

chkconfig --add zabbix_server

chkconfig --level 345 zabbix_server on

chkconfig --list zabbix_server

wKioL1fl5ajDeNKNAABdXbRO5yY679.png-wh_50







1.7 完成界面

wKiom1fl5anhcgvcAAA-UFJe0Uc411.png-wh_50

 

 

 

以上是踩坑之後整理的,一些步驟已經成功避過坑了。接下來記錄一下踩過的坑。


報錯

2.1 安裝libpng報錯:

報錯:

pngfix.c:2151: undefined reference to `inflateReset2'

解決:

wKiom1fl5vKRYBqYAABLXBsN0X0771.png-wh_50

開始安裝libpng1.6.6 ,版本之間不匹配,於是更換了版本 /libpng-1.5.9問題解決

參考鏈接

http://stackoverflow.com/questions/19738464/pngfix-c2151-undefined-reference-to-inflatereset2



 

報錯:

configure: error: Problem with libpng.(a|so) or libz.(a|so). Please check config.log for more information.

 

解決:

重新編譯zlib


報錯:

ext/gd/gd.c:1330: undefined reference to `XpmLibraryVersion'

問題說明:沒有找到xpm庫的安裝位置

wKioL1fl5amjLZ_SAABM-2iTKwM318.png-wh_50

解決方法

1.rpm -ql libXpm :查詢出libXpm的安裝位置,發現在/usr/lib64/ 

2.重新編譯php./configure中增加 --with-xpm-dir=/usr/lib64/ 

3.make && make install 成功!


2.2 網頁訪問,數據庫報錯如下

wKiom1fl5aqxMF0CAABZLNY6imY338.png-wh_50

 

解決方法:網上大部分都是說重新導入zabbix 數據架構。Image.sqlschema.sql等。但這不能解決問題。 主要還是因爲php編譯部分參數有問題導致zabbix升級數據庫失敗了,於是報了這個錯,正確編譯php(編譯參數較多)然後啓動zabbixzabbix會自動升級數據庫。

 

11033:20160426:152119.126 current database version (mandatory/optional): 02040000/02040000

11033:20160426:152119.126 required mandatory version: 02040000

自動升級成功後,可看到日誌

more /var/log/zabbix/zabbix_server.log

 

37106:20160923:102819.654 using configuration file: /etc/zabbix/etc/zabbix_server.conf

37106:20160923:102819.657 current database version (mandatory/optional): 03000000/03000000

37106:20160923:102819.657 required mandatory version: 03000000

 

2.3 Php編譯少png支持

通過寫文件index.php 查看php是否支持

wKioL1fl5sPRP3PrAAAvtBcZOwI058.png-wh_50


通過訪問網頁查看

http://192.168.2.68/index.php

查看gd不支持png

wKiom1fl5auhs8gHAAA1odMlbjU586.png-wh_50

解決方法 編譯參數不對。

原編譯參數:

./configure --prefix=/usr/local/php --with-config-file-path=/etc/ --with-apxs2=/usr/sbin/apxs --with-bz2 --with-curl --with-libdir=lib64 --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --with-libxml-dir=/usr/local --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-gettext --with-zlib --with-gd --enable-sockets --disable-ipv6 --enable-gd-native-ttf--enable-mbstring --enable-bcmath --enable-calendar --enable-dom --enable-xml --enable-fpm

 

後把freetypelibpnggd等重新編譯

改爲:

./configure --prefix=/usr/local/php --with-config-file-path=/etc/ --with-apxs2=/usr/sbin/apxs --with-bz2 --with-curl  --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --with-libxml-dir=/usr/local --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --with-gettext --with-zlib-dir=/usr/local/zlib --with-gd=/usr/local/gd2  --with-xpm-dir=/usr/lib64/ --enable-sockets --disable-ipv6 --enable-gd-native-ttf --enable-mbstring --enable-bcmath --enable-calendar --enable-dom --enable-xml --enable-fpm

 

注:紅色部分有改變。

 

重新編譯,再次訪問index.php

可以看到gd支持更多。

wKioL1fl5azCvOUbAABa_tXjrBg948.png-wh_50

2.4 啓動zabbix日誌報錯

報錯:無法連接上數據庫:

wKiom1fl5nDSWVb4AAA9g7cmdZk966.png-wh_50

解決方法:

1. 給數據庫權限,

wKioL1fl5nGDnM8YAABXd60TnWo782.png-wh_50

2. 並修改 zabbix.conf.php文件。

vim /var/www/html/zabbix/conf/zabbix.conf.php

$DB['SERVER']   

$DB['PASSWORD']

wKiom1fl5nLB9mBfAABlNDurOuQ939.png-wh_50


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