zabbix 5.2.6 升级到 6.0.1

1、 升级前必做的事情

1.升级之前一定要做数据库的备份,万一升级失败还能做回滚

2.升级之前在页面上关闭所有的动作,防止升级过程中触发一些非正常问题造成不必要的告警通知

 

2、 以下操作在本地环境进行,以防对现有zabbix环境的破坏 ###

mkdir /data/
cd /data/
wget -c https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.1.tar.gz
tar xf zabbix-6.0.1.tar.gz 
cd zabbix-6.0.1/
./configure --prefix=/data/zabbix-server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc  && make && make install

/data/zabbix-server/sbin/zabbix_server --version #返回信息如下 zabbix_server (Zabbix) 6.0.1 # 拷贝需要升级的资源到zabbix server上面 scp /data/zabbix-server/sbin/zabbix_server root@zabbix_server_ip:/tmp/ scp -r /data/zabbix-6.0.1/ui root@zabbix_server_ip:/tmp/

 

3、 以下操作在zabbix server上进行

cp /data/zabbix-server/sbin/zabbix_server /data/zabbix-server/sbin/zabbix_server.bak.5.2.6
mkdir -p /data/zabbix-6.0.1/ 
mv /tmp/ui /data/zabbix-6.0.1/ 

### 以下操作在zabbix server上进行:修改nginx之前

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  localhost;
        root         /data/zabbix-ui-5.2.6/;
    index    index.php;

    location ~ .*\.php$ {
        fastcgi_read_timeout 300;
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    }

### 以下操作在zabbix server上进行:修改nginx后

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  localhost;
        root /data/zabbix-6.0.1/ui/;
    index    index.php;

    location ~ .*\.php$ {
        fastcgi_read_timeout 300;
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    }

nginx -t

nginx -s reload

systemctl restart zabbix_server.service

 

升级成功的日志

 26781:20220303:110508.325 Starting Zabbix Server. Zabbix 6.0.1 (revision a80cb13868).
 26781:20220303:110508.325 ****** Enabled features ******
 26781:20220303:110508.325 SNMP monitoring:           YES
 26781:20220303:110508.325 IPMI monitoring:            NO
 26781:20220303:110508.325 Web monitoring:            YES
 26781:20220303:110508.326 VMware monitoring:         YES
 26781:20220303:110508.326 SMTP authentication:       YES
 26781:20220303:110508.326 ODBC:                      YES
 26781:20220303:110508.326 SSH support:                NO
 26781:20220303:110508.326 IPv6 support:               NO
 26781:20220303:110508.326 TLS support:                NO
 26781:20220303:110508.326 ******************************
 26781:20220303:110508.326 using configuration file: /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf
 26781:20220303:110508.359  
 26781:20220303:110508.359 Warning! Unsupported MySQL database server version (5.07.34)
 26781:20220303:110508.359 Should be at least (8.00.0)
 26781:20220303:110508.359 Use of supported database version is highly recommended.
 26781:20220303:110508.359  
 26781:20220303:110508.361 current database version (mandatory/optional): 06000000/06000000
 26781:20220303:110508.361 required mandatory version: 06000000
 26781:20220303:110508.363 database could be upgraded to use primary keys in history tables
 26782:20220303:110508.381 starting HA manager
 26782:20220303:110508.400 HA manager started in active mode
 26781:20220303:110508.402 server #0 started [main process]
 26783:20220303:110508.402 server #1 started [service manager #1]
 26784:20220303:110508.403 server #2 started [configuration syncer #1]
 26784:20220303:110515.363 slow query: 6.329295 sec, "select pp.item_preprocid,pp.itemid,pp.type,pp.params,pp.step,h.hostid,pp.error_handler,pp.error_handler_params from item_preproc pp,items i,hosts h where pp.itemid=i.itemid and i.hostid=h.hostid and (h.proxy_hostid is null or i.type in (5,15,18)) and h.status in (0,1) and i.flags<>2"
 26790:20220303:110517.111 server #4 started [alerter #1]
 26791:20220303:110517.112 server #5 started [alerter #2]

 

 

 

 

