14、zabbix版本升级

版权声明:原创作品,谢绝转载!否则将追究法律责任。 ————— 作者:kirin

zabbix版本升级 zabbix版本升级
版本 2.2—>3.0 4.0—>5.0
PHP版本需求 5.3—5.4 5.4—7.2

#18.1.zabbix-agent或agent2升级(简直不要太简单)

[root@web01 ~]# ll
total 11904
-rw-r--r-- 1 root root 6087492 May 27 22:42 zabbix-agent2-5.4.0-9.el7.x86_64.rpm
-rw-r--r-- 1 root root 6097436 Jul 21 16:12 zabbix-agent2-5.4.3-1.el7.x86_64.rpm

[root@web01 ~]# rpm -qa|grep zabbix-agent2
zabbix-agent2-5.4.0-9.el7.x86_64

[root@web01 ~]# rpm -Uvh zabbix-agent2-5.4.3-1.el7.x86_64.rpm 
warning: zabbix-agent2-5.4.3-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-agent2-5.4.3-1.el7        ################################# [ 50%]
Cleaning up / removing...
   2:zabbix-agent2-5.4.0-9.el7        ################################# [100%]

##成功将zabbix-agent2-5.4.0-9升级为zabbix-agent25.4.3-1
[root@web01 ~]# rpm -qa|grep zabbix-agent2
zabbix-agent2-5.4.3-1.el7.x86_64

#升级完成之后,记得重启客户端
[root@web01 ~]# systemctl restart zabbix-agent2.service 

#zabbix-agent也是类似的方法

18.2.zabbix-server升级( zabbix4.0升级至zabbix5.0 )

1、环境准备、zabbix4.0安装
#安装PHP
[root@zabbix-server ~]# yum install epel-release -y
[root@zabbix-server ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@zabbix-server ~]# yum install php72w-fpm  php72w-gd.x86_64 php72w-bcmath.x86_64 php72w-xml.x86_64 php72w-mbstring.x86_64 php72w-ldap.x86_64 php72w-mysqlnd.x86_64  -y


#安装nginx
[root@zabbix-server ~]# yum install nginx -y
[root@zabbix-server ~]# sed -i '/^user/c user = nginx' /etc/php-fpm.d/www.conf 
[root@zabbix-server ~]# sed -i '/^group/c group = nginx' /etc/php-fpm.d/www.conf
[root@zabbix-server ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
[root@zabbix-server ~]# vim /etc/nginx/nginx.conf
[root@zabbix-server ~]# cat /etc/nginx/nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   /html;
            index  index.php index.html index.htm;
        }
        location ~ \.php$ {
            root           /html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /html$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}
