zabbix4.4版本升级5.0版本

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

参考2:https://www.zabbix.com/documentation/current/manual/installation/install_from_packages/frontend_on_rhel7

时间:2020-09-15

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Zabbix是一款开源的网络监控软件,可以对各种网络设备进行监控和管理。以下是Zabbix 4.4版本的安装部署方法: 1. 安装必要的软件 在安装Zabbix之前,需要安装LAMP(Linux + Apache + MySQL + PHP)或LEMP(Linux + Nginx + MySQL + PHP)环境。具体安装方法请参考相关教程。 2. 下载并安装Zabbix 官方网站下载Zabbix 4.4版本的压缩包,解压缩后将其移动到/var/www/html目录下(如果使用LEMP则是/var/www)。 ```shell # 下载 wget https://cdn.zabbix.com/zabbix/sources/stable/4.4/zabbix-4.4.0.tar.gz # 解压 tar -zxvf zabbix-4.4.0.tar.gz # 移动到目录 mv zabbix-4.4.0 /var/www/html/ ``` 3. 创建数据库 使用MySQL登录,并创建一个新的数据库和用户,并分配权限。 ```shell mysql -u root -p # 创建数据库 create database zabbix; # 创建用户 create user 'zabbix'@'localhost' identified by 'password'; # 授权 grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'password'; # 刷新权限 flush privileges; # 退出MySQL exit ``` 4. 导入数据库 使用Zabbix提供的SQL文件,导入到刚刚创建的数据库中。 ```shell cd /var/www/html/zabbix-4.4.0/database/mysql/ mysql -u zabbix -p zabbix < schema.sql mysql -u zabbix -p zabbix < data.sql ``` 5. 配置Zabbix服务器 将zabbix_server.conf和zabbix_agentd.conf配置文件中的数据库相关信息改为刚刚创建的数据库信息。 ```shell cd /var/www/html/zabbix-4.4.0/conf/ # 备份文件 cp zabbix_server.conf zabbix_server.conf.bak cp zabbix_agentd.conf zabbix_agentd.conf.bak # 修改文件 vim zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=password vim zabbix_agentd.conf Server=127.0.0.1 ServerActive=127.0.0.1 Hostname=Zabbix server ``` 6. 启动Zabbix服务 启动Zabbix服务,并设置开机自启动。 ```shell # 启动服务 systemctl start zabbix-server systemctl start zabbix-agent # 设置开机自启动 systemctl enable zabbix-server systemctl enable zabbix-agent ``` 至此,Zabbix 4.4版本的安装部署完成。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值