Yesterday I had fun time repairing 1.5Tb ext3 partition, containing many millions of files. Of course it should have never happened – this was decent PowerEdge 2850 box with RAID volume, ECC memory and reliable CentOS 4.4 distribution but still it did. We had “journal failed” message in kernel log and filesystem needed to be checked and repaired even though it is journaling file system which should not need checks in normal use, even in case of power failures. Checking and repairing took many hours especially as automatic check on boot failed and had to be manually restarted.

Same may happen with Innodb tables. They are designed to never crash, surviving power failures and even partial page writes but still they can get corrupted because of MySQL bugs, OS Bugs or hardware bugs, misconfiguration or failures.

Sometimes
corruption kind be mild, so ALTER TABLE to rebuild the table fixes it.
Sometimes table needs to be dropped and recovered from backup but in
certain cases you may need to reimport whole database – if corruption is
happens to be in undo tablespace or log files.

So do not forget
to have your recovery plan this kind failures. This is one thing you
better to have backups for. Backups however take time to restore,
especially if you do point in time recovery using binary log to get to
actual database state.

The good practice to approach this kind of
problem is first to have enough redundancy. I always assume any
component, such as piece of hardware or software can fail, even if this
piece of hardware has some internal redundancy by itself, such as RAID
or SAN solutions.

If you can’t afford full redundancy for
everything (and probably even if you do) the good idea is to keep your
objects smaller so if you need to do any maintenance with them it will
take less times. Smaller RAID volumes would typically rebuild faster,
smaller database size per system (yet another reason to like medium
end commodity hardware) makes it faster to recover, smaller tables
allow per table backup and recovery to happen faster.

With MySQL
and blocking ALTER TABLE there is yet another reason to keep tables
small, so you do not have to use complicated scenarios to do simple
things. Assume for example you need to add extra column to 500GB
Innodb table. It will probably take long hours or even days for ALTER
TABLE to complete and about 500GB of temporary space will be required
which you simply might not have. You can of course use MASTER-MASTER
replication and run statement on one server, switch role and then do it
on other, but if alter table takes several days do you really can
afford having no box to fall back to for such a long time ?

On
other hand if you would have 500 of 1GB tables it would be very easy –
you can simply move small pieces of data offline for a minute and alter
them live. Also all process will be much faster this way as whole
indexes will well fit in memory for such small tables.

Not to mention splitting 500 tables to several servers will likely be easy than splitting one big one.

There
are bunch of complications with many tables of course, it is not always
easy to partition your data appropriately, also code gets complicated
but for many applications it is worth the trouble

At NNSEEK
for example we have data split at 256 groups of tables. Current data
size is small enough so even single table would not be big problem but
it is much easier to write your code to handle split from very beginning
rather than try to add in later on when there are 100 helper scripts
written etc.

For the same reason I would recommend setting up
multiple virtual servers even if you work with physical one in the
beginning. Different accounts with different permissions will be good
enough. Doing so will ensure you will not have problems once you will
really need to scale to multiple servers.

 
参考:
http://www.mysqlperformanceblog.com/2006/10/08/small-things-are-better/

最新文章

  1. 文本处理三剑客之sed命令
  2. 机器学习实战笔记(Python实现)-00-readme
  3. java多线程详解(7)-线程池的使用
  4. github打不开
  5. php入门
  6. 安装faac编译问题
  7. Js笔试题之parseInt()和.map()
  8. 自定义Attribute 服务端校验 客户端校验
  9. 微软职位内部推荐-Senior NLP Scientist & Developer
  10. IntraWeb.v14.0.32安装及破解指南
  11. jQuery 随滚动条滚动效果 (适用于内容页长文章)
  12. 普联的路由器TL-WR842N和TL-WR845N还有 TL-WR847N哪一个更好,我是家用
  13. 如何通过subId来获取phoneId?
  14. 使用java API操作hdfs--通过filesystem API 来读取数据
  15. CJOJ 2171 火车站开饭店(树型动态规划)
  16. [ASP.NET MVC]笔记(三) 成员资格、授权和安全性
  17. storm消费kafka实现实时计算
  18. C Primer Plus 第8章 字符输入/输出和验证输入 编程练习
  19. angular中因异步问题产生的错误解决方法
  20. ping的作用

热门文章

  1. ubuntu配置机器学习环境(一) ubuntu安装
  2. JENKINS系统的安装部署
  3. JS 实现AJAX封装(只限于异步)
  4. xss挑战赛小记 0x01(xsstest)
  5. Git使用之一:创建仓储和提交文件
  6. 网站的robots.txt文件
  7. Yarn 调度器Scheduler详解
  8. 管理员常用Windows PowerShell命令Top25
  9. jq 一个强悍的json格式化查看工具
  10. html基础问题总结