spreading mysql data across multiple disks

无人久伴 提交于 2019-12-05 07:21:47

问题


I have a large mysql database and two small disks on centos, how do I make the it utilize both disks?


回答1:


You can partition a table over multiple drives. Have a look at the official manual, which covers this subject in depth.

http://dev.mysql.com/doc/refman/5.5/en/partitioning.html

Here's an example to partition an existing table over multiple drives:

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"
    );

Mind that this needs NO_DIR_IN_CREATE to be off. It doesn't seem to work in windows, and it doesn't seem to work with InnoDB.

If you run out of diskspace on your last partition, you can split it with following statement:

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"
);


来源:https://stackoverflow.com/questions/8963417/spreading-mysql-data-across-multiple-disks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!