4、升级过程遇到的问题:问题处理完 重启zabbix server也就是执行命令<systemctl restart zabbix_server.service>

问题1:报错日志如下

 22917:20220302:201523.838 Unable to start Zabbix server due to unsupported MySQL database server version (5.07.34)
 22917:20220302:201523.838 Must be at least (8.00.0)
 22917:20220302:201523.838 Use of supported database version is highly recommended.
 22917:20220302:201523.838 Override by setting AllowUnsupportedDBVersions=1 in Zabbix server configuration file at your own risk.

问题1:解决方法

根据提示分析是因为zabbix 6.0.1对数据库的版本有要求,但是可以通过设置跳过检查
执行下面的命令添加配置跳过检查
echo "AllowUnsupportedDBVersions=1" >> zabbix_server.conf
重启zabbix server
systemctl restart zabbix_server.service

问题2:报错日志如下

 23026:20220302:201746.160 Warning! Unsupported MySQL database server version (5.07.34)
 23026:20220302:201746.160 Should be at least (8.00.0)
 23026:20220302:201746.160 Use of supported database version is highly recommended.
 23026:20220302:201746.160  
 23026:20220302:201746.162 current database version (mandatory/optional): 05030057/05030057
 23026:20220302:201746.162 required mandatory version: 06000000
 23026:20220302:201746.162 starting automatic database upgrade
 23026:20220302:201746.163 [Z3005] query failed: [1060] Duplicate column name 'scope' [alter table `scripts` add `scope` integer default '1' not null]
 23026:20220302:201746.163 database upgrade failed

问题2:解决方法,如果下面的insert执行失败可以忽略

登录zabbix server数据库执行下面的命令

use zabbix;

CREATE TABLE `scripts` (
`scriptid` bigint unsigned NOT NULL,
`name` varchar(255) DEFAULT '' NOT NULL,
`command` varchar(255) DEFAULT '' NOT NULL,
`host_access` integer DEFAULT '2' NOT NULL,
`usrgrpid` bigint unsigned NULL,
`groupid` bigint unsigned NULL,
`description` text NOT NULL,
`confirmation` varchar(255) DEFAULT '' NOT NULL,
`type` integer DEFAULT '0' NOT NULL,
`execute_on` integer DEFAULT '2' NOT NULL,
PRIMARY KEY (scriptid)
) ENGINE=InnoDB;
CREATE INDEX `scripts_1` ON `scripts` (`usrgrpid`);
CREATE INDEX `scripts_2` ON `scripts` (`groupid`);
CREATE UNIQUE INDEX `scripts_3` ON `scripts` (`name`);
ALTER TABLE `scripts` ADD CONSTRAINT `c_scripts_1` FOREIGN KEY (`usrgrpid`) REFERENCES `usrgrp` (`usrgrpid`);
ALTER TABLE `scripts` ADD CONSTRAINT `c_scripts_2` FOREIGN KEY (`groupid`) REFERENCES `hstgrp` (`groupid`);
INSERT INTO `scripts` (`scriptid`,`name`,`command`,`host_access`,`usrgrpid`,`groupid`,`description`,`confirmation`,`type`,`execute_on`) values ('1','Ping','ping -c 3 {HOST.CONN}; case $? in [01]) true;; *) false;; esac','2',NULL,NULL,'','','0','2');
INSERT INTO `scripts` (`scriptid`,`name`,`command`,`host_access`,`usrgrpid`,`groupid`,`description`,`confirmation`,`type`,`execute_on`) values ('2','Traceroute','/usr/bin/traceroute {HOST.CONN}','2',NULL,NULL,'','','0','2');
INSERT INTO `scripts` (`scriptid`,`name`,`command`,`host_access`,`usrgrpid`,`groupid`,`description`,`confirmation`,`type`,`execute_on`) values ('3','Detect operating system','sudo /usr/bin/nmap -O {HOST.CONN}','2','7',NULL,'','','0','2');

 

