Zabbix 6.0 LTS 6.0.12升级6.0.21(欧拉系统)

2023-09-12 19:01:03 浏览数 (3)

升级Zabbix 6.0.x 小版本,实现软件版本全生命周期管理,保留Nginx、PHP、MySQL原有版本,不对MySQL数据库进行更改操作,保留原有监控数据。

软件版本

  • nginx/1.21.5
  • mysql Ver 8.0.29
  • PHP 8.0.26
  • Zabbix 6.0.21

Zabbix 升级步骤

  1. 下载升级版本 zabbix 源码包
  2. 停止旧版本zabbix,编译升级版本zabbix
  3. 备份拷贝zabbix_server.conf配置文件,更新zabbix-server.service文件,启动zabbix server
  4. 更新zabbix环境变量,检查zabbix-server版本,检查zabbix server 日志
  5. 拷贝zabbix ui目录,修改nginx 发布目录,修改中文字体
  6. 登录Zabbix URL,配置数据库参数,检查监控主机以及监控项最新数据

停止旧版本zabbix server

代码语言:javascript复制
systemctl stop zabbix-server

升级依赖软件包

dnf install gcc libxml2 libxml2-devel net-snmp net-snmp-devel OpenIPMI OpenIPMI-devel libevent libevent-devel curl curl-devel libssh2-devel java java-devel mysql-devel unixODBC-devel openldap openldap-devel pcre pcre-devel fping -y

设置fping 执行权限

代码语言:javascript复制
chmod u s   /usr/sbin/fping

下载zabbix6.0.21源码包

wget https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.21.tar.gz

tar -zvxf zabbix-6.0.21.tar.gz -C /opt && cd /opt/zabbix-6.0.21/

编译Zabbix

./configure --prefix=/usr/local/zabbix-6.0.21 --enable-server --enable-agent --enable-java --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-openipmi --enable-ipv6 --with-openssl --with-ssh2 --with-iconv --with-libpcre --with-iconv-include --with-iconv-lib --with-libevent --with-libevent-include --with-zlib --with-zlib-include --with-zlib-lib --with-libpthread --with-libpthread-include --with-libpthread-lib --with-libevent-lib --with-ldap

make install

备份zabbix server配置文件

代码语言:javascript复制
cd /usr/local/zabbix-6.0.21/etc/
cp zabbix_server.conf zabbix_server.conf.bak

拷贝zabbix server 配置文件

代码语言:javascript复制
cp /usr/local/zabbix/etc/zabbix_server.conf /usr/local/zabbix-6.0.21/etc/zabbix_server.conf

Zabbix编译安装 systemctl 服务启动管理

zabbix-server.service

代码语言:javascript复制
cat << EOF > /usr/lib/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server
After=syslog.target
After=network.target
[Service]
Environment="CONFFILE=/usr/local/zabbix-6.0.21/etc/zabbix_server.conf"
EnvironmentFile=-/usr/local/zabbix-6.0.21
Type=forking
#PIDFile=/var/run/zabbix/zabbix_server.pid
PIDFile=/tmp/zabbix_server.pid
ExecStart=/usr/local/zabbix-6.0.21/sbin/zabbix_server -c /usr/local/zabbix-6.0.21/etc/zabbix_server.conf
ExecStop=/usr/bin/kill 
Restart=always
RestartSec=5
User=zabbix
Group=zabbix
[Install]
WantedBy=multi-user.target
EOF

Zabbix 环境变量

代码语言:javascript复制
vim /etc/profile
export PATH=/usr/local/zabbix-6.0.21/sbin:/usr/local/zabbix/bin:$PATH
source   /etc/profile

检查Zabbix Server 版本

重启Zabbix Server

代码语言:javascript复制
systemctl  restart   zabbix-server

Zabbix Web 前端配置文件更新

拷贝zabbix web ui 配置文件到/usr/share/zabbix目录下

代码语言:javascript复制
cp -rp  /opt/zabbix-6.0.21/ui /usr/share/
mv /usr/share/ui /usr/share/zabbix-6.0.21
chown -R  nginx:nginx    /usr/share/zabbix-6.0.21

Nginx 配置文件更新

cat /etc/nginx/conf.d/zabbix.conf

代码语言:javascript复制
server {
listen          8080;
root    /usr/share/zabbix-6.0.21;
index   index.php;
location = /favicon.ico {
log_not_found   off;
}
location / {
try_files       $uri $uri/ =404;
}
location /assets {
access_log      off;
expires         10d;
}
location ~ /.ht {
deny            all;
}
location ~ /(api/|conf[^.]|include|locale) {
deny            all;
return          404;
}
location /vendor {
deny            all;
return          404;
}
location ~ [^/].php(/|$)|^/(status|ping)$ {
fastcgi_pass    unix:/run/zabbix.sock;
fastcgi_split_path_info ^(. .php)(/. )$;
fastcgi_index   index.php;
fastcgi_param   DOCUMENT_ROOT   /usr/share/zabbix-6.0.21;
fastcgi_param   SCRIPT_FILENAME /usr/share/zabbix-6.0.21$fastcgi_script_name;
fastcgi_param   PATH_TRANSLATED /usr/share/zabbix-6.0.21$fastcgi_script_name;
include fastcgi_params;
fastcgi_param   QUERY_STRING    $query_string;
fastcgi_param   REQUEST_METHOD  $request_method;
fastcgi_param   CONTENT_TYPE    $content_type;
fastcgi_param   CONTENT_LENGTH  $content_length;
fastcgi_intercept_errors        on;
fastcgi_ignore_client_abort     off;
fastcgi_connect_timeout         60;
fastcgi_send_timeout            180;
fastcgi_read_timeout            180;
fastcgi_buffer_size             128k;
fastcgi_buffers                 4 256k;
fastcgi_busy_buffers_size       256k;
fastcgi_temp_file_write_size    256k;
}
location = /basic_status {     
stub_status; 
allow 127.0.0.1;     
                #allow ::1;    
deny all; 
}

}

检查nginx配置文件

nginx -t

重新加载nginx配置

nginx -s reload

Zabbix 6.0 Web UI 中文乱码

在Windows 系统中找到 C:WindowsFonts 中的楷体(常规)复制到 windows 桌面上,通过lrzsz 上传到 /usr/share/zabbix/assets/fonts 目录下

代码语言:javascript复制
cd /usr/share/zabbix/assets/fonts
cp DejaVuSans.ttf DejaVuSans.ttf.bak
mv simkai.ttf DejaVuSans.ttf
chmod  755 DejaVuSans.ttf

Zabbix Web 关闭管家功能(housekeeping)

0 人点赞