简体   繁体   English

在MySQL,MyISAM中,是否可以将带有分区的表更改为多个硬盘驱动器?

[英]In MySQL, MyISAM, Is it possible to alter table with partition into multiple hard drive?

In MySQL, MyISAM, Is it possible to alter table with partition into multiple hard drive ? 在MySQL,MyISAM中,是否可以将带有分区的表更改为多个硬盘驱动器?

My hard drive is nearly used up its disk space. 我的硬盘驱动器几乎用完了磁盘空间。

is there anyone facing this problem and how do you solve it? 有没有人遇到这个问题,您如何解决?

Yes, it's possible to 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 http://dev.mysql.com/doc/refman/5.5/zh-CN/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. 请注意,这需要关闭NO_DIR_IN_CREATE。 It doesn't seem to work in windows, and it doesn't seem to work with InnoDB. 它似乎在Windows中不起作用,并且似乎不适用于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"
);

诀窍是像平常一样创建分区,将选定的分区移动到其他硬盘驱动器,并将它们符号链接回/var/lib/mysql

You can move the entire mysql data directory. 您可以移动整个mysql数据目录。 Change the datadir option in /etc/mysql/my.cnf . 更改datadir在选项/etc/mysql/my.cnf

If you want to just move one database, you can stop the server, move the directory ( /var/lib/mysql/DATABASE_NAME ) somewhere else, then add a symlink to the new location ( ln -s NEW_LOCATION /var/lib/mysql/DATABASE_NAME ). 如果只想移动一个数据库,则可以停止服务器,将目录( /var/lib/mysql/DATABASE_NAME )移至其他位置,然后将符号链接添加到新位置( ln -s NEW_LOCATION /var/lib/mysql/DATABASE_NAME )。

Make certain to make backups!!!!!! 确保进行备份! Before messing with this!!!!! 在弄乱这个之前!!!!!

( mysqldump --all-databases as a user that has access to everything, root probably.) mysqldump --all-databases作为有权访问所有内容的用户,可能是root用户。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM