我们的zabbix 监控使用 oracle 作为存储, 因此,需要创建基于 基于时间戳的分区表,在此将操作过程记录如下
1. 创建,四个zabbix 最大的表的分区表
create table history_part
(
"ITEMID" NUMBER(20,0) NOT NULL ENABLE,
"CLOCK" NUMBER(10,0) DEFAULT '0' NOT NULL ENABLE,
"VALUE" NUMBER(20,4) DEFAULT '0.0000' NOT NULL ENABLE,
"NS" NUMBER(10,0) DEFAULT '0' NOT NULL ENABLE
)
PARTITION BY RANGE (CLOCK) INTERVAL (2592000)
(partition part_t01 values less than(1573401600));
CREATE TABLE "ZABBIX_SERVER"."HISTORY_UINT_PART"
( "ITEMID" NUMBER(20,0) NOT NULL ENABLE,
"CLOCK" NUMBER(10,0) DEFAULT '0' NOT NULL ENABLE,
"VALUE" NUMBER(20,0) DEFAULT '0' NOT NULL ENABLE,
"NS" NUMBER(10,0) DEFAULT '0' NOT NULL ENABLE
)
PARTITION BY RANGE (CLOCK) INTERVAL (2592000)
(partition part_t01 values less than(1573401600));
CREATE TABLE "ZABBIX_SERVER"."TRENDS_PART"
( "ITEMID" NUMBER(20,0) NOT NULL ENABLE,
"CLOCK" NUMBER(10,0) DEFAULT '0' NOT NULL ENABLE,
"NUM" NUMBER(10,0) DEFAULT '0' NOT NULL ENABLE,
"VALUE_MIN" NUMBER(20,4) DEFAULT '0.0000' NOT NULL ENABLE,
"VALUE_AVG" NUMBER(20,4) DEFAULT '0.0000' NOT NULL ENABLE,
"VALUE_MAX" NUMBER(20,4) DEFAULT '0.0000' NOT NULL ENABLE,
PRIMARY KEY ("ITEMID", "CLOCK"))
PARTITION BY RANGE (CLOCK) INTERVAL (2592000)
(partition part_t01 values less than(1573401600));
CREATE TABLE "ZABBIX_SERVER"."TRENDS_UINT_PART"
( "ITEMID" NUMBER(20,0) NOT NULL ENABLE,
"CLOCK" NUMBER(10,0) DEFAULT '0' NOT NULL ENABLE,
"NUM" NUMBER(10,0) DEFAULT '0' NOT NULL ENABLE,
"VALUE_MIN" NUMBER(20,0) DEFAULT '0' NOT NULL ENABLE,
"VALUE_AVG" NUMBER(20,0) DEFAULT '0' NOT NULL ENABLE,
"VALUE_MAX" NUMBER(20,0) DEFAULT '0' NOT NULL ENABLE,
PRIMARY KEY ("ITEMID", "CLOCK"))
PARTITION BY RANGE (CLOCK) INTERVAL (2592000)
(partition part_t01 values less than(1573401600));
第二步 迁移历史数据
本地不迁移了, 如果自己迁移,注意数据不能用
insert into select 方式,这样的数据量非常大,造成回滚段,占满
第三部 分区表和原始表 采用重命名方式对调
alter table trends rename to trends_nopart;
alter table trends_uint rename to trends_uint_nopart
alter table history rename to history_nopart;
alter table history_uint rename to history_uint_nopart
alter table trends_part rename to trends;
alter table trends_uint_part rename to trends_uint;
alter table history_part rename to history;
alter table history_uint_part rename to history_uint