[root@zabbix-server ~]#  mkdir /html
[root@zabbix-server ~]# nginx -t
[root@zabbix-server ~]# systemctl restart nginx
[root@zabbix-server ~]# systemctl enable nginx
[root@zabbix-server ~]# wget https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.28.tar.gz
[root@zabbix-server ~]# tar xf zabbix-4.0.28.tar.gz 
[root@zabbix-server ~]# mv  zabbix-4.0.28/frontends/php/* /html/
[root@zabbix-server ~]# cd /html/
[root@zabbix-server /html# ll
[root@zabbix-server /html]# chown -R nginx. .
[root@zabbix-server ~]# mkdir /var/lib/php/session
[root@zabbix-server ~]# chown -R nginx:nginx /var/lib/php/session/

#访问web界面

[root@zabbix-server ~]# vim /etc/php.ini
max_execution_time = 300
max_input_time = 300
post_max_size = 16M
date.timezone = Asia/Shanghai
[root@zabbix-server ~]#  systemctl restart php-fpm.service


#安装数据库
[root@zabbix-server /opt]# rz -E
[root@zabbix-server /opt]# tar xf mysql-5.7.32-linux-glibc2.12-x86_64.tar.gz [root@zabbix-server /opt]# mkdir -p /app/
[root@zabbix-server /opt]# mv mysql-5.7.32-linux-glibc2.12-x86_64 /app/mysql
[root@zabbix-server /opt]# vim /etc/profile
[root@zabbix-server /opt]# source /etc/profile
[root@zabbix-server /opt]# useradd mysql
[root@zabbix-server /opt]# mkdir /data/mysql -p 
[root@zabbix-server /opt]# chown -R mysql.mysql /app/*
[root@zabbix-server /opt]# chown -R mysql.mysql /data/*
[root@zabbix-server /opt]# mysqld --initialize  --user=mysql --basedir=/app/mysql --datadir=/data/mysql
[root@zabbix-server /opt]# yum install -y libaio-devel
[root@zabbix-server /opt]# vim /etc/my.cnf
[root@zabbix-server /opt]# cat /etc/my.cnf
[mysqld]
user=mysql
basedir=/app/mysql
datadir=/data/mysql
server_id=6
port=3306
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
prompt=mysql [\\d]>
[root@zabbix-server /opt]# vim /etc/systemd/system/mysqld.service 
[root@zabbix-server /opt]# cat /etc/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/app/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
[root@zabbix-server /opt]# systemctl start mysqld.service 
[root@zabbix-server /opt]# systemctl enable mysqld.service
[root@zabbix-server /opt]# netstat -lntup|grep 3306
[root@zabbix-server ~]# mysql -uroot -p123456
mysql [(none)]>create database zabbix character set utf8 collate utf8_bin; 
mysql [(none)]>create user 'zabbix'@'localhost' identified by '123456'; 
mysql [(none)]>grant all privileges on zabbix.* to 'zabbix'@'localhost'; 


#安装zabbix-server
[root@zabbix-server ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
[root@zabbix-server ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.tuna.tsinghua.edu.cn/zabbix#g' /etc/yum.repos.d/zabbix.repo
[root@zabbix-server ~]# yum install zabbix-server-mysql -y
[root@zabbix-server ~]#  zcat /usr/share/doc/zabbix-server-mysql-*/create.sql.gz|mysql -uzabbix -p123456 zabbix
[root@zabbix-server ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBSocket=/tmp/mysql.sock
pdo_mysql.default_socket=/tmp/mysql.sock
mysqli.default_socket =/tmp/mysql.sock
[root@zabbix-server ~]# systemctl start zabbix-server.service 
[root@zabbix-server ~]# systemctl enable zabbix-server.service 
[root@zabbix-server ~]# netstat -lntup|grep 10051

#配置web界面





#接下来修改一下主机名,验证升级完成后主机名是否还在

2、清除之前的zabbix的yum源缓存
[root@zabbix-server ~]# yum clean all
3、升级zabbix-server之前首先升级zabbix-release
[root@zabbix-server ~]# rpm -Uvh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

#升级的过程中,yum的文件又被替换成了官方的地址,所以还需要执行一下替换
[root@zabbix-server ~]#cat /etc/yum.repos.d/zabbix.repo 

[root@zabbix-server ~]# sed -i 's#http://repo.zabbix.com#https://mirrors.tuna.tsinghua.edu.cn/zabbix#g' /etc/yum.repos.d/zabbix.repo

4、然后升级zabbix-server
[root@zabbix-server ~]# yum install zabbix-server-mysql -y

PS:如果yum报错就清空下缓存,在重新生成下缓存

5、重启生效
[root@zabbix-server ~]# systemctl restart zabbix-server.service 

18.3.zabbix-web升级

#上传包并解压
[root@zabbix-server ~]# rz -E
[root@zabbix-server ~]# tar xf zabbix-5.0.8.tar.gz 

#备份文件
[root@zabbix-server ~]# cp /html/conf/zabbix.conf.php /tmp/

#覆盖文件
[root@zabbix-server ~]# \cp -a zabbix-5.0.8/ui/* /html/
[root@zabbix-server ~]# cd /html/
[root@zabbix-server /html]# chown -R nginx. .

#刷新web界面

18.4.PHP升级

有一种情况是,假如再用4.0的时候,PHP版本是5.4的,当zabbix升级到5.0以后,PHP是不能够使用的,所以还应该升级PHP

1、停掉现在使用的PHP
[root@zabbix-server ~]# systemctl stop php-fpm.service 

2、卸载PHP
[root@zabbix-server ~]# rpm -e `rpm -qa|grep php*`

3、安装7.2版本的PHP
[root@zabbix-server ~]# yum install epel-release -y
[root@zabbix-server ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root@zabbix-server ~]# yum install php72w-fpm  php72w-gd.x86_64 php72w-bcmath.x86_64 php72w-xml.x86_64 php72w-mbstring.x86_64 php72w-ldap.x86_64 php72w-mysqlnd.x86_64  -y

4、修改属主属组
[root@zabbix-server ~]#sed -i '/^user/c user = nginx' /etc/php-fpm.d/www.conf 
[root@zabbix-server ~]#sed -i '/^group/c group = nginx' /etc/php-fpm.d/www.conf

5、启动服务并加入开机自启
[root@zabbix-server ~]# systemctl start php-fpm
[root@zabbix-server ~]# systemctl enable php-fpm

18.5.升级总结

zabbix升级注意两点:

1、zabbix-server升级

2、zabbix-web升级,稍微麻烦一点的是涉及到PHP的版本升级

posted @ 2022-06-17 21:59  kirin(麒麟)  阅读(584)  评论(0编辑  收藏  举报
Δ