我有一个庞大的mysql数据库和centos上的两个小磁盘,如何使它同时使用两个磁盘?
答案 0 :(得分:8)
您可以将表分区到多个驱动器上。请查看官方手册,其中深入探讨了这一主题。
http://dev.mysql.com/doc/refman/5.5/en/partitioning.html
以下是在多个驱动器上对现有表进行分区的示例:
ALTER TABLE mytable
PARTITION BY RANGE (mycolumn)(
PARTITION p01 VALUES Less Than (10000)
DATA DIRECTORY = "/mnt/disk1"
INDEX DIRECTORY = "/mnt/disk1",
PARTITION p02 VALUES Less Than (20000)
DATA DIRECTORY = "/mnt/disk2"
INDEX DIRECTORY = "/mnt/disk2",
PARTITION p03 VALUES Less Than MAXVALUE
DATA DIRECTORY = "/mnt/disk3"
INDEX DIRECTORY = "/mnt/disk3"
);
请注意,这需要关闭NO_DIR_IN_CREATE。它似乎不适用于Windows,它似乎与InnoDB无关。
如果最后一个分区上的磁盘空间不足,可以使用以下语句将其拆分:
ALTER TABLE mytable REORGANIZE PARTITION p03 INTO
(
PARTITION p03 VALUES Less Than (30000)
DATA DIRECTORY = "/mnt/disk3"
INDEX DIRECTORY = "/mnt/disk3",
PARTITION p04 VALUES Less Than MAXVALUE
DATA DIRECTORY = "/mnt/disk4"
INDEX DIRECTORY = "/mnt/disk4"
);