db tech showcase 2016 Tokyo で発表した資料です。MySQL 5.7の新機能のうち、InnoDBについてまとめてあります。Read less
何がしたいの? 一般クエリとスロー クエリのログ出力先の選択 に記載の通り、log-output を TABLE にすれば、クエリログが mysql.general_log テーブルに保存されるようになります。 ログを SQL で検索できるようになるのでそれはそれは死ぬほど便利なんですが、ファイルではないので logrotate が行われません。 スロークエリはともかく、一般クエリログは膨大なサイズに成り得ますので、できれば自動で削減したいです。 が、簡単に調べたところ、mysql.general_log と mysql.slow_log は「log tables」と呼ばれるちょっと特別扱いなテーブルらしく、能動的な INSERT/UPDATE/DELETE 処理が一切行えず、TRUNCATE のみが可能なようです。 定期的に TRUNCATE してもいいんですが、それだと「ログを SQL
テスト・開発に使用するデータ生成の必要性 動作確認テストや開発時に使用するデータベースのデータ、どのように準備していますでしょうか?毎回手動で作成している、本番環境から持ってくる。これらは一番良くない例ですよね。 毎回手動で作成していては、開発環境構築の度に、テスト実行の度に作業コストがかかり、オペレーションミスも発生しやすくなります。知っていないと用意できないデータ項目などもあるでしょう。それらを毎回一つ一つ確認するのは大変な作業です。 本番環境のデータを使用することが危険であることは言うまでもないと思います。個人情報を扱っているシステムであれば、情報保護の点から大変なリスクを犯す行為です。メールアドレスを保存してあるシステムであれば、オペレーションミスにより不要なメールを実際に送信してしまう危険性も伴います。 特に、動作確認の際に自動テストを実行する場合、想定通りのデータが入って
DockerHubでは公式のMySQLイメージが無料で公開されています。 これを使えば簡単にDockerでMySQLサーバを起動することができます。データの永続化もできます。 https://hub.docker.com/_/mysql/ 2015年10月現在では下記3種類のバージョンが用意されています。 タグを指定することで任意のバージョンのイメージを取得できます。 5.5 5.6 5.7 (latest) イメージの取得方法 docker pull mysql これで最新の安定版を取得できます。 バージョンを明示的に取得したい場合はタグを使います。 docker pull mysql:5.7 (2015/10/25現在だと、mysql, mysql:latest, mysql:5.7, mysql:5.7.9はどれも同じイメージを指します。) これのDockerfileを見たい場合はこ
インフラストラクチャー部の菅原(@sgwr_dts)です。 インフラストラクチャー部のメンバーはオペレーションのため強力な権限のMySQLアカウントを使用していますが、サービス開発をするエンジニアも業務のためにサービスのDBの参照・更新権限を持ったアカウントが必要になることがあります。 セキュリティやオペレーションミスのことを考えると、すべてのエンジニアのアカウントをスーパーユーザーにするわけにはいかないため、都度適切な権限を付与していますが、手動での作業は地味に手間がかかります。 そこでクックパッドではMySQLのアカウント情報をコード化し、リポジトリで管理するようにしています。 gratanによるコード化 MySQLのアカウント管理はgratanという自作のツールを使って行っています。 gratanを使うとMySQLのアカウントをRubyのDSLで記述することができるようになります。
さらば、愛しき論理削除。MySQLで大福帳型データベースを実現するツール「daifuku」を作ってみた 先のエントリ「論理削除はなぜ「筋が悪い」か」で書いたとおり、データベースに対して行われた操作を記録し、必要に応じて参照したり取り消したりしたいという要求は至極妥当なものですが、多くのRDBは、そのために簡単に使える仕組みを提供していません。 daifukuは、RDBに対して加えられた変更をトランザクション単位でRDB内にJSONとして記録するためのストアドやトリガを生成するコマンドです。 % daifuku dbname tbl1 tbl2 > setup.sql のように実行すると、指定されたテーブル(ここではtbl1とtbl2)にセットすべきトリガや、更新ログを記録するためのテーブル「daifuku_log」を生成するCREATE TABLEステートメントなど、必要なSQL文をset
メリークリスマス!!やあ、良い子のみんな!!サンタクロース・・・ではなく、ヒゲモジャギークからのクリスマスプレゼントだよ!! というわけで、MySQL Casual Advent Calendarの25日目である。今朝Advent Calendarを覗いてみると、本日分のエントリーが無かったので、急遽書くことにした。Advent Calendar最後の日、クリスマスを飾る記事のテーマはGTIDだ。 前回の投稿では、MySQL 5.6の目玉機能として、レプリケーションがクラッシュセーフになったことを挙げた。レプリケーションまわりで言えば、もうひとつ外せない目玉機能がある。それがGTID(Global Transaction ID)である。 GTIDは良くも悪くもレプリケーションの運用を変化させる。GTIDを使うことによって得られる最大のメリットは、CHANGE MASTER TOでバイナリロ
毎回わからなくなってググってるから今度からここに追記していく。 MySQL PostgreSQL SHOW DATABASES; \l USE dbname \c dbname SHOW TABLES; \dt SELECT * FROM tblname\G \x on SELECT * FROM tblname; SELECT * FROM information_schema.processlist; SELECT * FROM pg_stat_activity; KILL <pid>; SELECT pg_terminate_backend(pid); KILL QUERY <pid>; SELECT pg_cancel_backend(pid); table / column の情報 MySQL PostgreSQL SHOW TABLE STATUS FROM dbname; わ
インフラストラクチャー部の成田(@mirakui)です。 Rails の OR マッパーである ActiveRecord ですが、みなさんどのように運用していますか? ActiveRecord を使うと、 SQL を直接扱うことなく、抽象化された表現で RDB にアクセスできるので、アプリケーションの開発効率という観点ではメリットが大きいです。 一方で、 ActiveRecord が駆使されているアプリケーションをサーバに配置してプロダクションとして運用する立場からすると、いくつかの問題に突き当たります。 まずはクックパッド本体アプリケーションにおける、最新の rake stats をご覧ください。 +----------------------+-------+-------+---------+---------+-----+-------+ | Name | Lines | LOC
全国1億2000万の Docker ファンの皆さんこんにちは。 MySQL の起動がとてつもなく遅いのは有名な話。 ところが Docker コンテナの起動はなかなか早いので、 MySQL を使っているようなテストを高速化するケースで有用性が認められるのではないかと思って PoC を書いてみた。 (宣伝)こういった話も含めて YAPC でトークしたいので SNS 等で upvote お願いします: ( ✌'ω')✌ 楽しいモデル層開発 - YAPC::Asia Tokyo 2014 (宣伝おわり) MySQL を使ったテスト MySQL を使ったテストをする場合、だいたい次の 2 パターンになる。 MySQL をテストのたびに起動してクリーンな状態で使う ローカルにデーモンとして起動した MySQL に接続して DROP TABLE や TRUNCATE でクリーンな状態にして使う だけど、
ひとつのMySQLサーバーだけでなく、もうひとつ別のMySQLサーバーに接続したい欲張りさんのための方法。 development: # ひとつめはいつもどおり adapter: mysql2 encoding: utf8 database: database1 username: hoge password: hogehoge host: database1.url port: 3306 pool: 5 timeout: 5000 test: # 略 production: # 略 # ふたつめ database2: adapter: mysql2 encoding: utf8 database: database2 username: fuga password: fugafuga host: database2.url port: 3306 pool: 5 timeout: 5000
こんにちは、DBAのたなかです。 べんりなべんりなprofilingですが、5.6からは非推奨になってしまいました。 mysql56> SET profiling= 1; Query OK, 0 rows affected, 1 warning (0.03 sec) mysql56> SHOW WARNINGS; +---------+------+----------------------------------------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------------------------------------+ | Warning | 1287 | '@@profiling' is
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く