1、简介
记录4.4版本升级5.0版本的过程;系统是CentOS7的系统;web使用的是NGINX;
2、4.4版本的安装【参考1】
#1、安装zabbix源,使用阿里源 rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm sed -i 's/repo.zabbix.com/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo #2、安装epel源,使用阿里源 yum install wget -y wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo #3、安装需要的软件 yum install -y zabbix-web-mysql zabbix-nginx-conf zabbix-server-mysql mariadb-server mariadb zabbix-agent #4、启动数据库,并配置账号、密码,初始化zabbix数据库 systemctl start mariadb mysql -uroot mysql> create database zabbix character set utf8 collate utf8_bin; mysql> create user zabbix@localhost identified by 'password'; mysql> grant all privileges on zabbix.* to zabbix@localhost; zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix #5、修改php配置 sed -i '$a php_value[date.timezone] = Asia/Shanghai' /etc/php-fpm.d/zabbix.conf #6、修改nginx配置 sed -i '38,57 s/^/#/g' /etc/nginx/nginx.conf sed -ir '3i listen 80 default_server;\nlisten [::]:80 default_server;\nserver_name _;' /etc/nginx/conf.d/zabbix.conf #7、修改zabbix-server的配置 sed -i '124a DBPassword=password' /etc/zabbix/zabbix_server.conf #8、打开防火墙上的特殊的端口及selinux策略 setsebool -P httpd_can_connect_zabbix 1 firewall-cmd --permanent --add-service=http firewall-cmd --permanent --add-service=zabbix-server firewall-cmd --reload #9、启动zabbix,及设置开机启动 systemctl enable zabbix-server nginx php-fpm zabbix-agent systemctl restart zabbix-agent zabbix-server nginx php-fpm #10、若启动了selinux,请根据日志查看,首先安装软件,否则不会出建议 yum install setroubleshoot -y journalctl -f 命令会提示执行下面两个临时方案 ausearch -c 'zabbix_server' --raw | audit2allow -M my-zabbixserver semodule -i my-zabbixserver.pp #若还是有问题,继续根据journalctl中的建议命令试试(就是下面的两个) ausearch -c 'zabbix_server' --raw | audit2allow -M my-zabbixserver semodule -i my-zabbixserver.pp
3、升级到5.0版本【参考2】
#1、关闭旧版本的程序、关闭开机启动 systemctl stop zabbix-server nginx php-fpm zabbix-agent systemctl disable zabbix-server nginx php-fpm zabbix-agent #2、备份 mkdir /opt/zabbix-backup/ cp /etc/zabbix/zabbix_server.conf /opt/zabbix-backup/ cp /etc/httpd/conf.d/zabbix.conf /opt/zabbix-backup/ cp -R /usr/share/zabbix/ /opt/zabbix-backup/ cp -R /usr/share/doc/zabbix-* /opt/zabbix-backup/ #3、安装国内的源,启动zabbix的fronted源,并升级部分软件 rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm sed -i 's/repo.zabbix.com/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo yum upgrade -y zabbix-server-mysql zabbix-web-mysql zabbix-agent sed -i '11 s/enabled=0/enabled=1/g' /etc/yum.repos.d/zabbix.repo yum clean all #4、安装redhat的scl软件集合源,方便一个系统安装多个源,比如下面会自动安装的依赖包rh-php72 yum install centos-release-scl -y #5、移除旧的界面,否则新的界面会冲突,无法安装 yum remove -y zabbix-web zabbix-nginx-conf zabbix-web-mysql #6、安装新的软件,并修改配置 yum install -y zabbix-nginx-conf-scl zabbix-web-deps-scl zabbix-web-mysql-scl sed -i 's/^listen.acl_users = apache$/listen.acl_users = apache,nginx/' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf sed -ir '3i listen 80 default_server;\nlisten [::]:80 default_server;\nserver_name _;' /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf sed -i '38,80 s/^/#/g' /etc/opt/rh/rh-nginx116/nginx/nginx.conf sed -i '$a php_value[date.timezone] = Asia/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf #7、启动zabbix,并设置自动启动 systemctl stop rh-nginx116-nginx rh-php72-php-fpm zabbix-server zabbix-agent systemctl enable rh-nginx116-nginx rh-php72-php-fpm zabbix-server zabbix-agent #8、注意,在/var/log/zabbix-server.log中,可以看到数据库自动升级成功的,所以数据库不需要手动升级;
参考1:https://www.zabbix.com/documentation/4.4/manual/installation/install_from_packages/rhel_centos
时间:2020-09-15