您好,登錄后才能下訂單哦!
這期內容當中小編將會給大家帶來有關怎么實現MyISAM分區表遷移及合并,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
dyn_change_yyyymm 是一張按照日期(字段time_d)分區的表(myisam),只有insert,select操作。
2016年3月份起結構如下:
CREATE TABLE `dyn_change_201603` (
`time_d` int(8) NOT NULL COMMENT '帳期',
`id` char(32) NOT NULL COMMENT '業務標識',
`content` text COMMENT '內容',
`create_time` int(11) NOT NULL COMMENT '時間',
KEY `idx_id` (`id`),
KEY `idx_create_time` (`create_time`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='動態數據記錄表'
/*!50100 PARTITION BY RANGE (time_d)
(PARTITION dypt_20160301 VALUES LESS THAN (20160302) ENGINE = MyISAM,
PARTITION dypt_20160302 VALUES LESS THAN (20160303) ENGINE = MyISAM,
PARTITION dypt_20160303 VALUES LESS THAN (20160304) ENGINE = MyISAM,
PARTITION dypt_20160304 VALUES LESS THAN (20160305) ENGINE = MyISAM,
PARTITION dypt_20160305 VALUES LESS THAN (20160306) ENGINE = MyISAM,
PARTITION dypt_20160306 VALUES LESS THAN (20160307) ENGINE = MyISAM,
PARTITION dypt_20160307 VALUES LESS THAN (20160308) ENGINE = MyISAM,
PARTITION dypt_20160308 VALUES LESS THAN (20160309) ENGINE = MyISAM,
PARTITION dypt_20160309 VALUES LESS THAN (20160310) ENGINE = MyISAM,
PARTITION dypt_20160310 VALUES LESS THAN (20160311) ENGINE = MyISAM,
PARTITION dypt_20160311 VALUES LESS THAN (20160312) ENGINE = MyISAM,
PARTITION dypt_20160312 VALUES LESS THAN (20160313) ENGINE = MyISAM,
PARTITION dypt_20160313 VALUES LESS THAN (20160314) ENGINE = MyISAM,
PARTITION dypt_20160314 VALUES LESS THAN (20160315) ENGINE = MyISAM,
PARTITION dypt_20160315 VALUES LESS THAN (20160316) ENGINE = MyISAM,
PARTITION dypt_20160316 VALUES LESS THAN (20160317) ENGINE = MyISAM,
PARTITION dypt_20160317 VALUES LESS THAN (20160318) ENGINE = MyISAM,
PARTITION dypt_20160318 VALUES LESS THAN (20160319) ENGINE = MyISAM,
PARTITION dypt_20160319 VALUES LESS THAN (20160320) ENGINE = MyISAM,
PARTITION dypt_20160320 VALUES LESS THAN (20160321) ENGINE = MyISAM,
PARTITION dypt_20160321 VALUES LESS THAN (20160322) ENGINE = MyISAM,
PARTITION dypt_20160322 VALUES LESS THAN (20160323) ENGINE = MyISAM,
PARTITION dypt_20160323 VALUES LESS THAN (20160324) ENGINE = MyISAM,
PARTITION dypt_20160324 VALUES LESS THAN (20160325) ENGINE = MyISAM,
PARTITION dypt_20160325 VALUES LESS THAN (20160326) ENGINE = MyISAM,
PARTITION dypt_20160326 VALUES LESS THAN (20160327) ENGINE = MyISAM,
PARTITION dypt_20160327 VALUES LESS THAN (20160328) ENGINE = MyISAM,
PARTITION dypt_20160328 VALUES LESS THAN (20160329) ENGINE = MyISAM,
PARTITION dypt_20160329 VALUES LESS THAN (20160330) ENGINE = MyISAM,
PARTITION dypt_20160330 VALUES LESS THAN (20160331) ENGINE = MyISAM,
PARTITION dypt_20160331 VALUES LESS THAN (20160401) ENGINE = MyISAM) */
在不影響insert的情況下,需要將dyn_change_201603遷移到新環境下。
步驟如下:
1)假設當前日期為:2016年3月30日,對應分區dypt_20160330,新環境創建dyn_change_201603表(非分區表)。insert 操作可以移到新環境下;
2)將老環境下的表dyn_change_201603 重命名為: dyn_change_201603_old;
3)到mysql的數據目錄下,將dyn_change_201603_old的數據文件&&索引文件scp到新環境對應的路徑下面。[注:dyn_change_201603_old此時的對應數據&&索引文件不同與dyn_change_201603的數據&&索引文件]
4)然后交換dyn_change_201603,dyn_change_201603_old表名。交換后,90%以上的數據都在dyn_change_201603表,而少部分數據在dyn_change_201603_old(只在分區dypt_20160330 中);
dyn_change_201603接受當前insert操作;
5)然后導出dyn_change_201603_old 的dypt_20160330分區的數據(僅有少量數據),可以導出dyn_change_201603_30.csv文件;
6)然后將dyn_change_201603_30.csv的數據導入dyn_change_201603;
7)alter table dyn_change_201603 analyze partition dypt_20160330。
[注:此時可在insert操作較少的時間 or 暫停insert 操作]。
遷移合并完成。
上述就是小編為大家分享的怎么實現MyISAM分區表遷移及合并了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。