您的位置:首页 > 编程语言 > PHP开发

Zabbix2.4 升级到3.0

2016-09-24 10:40 435 查看
软件升级前升级后
Php5.3.35.6.6 (要求>5.4)
Apache2.2.152.2.15(不变)
Mysql5.1.735.1.73(不变)
CentOSCentOS 6.3 x86_64CentOS 6.3 x86_64(不变)
Zabbix2.4.43.0.4
前提:zabbix2.4.4 正在运行中。 已有apache+mysql+php环境。Centos6.3 yum安装的php是5.3 版本,故接下来采用编译的方式安装php5.6.6Apache和mysql无需升级。在同一台服务器上升级,升级期间的数据会丢失。 1.1 编译php
1.1.1 安装一些基础软件包
yum -y install bzip2-devel libxml2-devel libxml2 httpd-devel icu libicu libicu-devellibpng* gcc 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/freetypemake && make install 1.1.3 编译jpeg
tar zxvf jpegsrc.v8b.tar.gz cd jpegcd jpeg-8b/./configure --prefix=/usr/local/jpeg --enable-sharedmake && 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/libpngmakemake install 1.1.6 编译libgd
tar xvf libgd-2.2.2.tarcd libgd-2.2.2./configure --prefix=/usr/local/gd2make && make install 1.1.7 编译php:
tar jxvf php-5.6.6.tar.bz2cd 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-fpmmake && make install 1.1.8 拷贝php执行文件
mv /usr/bin/php /usr/bin/php.bakln -s /usr/local/php/bin/php /usr/bin/php 1.1.9 查看版本
php -v

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-libxml2make install

1.2.2 配置zabbix
cd /var/www/html/mv zabbix zabbix.bakcp -r /root/zabbix-3.0.4/frontends/php zabbixchown -R apache.apache zabbix 1.2.3 上传中文字体

上传字体(楷体常规)到/var/www/html/zabbix/fonts/

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 namedefine('ZBX_GRAPH_FONT_NAME', ‘simkai'); // font file name 1.3 mysql
注:grant localhost 权限,但zabbix无法读取到数据库zabbix,后来改成ip,可以正常连接访问。虽然我使用了mysqldump备份。但因为我的mysql是单机,dump的时候,锁库,导致数据也无法写入。而且dump之后的sql文件source恢复非常慢。(花了2,3个小时,才source了2,3G 数据。 线上mysql data总共15G左右。)不过还好zabbix能自动升级数据库,只是丢了小部分时间的监控数据,影响不大。1.3.1 mysql权限修改
mysql -pgrant all privileges on zabbix.* to zabbix@192.168.2.68 identified by 'zabbix';flush privileges;

1.3.2 修改zabbix.conf.php
vim /var/www/html/zabbix/conf/zabbix.conf.php$DB['SERVER'] 由localhost改为服务器ip$DB['PASSWORD'] 由空改为你的密码

1.4 Apache
重启apacheService httpd restart 1.5 启动zabbix3.0.4
mv /usr/sbin/zabbix_server /usr/sbin/zabbix_server.bak(2.4版本备份,或者删除)ln -s /root/zabbix-3.0.4/src/zabbix_server/zabbix_server /usr/sbin/zabbix_server zabbix_server //启动zabbix1.5.1 启动并查看进程


通过1.5.2 通过日志查看数据库正常升级
[root@localhost conf]# tail -f /tmp/zabbix_server.log

1.6 配置zabbix开机自启动
cp /root/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_serverln -s /usr/sbin/zabbix_server /usr/local/sbin/zabbix_serverservice zabbix_server start chkconfig --add zabbix_serverchkconfig --level 345 zabbix_server onchkconfig --list zabbix_server




1.7 完成界面


以上是踩坑之后整理的,一些步骤已经成功避过坑了。接下来记录一下踩过的坑。
2 报错
2.1 安装libpng报错:
报错:pngfix.c:2151: undefined reference to `inflateReset2'解决:

开始安装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库的安装位置

解决方法:1.rpm -ql libXpm :查询出libXpm的安装位置,发现在/usr/lib64/ 下2.重新编译php,./configure中增加 --with-xpm-dir=/usr/lib64/ 3.make && make install 成功!
2.2 网页访问,数据库报错如下


解决方法:网上大部分都是说重新导入zabbix的 数据架构。Image.sql,schema.sql等。但这不能解决问题。 主要还是因为php编译部分参数有问题导致zabbix升级数据库失败了,于是报了这个错,正确编译php(编译参数较多),然后启动zabbix,zabbix会自动升级数据库。 11033:20160426:152119.126 current database version (mandatory/optional): 02040000/0204000011033: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.conf37106:20160923:102819.657 current database version (mandatory/optional): 03000000/0300000037106:20160923:102819.657 required mandatory version: 03000000 2.3 Php编译少了png支持
通过写文件index.php 查看php是否支持


通过访问网页查看http://192.168.2.68/index.php查看gd不支持png。

解决方法: 编译参数不对。原编译参数:./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 后把freetype、libpng、gd等重新编译改为:./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支持更多。

2.4 启动zabbix日志报错
报错:无法连接上数据库:

解决方法:1. 给数据库权限,


2. 并修改 zabbix.conf.php文件。
vim /var/www/html/zabbix/conf/zabbix.conf.php$DB['SERVER'] $DB['PASSWORD']

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php 升级 mysql zabbix3.0