开发者

How to prevent corrupt database - MySQL

Currently running an ecommerce store. In the last coupl开发者_运维技巧e of months we have been experiencing lots of very odd / random issues that have been affecting the store. In almost all cases we have been unable to replicate the faults and it turned out to be a corrupt database.

What can cause this to happen? How can it be prevented?

EDIT: Sorry, this is pretty vague. Basically Im looking for things that could potentially cause a database corruption. Its a MySql4 database.

What essentially causes database corruption and how can you detect and prevent.

Just generally.


The question is very broad so I will try to answer with broad suggestions. MySQL, while not what I would call an enterprise-level DBMS, should not have random corruption problems.

  • Check your hardware. I don't know your platform, but assuming it's linux you can use Try prime95 to test your processors and smartmontools to do some basic disk tests. Memtest86 can diagnose memory errors, but you probably don't want to reboot your server just for that.
  • Some specific kernel versions have, in my experience, possibly led to unexplained problems. Can you upgrade?
  • Test importing the data on a newer version of MySQL, or on a different system. This may not be useful because "no errors yet" doesn't mean the problem is resolved.
  • If you are using MyISAM tables, which should still work fine, you may try an ACID compliant engine. InnoDB was all the rage for a while, but I believe it's been replaced.


This is a fairly general question, so I will just give you what I have seen personally.

Most of the MySQL database failures that I have seen have been because of a hard drive being corrupted some how or power failures when a server is hard powered-off instead of shutdown properly.

The main thing you can do to prevent damage in these two cases is to make backups of your database often (and store them somewhere that will not be tampered with), this way you will always have something recent to revert back to. Also, storing your data in a RAID is helpful because if depending on your setup, you can survive if a disk or two crashes. Having backup power supplies for your disks in case power goes out is good too.

Also, try to use a robust tables that can recover if problems arise. I used to use MyISAM tables but if I ever ran into a problem I would lose the data and have to start from the latest backup. So I switched to InnoDB and then I was actually able to recover from most crashes. However, this was a while ago and InnoDB may not be the latest and greatest anymore.

Anyways, good luck with solving your issues and if you have anymore information, hopefully I can help more.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