升级Zabbix 6.0.x 小版本,实现软件版本全生命周期管理,保留Nginx、PHP、MySQL原有版本,不对MySQL数据库进行更改操作,保留原有监控数据。
软件版本
Zabbix 升级步骤
停止旧版本zabbix server
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 执行权限
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配置文件
cd /usr/local/zabbix-6.0.21/etc/
cp zabbix_server.conf zabbix_server.conf.bak
拷贝zabbix server 配置文件
cp /usr/local/zabbix/etc/zabbix_server.conf /usr/local/zabbix-6.0.21/etc/zabbix_server.conf
Zabbix编译安装 systemctl 服务启动管理
zabbix-server.service
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 环境变量
vim /etc/profile
export PATH=/usr/local/zabbix-6.0.21/sbin:/usr/local/zabbix/bin:$PATH
source /etc/profile
检查Zabbix Server 版本
重启Zabbix Server
systemctl restart zabbix-server
Zabbix Web 前端配置文件更新
拷贝zabbix web ui 配置文件到/usr/share/zabbix目录下
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
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:\Windows\Fonts 中的楷体(常规)复制到 windows 桌面上,通过lrzsz 上传到 /usr/share/zabbix/assets/fonts 目录下
cd /usr/share/zabbix/assets/fonts
cp DejaVuSans.ttf DejaVuSans.ttf.bak
mv simkai.ttf DejaVuSans.ttf
chmod 755 DejaVuSans.ttf
Zabbix Web 关闭管家功能(housekeeping)