设置 MySQL 以在带有 EBS 的 Amazon AWS 实例上使用另一个分区

Set Up MySQL to Use Another Partition on Amazon AWS Instance with EBS

我们有一个配备 30 GB 硬盘的 Amazon AWS 实例。有一个 MySQL 实例 运行 使用相同的硬盘。我们有一个托管应用程序并使用此数据库的 Apache 实例。

我们想增加可用于数据库的硬盘 space。有什么选择?

  1. 如果我们只是附加另一个 EBS 磁盘,是否可以让 MySQL 除了第一个磁盘之外还使用这个磁盘?
  2. 如果不是,"migrate" 数据库到新硬盘的难易程度如何?

我假设如果 1 不可能,唯一的选择是卸载数据库并重新安装它,以便它在新磁盘上存储数据。

If we just attach another EBS disk, is it possible to make MySQL use this disk in addition to the first disk?

Yes you can,但这增加了复杂性。

If not, how easy or hard is it to "migrate" the database to new Hard Disk?

如果你能接受一点停机时间:

  • 备份您的数据库
  • 关闭MySQL
  • 更改配置以指向新驱动器
  • 重启MySQL
  • 从您的备份恢复

与任何迁移过程一样,尽可能在测试环境中练习。这在 AWS 很容易做到,因为您可以创建实例的映像,然后从该实例创建新服务器。练习程序,然后杀死多余的实例。

I'm assuming if 1 is not possible, the only option is to uninstall the DB and reinstall it so that it stores data on new disk.

MySQL 将 datadir 存储在其配置文件中(my.cnf 或 my.ini)。您只需停止 MySQL,编辑配置文件,然后重新启动它。

还有第三种选择。您可以调整现有 EBS 卷的大小 (Windows or Linux)。