问题3:报错日志如下

 28099:20220302:202822.509 using configuration file: /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf
 28099:20220302:202822.517 current database version (mandatory/optional): 04000000/05030057
 28099:20220302:202822.517 required mandatory version: 05020000
 28099:20220302:202822.542 server #0 started [main process]
 28101:20220302:202822.543 server #1 started [configuration syncer #1]
 28101:20220302:202822.545 [Z3005] query failed: [1054] Unknown column 'compression_availability' in 'field list' [select discovery_groupid,snmptrap_logging,severity_name_0,severity_name_1,severity_name_2,severity_name_3,severity_name_4,severity_name_5,hk_events_mode,hk_events_trigger,hk_events_internal,hk_events_discovery,hk_events_autoreg,hk_services_mode,hk_services,hk_audit_mode,hk_audit,hk_sessions_mode,hk_sessions,hk_history_mode,hk_history_global,hk_history,hk_trends_mode,hk_trends_global,hk_trends,default_inventory_mode,db_extension,autoreg_tls_accept,compression_status,compression_availability,compress_older,instanceid,default_timezone from config order by configid]
zabbix_server [28101]: ERROR [file and function: <dbconfig.c,DCsync_configuration>, revision:798506596c] Something impossible has just happened.
 28101:20220302:202822.545 === Backtrace: ===

问题3:解决方法

登录zabbix server数据库执行下面的命令

use zabbix;

rename table config to config_bak;

