ふり返る暇なんて無いね

日々のメモ書きをつらつらと。メインブログに書くほどでもないことを流してます

2013-01-29日誌

MySQL5.5のmysqldumpの --dump-slave オプション

5.5から使えるらしい。
現状データディレクトリ丸ごとコピーしているので、ちょっと検証して見ても良いかも。
データの少なめのプロジェクトなら旨く回りそうな気がする。

--dump-slave[=value]

This option is similar to --master-data except that it is used to dump a replication slave server to produce a dump file that can be used to set up another server as a slave that has the same master as the dumped server. It causes the dump output to include a CHANGE MASTER TO statement that indicates the binary log coordinates (file name and position) of the dumped slave's master (rather than the coordinates of the dumped server, as is done by the --master-data option). These are the master server coordinates from which the slave should start replicating. This option was added in MySQL 5.5.3.

The option value is handled the same way as for --master-data and has the same effect as --master-data in terms of enabling or disabling other options and in how locking is handled.

In conjunction with --dump-slave, the --apply-slave-statements and --include-master-host-port options can also be used.

http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html#option_mysqldump_dump-slave

こんな感じでやるとよさそう。

mysqldump -u ${USER} -p --dump-slave --apply-slave-statements --include-master-host-port ${DATABASE}

SQLアンチパターン

SQLアンチパターン

SQLアンチパターン


読んでる。もう一回読み返す前提

1章ジェイウォーク(信号無視)

カンマ区切りで、複数の値を1つの列に入れるやつ。今だとJSONを文字列にしてやってしまうこともあるな。

2章ナイーブツリー(素朴な木)

も一回読み返す。

3章IDリクワイアド(とりあえずID)

現状、基本、PKはidだなあ。もう少し考えても良いかも。

4章キーレスエントリ(外部キー嫌い)

なぜか今のプロジェクト外部キー使ってないので、これも見直す。

5章EAV(エンティティ・アトリビュート・バリュー)