1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ROMAAdvent Calendar 2015

Day 15

エラー時の備えその2(snapshot / data backup)

Last updated at Posted at 2015-12-15

dataのバックアップを行うsnapshot機能です

条件

  • storage type: tokyocabinet

手順

コマンド

$ cpdb ${port No.}
  • 全てのインスタンスでsnapshotを取りたい場合は、各インスタンス毎にcpdbを実行してください

data directory確認(snapshot前)

$ ls -l localhost_10001/roma/
total 204900
-rw-r--r-- 1 root root 20975936 Dec 15 01:15 0.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:15 1.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 2.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 3.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 4.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 5.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 6.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 7.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:17 8.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:17 9.tc
-rw-r--r-- 1 root root        0 Dec 15 01:15 lock
-rw-r--r-- 1 root root        0 Dec 14 01:15 status.log.1

snap shot実行

$ cpdb 10001
waiting for storages[roma][0] == safecopy_flushed .
copy file : /usr/local/roma/app/localhost_10001/roma/0.tc
waiting for storages[roma][0] == normal .
.
.
.
waiting for storages[roma][9] == safecopy_flushed .
copy file : /usr/local/roma/app/localhost_10001/roma/9.tc
waiting for storages[roma][9] == normal .
finished

data directory確認(snapshot後)

$ ls -l localhost_10001/roma/
total 409764
-rw-r--r-- 1 root root 20975936 Dec 15 01:15 0.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:15 0.tc.20151215011546 # snapshotファイル
-rw-r--r-- 1 root root 20975936 Dec 15 01:15 1.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:15 1.tc.20151215011556 # snapshotファイル
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 2.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 2.tc.20151215011606 # snapshotファイル
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 3.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 3.tc.20151215011616 # snapshotファイル
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 4.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 4.tc.20151215011627 # snapshotファイル
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 5.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 5.tc.20151215011637 # snapshotファイル
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 6.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 6.tc.20151215011647 # snapshotファイル
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 7.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:16 7.tc.20151215011657 # snapshotファイル
-rw-r--r-- 1 root root 20975936 Dec 15 01:17 8.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:17 8.tc.20151215011707 # snapshotファイル
-rw-r--r-- 1 root root 20975936 Dec 15 01:17 9.tc
-rw-r--r-- 1 root root 20975936 Dec 15 01:17 9.tc.20151215011717 # snapshotファイル
-rw-r--r-- 1 root root        0 Dec 15 01:15 lock
-rw-r--r-- 1 root root     1714 Dec 15 01:17 status.log.1 # snapshot statusファイル
  • snapshotファイルはファイル名の末尾に実行日時がappendされています
  • status.logは、snapshotの実行ログです

ロジック

snapshotの処理は4つのステータスに分けられます

  • :normal
  • :flushing
  • :flushed
  • :cache cleaning

1. Status :normal

1_normal.jpg

2. Status :flushing

2_flushing.jpg

3. Status :flushed

3_flushed.jpg

4. Status :Cache Cleaning

4_chach_cleaning.jpg

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?