本文適用於在CentOS6下zabbix2.2及以上版本升級到zabbix3.0。
php
zabbix3.0的環境要求:
mysql
Software | Version | Comments |
MySQL | 5.0.3 or later | |
Apache | 1.3.12 or later | |
PHP | 5.4.0 or later | PHP v7 is not supported yet. |
libcurl | For SMTP authentication, version 7.20.0 or higher is required. |
因爲CentOS6默認的php和libcurl版本均不知足要求,因此須要使用第三方yum源升級。nginx
升級前的版本:git
PHP 5.3.3
github
curl 7.19.7web
Zabbix server v2.2.10sql
Zabbix Agent (daemon) v2.2.10數據庫
升級後的版本:centos
PHP 5.6.18緩存
curl 7.47.1
zabbix_server (Zabbix) 3.0.0
zabbix_agentd (daemon) (Zabbix) 3.0.0
0.升級前的準備
1)安裝yum多線程下載插件axelget,提高下載速度
下載地址:http://down.51cto.com/data/2183091
rpm -ivh http://pkgs.repoforge.org/axel/axel-2.4-1.el6.rf.x86_64.rpm cp axelget.conf /etc/yum/pluginconf.d/ cp axelget.py /usr/lib/yum-plugins/
網絡質量對yum的影響較大,若是yum執行過程當中網絡超時,能夠多嘗試幾回。
2)中止服務
# 中止zabbix server和agent service zabbix-server stop service zabbix-agent stop # 中止Nginx和php-fpm(LNMP) service nginx stop service php-fpm stop # 中止Apache(LAMP) service httpd stop
3)備份zabbix數據庫
# 數據庫zabbix,用戶名zabbix mysqldump --opt -R -uzabbix -p zabbix \ --ignore-table=zabbix.history \ --ignore-table=zabbix.history_log \ --ignore-table=zabbix.history_str \ --ignore-table=zabbix.history_text \ --ignore-table=zabbix.history_uint \ --ignore-table=zabbix.trends \ --ignore-table=zabbix.trends_uint | gzip > zabbix_`date +'%Y%m%d%H%M%S'`.sql.gz
上述備份命令忽略了history相關表和trends相關表,備份文件使用gzip壓縮。
1.升級php到5.6
# 安裝epel yum源 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm # 安裝php5.6 yum源 rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm # 升級php版本到5.6 yum install yum-plugin-replace -y yum replace php-common --replace-with=php56w-common -y
# 驗證php版本 php -v php-fpm -v
zabbix官方文檔要求:若是php版本>=5.6.0要設置php.ini裏always_populate_raw_post_data = -1。
2.升級libcurl到7.47
# 安裝新版libcurl的yum源 rpm -ivh http://mirror.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-1-13.rhel6.noarch.rpm # 升級libcurl到7.47 yum upgrade libcurl # 升級完成後能夠卸載此yum源 rpm -e city-fan.org-release
# 驗證curl版本 curl -V
3.升級Zabbix server到3.0
# 升級centos6的zabbix官方yum源(官方yum源沒有提供CentOS6版本的zabbix3.0 server) rpm -Uvh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm # 下載itnihao打包好的CentOS6版本的zabbix3.0 rpm包,感謝itnihao奉獻 mkdir /data cd /data yum install git createrepo -y git clone https://github.com/zabbixcn/zabbix3.0-rpm.git # 建立zabbix3.0本地yum源 createrepo /data/zabbix3.0-rpm/RPMS cat > /etc/yum.repos.d/zabbix3.0.repo << 'EOF' [zabbix3.0] name=zabbix3.0 itnihao baseurl=file:///data/zabbix3.0-rpm/RPMS enabled=0 gpgcheck=0 EOF # 重建yum緩存 yum clean all yum makecache # yum升級zabbix3.0相關服務(注意:要禁止epel源) yum --disablerepo=epel --enablerepo=zabbix3.0 upgrade zabbix-server-mysql zabbix-agent zabbix-get zabbix-sender
# 升級完成後檢查zabbix server和agent版本 zabbix_server_mysql -V zabbix_agentd -V
# 啓動zabbix-server和zabbix-agent service zabbix-server start service zabbix-agent start # 加入開機啓動 chkconfig zabbix-server on chkconfig zabbix-agent on
zabbix2.2及以上版本升級到zabbix3.0不須要額外執行數據庫升級腳本。3.0版zabbix-server啓動後會自動升級數據庫,到日誌裏查看升級進度:
# zabbix-server啓動後,觀察zabbix-server的日誌 tailf -100 /var/log/zabbix/zabbix_server.log
4.升級zabbix web
下面分別講下nginx和Apache的web升級:
1)Nginx
# 下載zabbix 3.0源碼包 wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.0/zabbix-3.0.0.tar.gz -O zabbix-3.0.0.tar.gz # 解壓後提取php源文件到zabbix web目錄/data/www/zabbix3.0 tar xvzf zabbix-3.0.0.tar.gz mkdir -p /data/www/zabbix3.0 \cp -r zabbix-3.0.0/frontends/php/* /data/www/zabbix3.0 # 設置web目錄的權限(個人nginx的啓動用戶是nginx) chown -R nginx. /data/www chmod 755 /data # 修改php-fpm的用戶也是nginx sed -i '/^user =/c\user = nginx' /etc/php-fpm.d/www.conf sed -i '/^group = =/c\group = nginx' /etc/php-fpm.d/www.conf
更新Nginx配置文件裏的zabbix web根目錄:
# 啓動php-fpm service php-fpm start # 啓動nginx nginx -t && service nginx start # 加入開機啓動 chkconfig php-fpm on chkconfig nginx on
最後訪問zabbix web進行配置便可,配置流程簡單就不細說了。
點擊下一步「Next step」沒有反應的解決方法以下:
# 若是你的nginx和php-fpm啓動用戶爲nginx,則運行下面的命令修改php session文件目錄的權限: setfacl -R -m u:nginx:rwx /var/lib/php
2)Apache
# yum更新zabbix web(按照下面的命令升級) yum --disablerepo=epel --enablerepo=zabbix3.0 install httpd php56w zabbix-web-mysql-3.0.0-1.el6.noarch zabbix-web-3.0.0-1.el6.noarch sed -i "s@# php_value date.timezone Europe/Riga@php_value date.timezone Asia/Shanghai@g" /etc/httpd/conf.d/zabbix.conf # 啓動Apache /etc/init.d/httpd restart # 加入開機啓動 chkconfig httpd on
至此所有升級結束了。