大网数据广告活动
服务器运维问答

Possible to drop MariaDB (MySQL) InnoDB databases by deleting directories?

· 52CE 我爱测

I'm working out the fastest way to spin up a new slave server, which will only require some of our databases. The basic plan is: Stop existing slave Take LVM snapshot and re-start slave (so it can go back to handling traffic) Mou…

问题原文

原帖链接 · Nathan Stretch · CC BY-SA 3.0

I'm working out the fastest way to spin up a new slave server, which will only require some of our databases. The basic plan is:

  • Stop existing slave
  • Take LVM snapshot and re-start slave (so it can go back to handling traffic)
  • Mount snapshot
  • Delete directories of unneeded databases in snapshot
  • Make a tarball of entire mysql directory, excluding the directories of the databases I don't want to transfer, and transfer to new slave
  • Swap out mysql directory on new slave. Start mysql there and update user table and grants, then flush privileges.
  • Update permissions on master to allow replication user from new slave IP.

What I'm not sure about is whether just deleting the database directories will work, or if I will run into problems with metadata not matching. If necessary I could mount the snapshot at the actual mysql location, and start a CLI session to drop the databases the right way, but it's more effort and will take longer, plus put more load on the source server, so if I can just delete the directories that would be ideal. Maybe delete the directories and clean up the appropriate information_schema table(s) afterward, on the new slave?

The purpose of all this is that I'm planning to be able to react quickly in the event of an unanticipated traffic spike, so the priorities are speed in spinning up the new slave, as well as minimizing added load and downtime of the existing slave, since it will be under high load in this situation.

已采纳解答

原帖链接 · akuzminsky · CC BY-SA 3.0

It's not a good idea. InnoDB keeps information about tables, fields in the dictionary that resides in ibdata1. If you delete database directory the database won't be visible for clients. But there will be side effects. For example, you won't be able to create tables with same name.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-03-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。