CREATE TABLE `config` (

        `configid`               bigint unsigned                           NOT NULL,

        `work_period`            varchar(255)    DEFAULT '1-5,09:00-18:00' NOT NULL,

        `alert_usrgrpid`         bigint unsigned                           NULL,

        `default_theme`          varchar(128)    DEFAULT 'blue-theme'      NOT NULL,

        `authentication_type`    integer         DEFAULT '0'               NOT NULL,

        `ldap_host`              varchar(255)    DEFAULT ''                NOT NULL,

        `ldap_port`              integer         DEFAULT 389               NOT NULL,

        `ldap_base_dn`           varchar(255)    DEFAULT ''                NOT NULL,

        `ldap_bind_dn`           varchar(255)    DEFAULT ''                NOT NULL,

        `ldap_bind_password`     varchar(128)    DEFAULT ''                NOT NULL,

        `ldap_search_attribute`  varchar(128)    DEFAULT ''                NOT NULL,

        `discovery_groupid`      bigint unsigned                           NOT NULL,

        `max_in_table`           integer         DEFAULT '50'              NOT NULL,

        `search_limit`           integer         DEFAULT '1000'            NOT NULL,

        `severity_color_0`       varchar(6)      DEFAULT '97AAB3'          NOT NULL,

        `severity_color_1`       varchar(6)      DEFAULT '7499FF'          NOT NULL,

        `severity_color_2`       varchar(6)      DEFAULT 'FFC859'          NOT NULL,

        `severity_color_3`       varchar(6)      DEFAULT 'FFA059'          NOT NULL,

        `severity_color_4`       varchar(6)      DEFAULT 'E97659'          NOT NULL,

        `severity_color_5`       varchar(6)      DEFAULT 'E45959'          NOT NULL,

        `severity_name_0`        varchar(32)     DEFAULT 'Not classified'  NOT NULL,

        `severity_name_1`        varchar(32)     DEFAULT 'Information'     NOT NULL,

        `severity_name_2`        varchar(32)     DEFAULT 'Warning'         NOT NULL,

        `severity_name_3`        varchar(32)     DEFAULT 'Average'         NOT NULL,

        `severity_name_4`        varchar(32)     DEFAULT 'High'            NOT NULL,

        `severity_name_5`        varchar(32)     DEFAULT 'Disaster'        NOT NULL,

        `ok_period`              varchar(32)     DEFAULT '5m'              NOT NULL,

        `blink_period`           varchar(32)     DEFAULT '2m'              NOT NULL,

        `problem_unack_color`    varchar(6)      DEFAULT 'CC0000'          NOT NULL,

        `problem_ack_color`      varchar(6)      DEFAULT 'CC0000'          NOT NULL,

        `ok_unack_color`         varchar(6)      DEFAULT '009900'          NOT NULL,

        `ok_ack_color`           varchar(6)      DEFAULT '009900'          NOT NULL,

        `problem_unack_style`    integer         DEFAULT '1'               NOT NULL,

        `problem_ack_style`      integer         DEFAULT '1'               NOT NULL,

        `ok_unack_style`         integer         DEFAULT '1'               NOT NULL,

        `ok_ack_style`           integer         DEFAULT '1'               NOT NULL,

        `snmptrap_logging`       integer         DEFAULT '1'               NOT NULL,

        `server_check_interval`  integer         DEFAULT '10'              NOT NULL,

        `hk_events_mode`         integer         DEFAULT '1'               NOT NULL,

        `hk_events_trigger`      varchar(32)     DEFAULT '365d'            NOT NULL,

        `hk_events_internal`     varchar(32)     DEFAULT '1d'              NOT NULL,

        `hk_events_discovery`    varchar(32)     DEFAULT '1d'              NOT NULL,

        `hk_events_autoreg`      varchar(32)     DEFAULT '1d'              NOT NULL,

        `hk_services_mode`       integer         DEFAULT '1'               NOT NULL,

        `hk_services`            varchar(32)     DEFAULT '365d'            NOT NULL,

        `hk_audit_mode`          integer         DEFAULT '1'               NOT NULL,

        `hk_audit`               varchar(32)     DEFAULT '365d'            NOT NULL,

        `hk_sessions_mode`       integer         DEFAULT '1'               NOT NULL,

        `hk_sessions`            varchar(32)     DEFAULT '365d'            NOT NULL,

        `hk_history_mode`        integer         DEFAULT '1'               NOT NULL,

        `hk_history_global`      integer         DEFAULT '0'               NOT NULL,

        `hk_history`             varchar(32)     DEFAULT '90d'             NOT NULL,

        `hk_trends_mode`         integer         DEFAULT '1'               NOT NULL,

        `hk_trends_global`       integer         DEFAULT '0'               NOT NULL,

        `hk_trends`              varchar(32)     DEFAULT '365d'            NOT NULL,

        `default_inventory_mode` integer         DEFAULT '-1'              NOT NULL,

        `custom_color`           integer         DEFAULT '0'               NOT NULL,

        `http_auth_enabled`      integer         DEFAULT '0'               NOT NULL,

        `http_login_form`        integer         DEFAULT '0'               NOT NULL,

        `http_strip_domains`     varchar(2048)   DEFAULT ''                NOT NULL,

        `http_case_sensitive`    integer         DEFAULT '1'               NOT NULL,

        `ldap_configured`        integer         DEFAULT '0'               NOT NULL,

        `ldap_case_sensitive`    integer         DEFAULT '1'               NOT NULL,

        `db_extension`           varchar(32)     DEFAULT ''                NOT NULL,

        `autoreg_tls_accept`     integer         DEFAULT '1'               NOT NULL,

        `compression_status`     integer         DEFAULT '0'               NOT NULL,

        `compression_availability` integer         DEFAULT '0'               NOT NULL,

        `compress_older`         varchar(32)     DEFAULT '7d'              NOT NULL,

        `instanceid`             varchar(32)     DEFAULT ''                NOT NULL,

        `saml_auth_enabled`      integer         DEFAULT '0'               NOT NULL,

        `saml_idp_entityid`      varchar(1024)   DEFAULT ''                NOT NULL,

        `saml_sso_url`           varchar(2048)   DEFAULT ''                NOT NULL,

        `saml_slo_url`           varchar(2048)   DEFAULT ''                NOT NULL,

        `saml_username_attribute` varchar(128)    DEFAULT ''                NOT NULL,

        `saml_sp_entityid`       varchar(1024)   DEFAULT ''                NOT NULL,

        `saml_nameid_format`     varchar(2048)   DEFAULT ''                NOT NULL,

        `saml_sign_messages`     integer         DEFAULT '0'               NOT NULL,

        `saml_sign_assertions`   integer         DEFAULT '0'               NOT NULL,

        `saml_sign_authn_requests` integer         DEFAULT '0'               NOT NULL,

        `saml_sign_logout_requests` integer         DEFAULT '0'               NOT NULL,

        `saml_sign_logout_responses` integer         DEFAULT '0'               NOT NULL,

        `saml_encrypt_nameid`    integer         DEFAULT '0'               NOT NULL,

        `saml_encrypt_assertions` integer         DEFAULT '0'               NOT NULL,

        `saml_case_sensitive`    integer         DEFAULT '0'               NOT NULL,

        `default_lang`           varchar(5)      DEFAULT 'en_GB'           NOT NULL,

        `default_timezone`       varchar(50)     DEFAULT 'system'          NOT NULL,

        `login_attempts`         integer         DEFAULT '5'               NOT NULL,

        `login_block`            varchar(32)     DEFAULT '30s'             NOT NULL,

        `show_technical_errors`  integer         DEFAULT '0'               NOT NULL,

        `validate_uri_schemes`   integer         DEFAULT '1'               NOT NULL,

        `uri_valid_schemes`      varchar(255)    DEFAULT 'http,https,ftp,file,mailto,tel,ssh' NOT NULL,

        `x_frame_options`        varchar(255)    DEFAULT 'SAMEORIGIN'      NOT NULL,

        `iframe_sandboxing_enabled` integer         DEFAULT '1'               NOT NULL,

        `iframe_sandboxing_exceptions` varchar(255)    DEFAULT ''                NOT NULL,

        `max_overview_table_size` integer         DEFAULT '50'              NOT NULL,

        `history_period`         varchar(32)     DEFAULT '24h'             NOT NULL,

        `period_default`         varchar(32)     DEFAULT '1h'              NOT NULL,

        `max_period`             varchar(32)     DEFAULT '2y'              NOT NULL,

        `socket_timeout`         varchar(32)     DEFAULT '3s'              NOT NULL,

        `connect_timeout`        varchar(32)     DEFAULT '3s'              NOT NULL,

        `media_type_test_timeout` varchar(32)     DEFAULT '65s'             NOT NULL,

        `script_timeout`         varchar(32)     DEFAULT '60s'             NOT NULL,

        `item_test_timeout`      varchar(32)     DEFAULT '60s'             NOT NULL,

        `session_key`            varchar(32)     DEFAULT ''                NOT NULL,

        PRIMARY KEY (configid)

) ENGINE=InnoDB;

CREATE INDEX `config_1` ON `config` (`alert_usrgrpid`);

CREATE INDEX `config_2` ON `config` (`discovery_groupid`);

 

 

问题4:报错日志如下

 18175:20220303:101206.481 current database version (mandatory/optional): 06000000/06000000
 18175:20220303:101206.481 required mandatory version: 06000000
 18175:20220303:101206.483 database could be upgraded to use primary keys in history tables
 18175:20220303:101206.486 cannot read instance id from database

问题4:解决方法

登录数据库,执行下面的命令

use zabbix;
INSERT INTO `config` (`configid`,`work_period`,`alert_usrgrpid`,`discovery_groupid`,`dbversion_status`) values ('1','1-5,09:00-18:00','7','5','5.7.34');

 

 

 

 

以上sql都是用下面的方式找到的

grep scripts zabbix-5.2.6/database/mysql/*sql

 

 

 

 

posted @ 2022-03-03 11:00  Hello_worlds  阅读(1948)  评论(0编辑  收藏  举报