mysqlのibdataが原因でディスクフルになったときに復旧方法
さっきまで落ちてたsakuratan.bizです。どーもすみません。
原因は MySQL の InnoDB が使用する ibdata ファイルがディスクを食いつぶしてディスクフルになってたためでした。
ibdata はテーブルスペースを保存するファイルで、CentOS ですとデフォルトで /var/lib/mysql/ibdata1 に作成されます。MySQL のデフォルトでは ibdata が自動で拡張されていく設定になっていますので、放っておくとどんどんファイルサイズがでかくなって、さくらの VPS とかですと結構あっさりディスクフルになりました。
とりあえず復旧できたんで手順とか残しときます。同じようにトラブった方は参考程度にどうぞ。
まず ibdata1 がディスクを食いつぶしているので、復旧するにはこれを消すとかファイルを小さく必要があります。
ファイルサイズを小さくする方法は調べたらいっぱいでてきますので(13.5.7 InnoDB データとログ ファイルの追加と削除 とか ibdata1 のサイズを減らす手順 とか ibdata1のサイズを減らす方法とか)、概要だけ引用しますと、
- 全ての InnoDB テーブルをダンプする為に mysqldump を利用してください。
- サーバを停止してください。
- 全ての存在するテーブルスペース ファイルを削除してください。
- 新しいテーブルスペースを設定してください。
- サーバを再起動してください。
- ダンプ ファイルをインポートしてください。
MySQL :: MySQL 5.1 リファレンスマニュアル :: 13.5.7 InnoDB データとログ ファイルの追加と削除
という感じだったりします。要はバックアップ取ってテーブルスペースを作り直せということのようです。
ただまあディスクフルしてるんでサーバ上に mysqldump のダンプファイルなんか置けないので、ssh 経由で mysqldump を実行することにしました。↓のように ssh を起動することで、ネットワーク越しにコマンドを実行して mysqldump の出力をローカルに直接保存できます。
mysqldump -v -u DBUSER \
--default-character-set=binary -p DBNAME \
TABLE1 TABLE2 ... | \
gzip > mysql.dump
それとコマンドを実行する前にサーバ上のサービスをできるだけ止めてある程度作業用のメモリの確保して、ついでに不要なファイルをできるだけ削除しておいた方が良いと思います。メモリかスワップか何が原因か調べてる暇も無かったので詳細は不明ですが、リソースが足らないと mysqldump がテーブル構造を読み込む際にエラーを出します。
今回はリストアする必要が無いテーブルが何個かありましたのでダンプする対象をテーブル単位で指定していますが、全部リストアする場合はデータベース単位で指定してもらえばよろしいかと思います。運用形態によっては mysqldump に –single-transaction オプションを指定してもらった方が良いかもしれません(とりあえずウチんとこでは不要だったので指定してませんが)。
ダンプできたら mysql を止めてから ibdata1 と ib_logfile0 と ib_logfile1 を消します。他のサイトだとリネームした方が良いとか書いてますがそんな余裕無いのでいきなりマジ削除しました。最悪データ全部豚でもいーや、の覚悟でどうぞw
rm -f ibdata1 ib_logfile[01]
/etc/my.cnf に ibdata1 のサイズ制限と innodb_file_per_table を加えてからmysqld を再起動して回復しましたよ、という感じです。
innodb_file_per_table
innodb_file_per_table を指定すると、各テーブルの中身は共有テーブルスペースでは無く個別のファイルに保存されるようになるのですが、こっちのファイルも放置しておくと大きくなっていきますので、定期的に ALTER TABLE を実行してデフラグする必要があります。(詳しくは 13.5.14.3 テーブルのデフラグメント化 とか 拡張され続ける InnoDB のデータファイルのサイズを小さくする方法 とかをご覧ください。)
個別に ALTER TABLE 実行するのも面倒なので、全ての InnoDB テーブルに対して ALTER TABLE を実行するスクリプトも書いてみました。よろしければどうぞ。
import MySQLdb
def main():
conn = MySQLdb.connect(user='root')
cur = conn.cursor()
cur.execute('SHOW DATABASES')
databases = [database for database, in cur if database != 'mysql']
cur.close()
conn.close()
for database in databases:
conn = MySQLdb.connect(user='root', db=database)
cur1 = conn.cursor()
cur1.execute('SHOW TABLE STATUS')
for t in cur1:
tablename = t[0]
engine = t[1]
if engine and engine.lower() == 'innodb':
print 'Defrag %s.%s' % (database, tablename)
cur2 = conn.cursor()
cur2.execute('ALTER TABLE %s ENGINE=INNODB' % tablename)
cur2.close()
cur1.close()
conn.close()
if __name__ == '__main__':
main()
MySQL にパスワード無しで root ログインできる前提でスクリプト書いてますので、その辺の設定変えている方は適当に改造して使ってください。
Widget バージョン2を利用させて頂いておりますm(_ _)m
本、ミュージック、DVDはいまだに落ちてるお(´・ω・`)
同じくver2をひと通り利用させてもらってますが、widgetが一切表示されない状態が続いております。
twitterの方に知らせた方が早いかも知れません
あら本当ですね。直しますので少々お待ちください。
ちなみに widget は別のサーバで動かしてますので今回のサーバ移転は関係ないです。
直しました。某外部ウェブサービスを使っているのですがそれのバージョンが上がって一部動かなくなっていたようです。
表示が直るのはサーバ上のデータのキャッシュの有効期限が切れてからになりますので、もうちょっと時間かかると思います。
キャッシュのタイムアウト確認しました。全部直ってると思います。
↓もどうぞ。
http://sakuratan.biz/archives/4574
Can yoս tell uѕ more aƅout this? Ι’ⅾ like to find out some additional іnformation.
Feel free to surf to᧐ my bloog post :: https://www.youtube.com/watch?v=3n6qU2luteg
座椅子のなるほど案。記録文書をたてる。座椅子の当て嵌めるおもいのほかとは。直後にな感じで行きます。
Everything posted made a bunch of sense. However,
think on this, what if you added a little content? I ain’t suggesting your information is not solid., however what if you added a
headline that makes people desire more? I mean mysqlのibdataが原因でディスクフルになったときに復旧方法 |
さくらたんどっとびーず is a little plain. You might peek
at Yahoo’s home page and note how they write article titles to
get people interested. You might add a video or a picture or two to get people excited about what you’ve
written. Just my opinion, it could make your website a little
livelier.
Kumpulan situs daftar mpo slot gacor terbaru dan terpercaya deposit pulsa tanpa potongan 24jam
This site was… how do I say it? Relevant!! Finally I have found something that helped me.
Thank you!
エルメス ユニクロ zara
非常にいい書いてあったけどそうは思えない。
自社基準なので仕方ないと思うけど、もうここで買わない。
Instagram URL Shortener
[...]please check out the internet sites we follow, like this one, because it represents our picks through the web[...]
esports
[...]Sites of interest we have a link to[...]
french bulldog texas
[...]Here is a good Blog You might Come across Intriguing that we Encourage You[...]
french bulldog
[...]The details mentioned inside the post are several of the most beneficial available [...]
french bulldog rescue
[...]always a big fan of linking to bloggers that I adore but really don’t get a good deal of link like from[...]
isla mujeres golf cart rental
[...]we like to honor quite a few other net web-sites on the net, even when they aren稚 linked to us, by linking to them. Beneath are some webpages worth checking out[...]
dog registry
[...]the time to read or check out the content material or web-sites we’ve linked to beneath the[...]
arma reforger ESP
[...]one of our visitors not too long ago encouraged the following website[...]
marvel rivals hacks
[...]Here is an excellent Weblog You may Uncover Fascinating that we Encourage You[...]
delta wallhack
[...]below you will uncover the link to some internet sites that we consider you ought to visit[...]
undetected battlefield hacks
[...]The information talked about in the report are some of the best out there [...]
mw3 cheats download
[...]the time to study or stop by the content material or web sites we have linked to beneath the[...]
download hunt cheats
[...]below you値l locate the link to some sites that we believe you must visit[...]
chamy rim dips
[...]always a huge fan of linking to bloggers that I like but don稚 get lots of link like from[...]
french bulldog for sale near me
[...]Wonderful story, reckoned we could combine a handful of unrelated information, nonetheless truly worth taking a appear, whoa did a single find out about Mid East has got extra problerms too [...]
clima en chimalhuacán
[...]we prefer to honor lots of other web web sites around the net, even if they aren稚 linked to us, by linking to them. Under are some webpages worth checking out[...]
condiciones climaticas queretaro
[...]check below, are some entirely unrelated internet sites to ours, on the other hand, they may be most trustworthy sources that we use[...]
grey frenchies
[...]Sites of interest we have a link to[...]
best probiotic for french bulldogs
[...]Here is an excellent Weblog You may Uncover Exciting that we Encourage You[...]
moped rental isla mujeres
[...]that will be the end of this post. Right here you will come across some web-sites that we feel you値l value, just click the links over[...]
rent a yacht in cancun
[...]please check out the sites we stick to, including this a single, as it represents our picks from the web[...]
isla mujeres condo
[...]The facts talked about inside the write-up are a few of the best available [...]
french bulldog puppies for sale $200
[...]always a big fan of linking to bloggers that I like but do not get a good deal of link adore from[...]
french bulldog blue color
[...]Here is a superb Blog You might Locate Interesting that we Encourage You[...]
dump him shirt
[...]just beneath, are a lot of entirely not associated web sites to ours, however, they may be certainly worth going over[...]
in vitro fertilization mexico
[...]just beneath, are quite a few absolutely not associated internet sites to ours, nonetheless, they are certainly worth going over[...]
elizabeth kerr
[...]just beneath, are quite a few entirely not associated websites to ours, nevertheless, they may be surely really worth going over[...]
늑대닷컴
[...]the time to read or check out the content or web pages we’ve linked to below the[...]
johnny dang
[...]Every after inside a though we opt for blogs that we read. Listed below are the most recent web sites that we pick [...]
늑대닷컴
[...]Every after in a whilst we select blogs that we study. Listed below would be the most current web-sites that we decide on [...]
joyce echols
[...]check beneath, are some totally unrelated internet websites to ours, on the other hand, they are most trustworthy sources that we use[...]
yorkie poo breeding
[...]please stop by the web pages we stick to, including this one particular, as it represents our picks in the web[...]
boston terrier puppies in massachusetts
[...]always a large fan of linking to bloggers that I like but don稚 get a great deal of link love from[...]
dog probiotic chews on amazon
[...]usually posts some extremely intriguing stuff like this. If you are new to this site[...]
fertility institute of nj
[...]here are some links to sites that we link to because we believe they may be worth visiting[...]
dr kim acupuncture
[...]we came across a cool web page which you may possibly get pleasure from. Take a look in case you want[...]
we buy french bulldogs
[...]usually posts some very fascinating stuff like this. If you are new to this site[...]
mexican candy store near me
[...]please visit the internet sites we follow, including this a single, because it represents our picks in the web[...]
mexican candy store near me
[...]please take a look at the web sites we comply with, such as this 1, as it represents our picks through the web[...]
mexican candy store near me
[...]very couple of web-sites that come about to be detailed below, from our point of view are undoubtedly nicely really worth checking out[...]
mexican candy store near me
[...]although sites we backlink to below are considerably not associated to ours, we really feel they may be actually worth a go by means of, so possess a look[...]
linh hoang
[...]although sites we backlink to below are considerably not connected to ours, we really feel they are in fact really worth a go through, so possess a look[...]
french bulldog shop
[...]Sites of interest we’ve a link to[...]
brazil crop top
[...]we came across a cool website which you may possibly take pleasure in. Take a search when you want[...]
gaming
[...]just beneath, are many totally not related sites to ours, on the other hand, they may be certainly worth going over[...]
mexican candy store
[...]Here is a good Blog You may Discover Interesting that we Encourage You[...]
clima cuautitlán izcalli
[...]usually posts some incredibly exciting stuff like this. If you池e new to this site[...]
culiacan clima
[...]Sites of interest we’ve a link to[...]
wix seo
[...]the time to study or pay a visit to the subject material or web-sites we have linked to beneath the[...]
best canine probiotics for bullies
[...]Here is a superb Weblog You may Find Fascinating that we Encourage You[...]
probiotics for english bulldogs
[...]please check out the web sites we follow, such as this a single, because it represents our picks from the web[...]
french bulldog pug mix
[...]Here is a good Blog You may Discover Interesting that we Encourage You[...]
french bulldog poodle mix
[...]please check out the websites we follow, which includes this a single, as it represents our picks from the web[...]