zabbix3.2版本源码安装完毕,目前将2.4版本升级到3.2版本操作,只需要将2.4的数据库备份导出,然后将其导入3.2版本的数据库即可。
1、停止zabbix相关服务
1
2
3
4
|
service zabbix_server stop
service zabbix_agentd stop
service mysqld stop
service php-fpm stop
|
2、zabbix2.4版数据库备份
1
|
mysqldump --opt -R -uzabbix -p zabbix --ignore-table=zabbix.
history
--ignore-table=zabbix.history_log --ignore-table=zabbix.history_str --ignore-table=zabbix.history_text --ignore-table=zabbix.history_uint --ignore-table=zabbix.trends --ignore-table=zabbix.trends_uint > zabbix.sql
|
注释:
–opt:此Mysqldump命令参数是可选的,如果带上这个选项代表激活了Mysqldump命令的quick,add-drop-table,add-locks,extended-insert,lock-tables参数,也就是通过–opt参数在使用Mysqldump导出Mysql数据库信息时不需要再附加上述这些参数。
--ignore-table:不导出制定表格,此项可根据具体情况添加,由于历史数据太多,只将重要的zabbix信息导出了,节省时间。
3、将数据库备份导入zabbix3.2版本的数据库
1
2
|
service mysqld start
mysql -uzabbix -p zabbix < zabbix.sql
|
4、启动服务器
1
2
3
|
service php-fpm start
service zabbix_agentd start
service zabbix_server start
|
但是,这样导入数据库是起不来的会报错,具体问题具体分析,去看下zabbix_server.log日志,查找一下原因。我碰到的问题是zabbix-server在自检升级数据库时,提示有一些表格是已经存在,导致启动失败,既然存在造成的就删掉好了。
下列是我删掉的表格:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
SET FOREIGN_KEY_CHECKS = 0;
drop table application_prototype;
drop table item_application_prototype;
drop table application_discovery;
drop table opinventory;
drop table opinventory;
drop table sysmap_user;
drop table sysmap_usrgrp;
drop table screen_user;
drop table screen_usrgrp;
drop table slideshow_user;
drop table slideshow_usrgrp;
drop table trigger_tag;
drop table event_tag;
drop table problem;
drop table event_recovery;
drop table problem_tag;
drop table correlation;
drop table corr_condition;
drop table corr_condition_tag;
drop table corr_condition_group;
drop table corr_condition_tagpair;
drop table corr_condition_tagvalue;
drop table corr_operation;
drop table task;
drop table task_close_problem;
DROP TABLE history_log;
DROP TABLE history_text;
CREATE TABLE `history_log` (
`
id
` BIGINT(20) UNSIGNED NOT NULL,
`itemid` BIGINT(20) UNSIGNED NOT NULL,
`clock` INT(11) NOT NULL DEFAULT
'0'
,
`timestamp` INT(11) NOT NULL DEFAULT
'0'
,
`
source
` VARCHAR(64) NOT NULL DEFAULT
''
COLLATE
'utf8_bin'
,
`severity` INT(11) NOT NULL DEFAULT
'0'
,
`value` TEXT NOT NULL COLLATE
'utf8_bin'
,
`logeventid` INT(11) NOT NULL DEFAULT
'0'
,
`ns` INT(11) NOT NULL DEFAULT
'0'
,
PRIMARY KEY (`
id
`),
UNIQUE INDEX `history_log_2` (`itemid`, `
id
`),
INDEX `history_log_1` (`itemid`, `clock`)
)
COLLATE=
'utf8_bin'
ENGINE=InnoDB
;
CREATE TABLE `history_text` (
`
id
` BIGINT(20) UNSIGNED NOT NULL,
`itemid` BIGINT(20) UNSIGNED NOT NULL,
`clock` INT(11) NOT NULL DEFAULT
'0'
,
`timestamp` INT(11) NOT NULL DEFAULT
'0'
,
`
source
` VARCHAR(64) NOT NULL DEFAULT
''
COLLATE
'utf8_bin'
,
`severity` INT(11) NOT NULL DEFAULT
'0'
,
`value` TEXT NOT NULL COLLATE
'utf8_bin'
,
`logeventid` INT(11) NOT NULL DEFAULT
'0'
,
`ns` INT(11) NOT NULL DEFAULT
'0'
,
PRIMARY KEY (`
id
`),
UNIQUE INDEX `history_text_2` (`itemid`, `
id
`),
INDEX `history_text_1` (`itemid`, `clock`)
)
COLLATE=
'utf8_bin'
ENGINE=InnoDB
;
|
注释:
SET FOREIGN_KEY_CHECKS = 0;#是关闭外键检查,不关闭,上述表格删不掉。
service zabbix_server start
应该就可以起来了,具体问题需要结合日志去排查,每个环境问题可能不一样,所以要有针对性的去解决。
本文转自 wangpengtai 51CTO博客,原文链接:http://blog.51cto.com/wangpengtai/1931568,如需转载请自行联系原作者