PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx /...

28
Copyright © funplex, Inc. All Rights Reserved. Copyright © funplex, Inc. All Rights Reserved. オンプレからAurora移行する3つの手法 #AuroraMatsuri 2017/07/05 ~ mysqldump, xtrabackup, DMS ~

Transcript of PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx /...

Page 1: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved. Copyright © funplex, Inc. All Rights Reserved.

オンプレからAuroraへ 移行する3つの手法

#AuroraMatsuri

2017/07/05

~ mysqldump, xtrabackup, DMS ~

Page 2: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• はじめに • 自己紹介

• funplex紹介

• funplexのシステム移行

• オンプレからAuroraへ移行

• mysqldump

• XtraBackup

• DMS

• さいごに

アジェンダ

Page 3: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved. Copyright © funplex, Inc. All Rights Reserved.

はじめに

Page 4: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

自己紹介

名前・出身

• パク ジョンウン

• 韓国出身、渡日12年目

• https://www.facebook.com/jungeun.park.1112

経歴

• インフラ10年目

• 元グリーのインフラ • 構築、監視、運用、などインフラ全般の業務を担当

• グリーインフラ女子の一人

• 現ファンプレックスのインフラ

• AWS歴:3年

好きなもの

• Aurora

• Au肉、Au酒

得意分野

• インフラ費用削減

• AWSレクチャー

Page 5: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

funplexとは?

「グリー株式会社」100%出資のゲーム運営子会社

社名:ファンプレックス株式会社 親会社:グリー株式会社 設立:2015年10月15日 従業員数:205名(2017年7月時点) 主要事業:ゲーム運営 運営タイトル数:13本 代表取締役社長:下村直仁 コーポレートサイト:https://funplex.co.jp/

グリーが培ったゲーム運営のノウハウを集結した 「ソーシャルゲーム運営のプロフェッショナル集団」です

インタビュー記事(出典:SGI) http://gamebiz.jp/?p=181017

Page 6: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved. Copyright © funplex, Inc. All Rights Reserved.

funplex のシステム移行

Page 7: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

funplexのシステム移行

システム移管の効果

技術的負債の返済

耐障害性の向上

コストパフォーマンスの最適化

運用の最適化

Page 8: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

funplexのシステム移行

システム移管で行うこと

ドメイン変更

リポジトリ変更 deployツール変更

管理ツールの移行

cacheサーバーをElastiCacheへ移行

DBサーバーをAuroraへ移行

CDN導入

QA環境の移行 開発環境の移行

SSL証明書変更

モニタリングツール変更

MWバージョンアップグレード

Page 9: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

funplexのシステム移行

システム移管で行うこと

ドメイン変更

リポジトリ変更 deployツール変更

管理ツールの移行

cacheサーバーをElastiCacheへ移行

DBサーバーをAuroraへ移行

CDN導入

QA環境の移行 開発環境の移行

SSL証明書変更

モニタリングツール変更

MWバージョンアップグレード

Page 10: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved. Copyright © funplex, Inc. All Rights Reserved.

オンプレからAuroraへ移行

Page 11: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• mysqldump

• XtraBackup

• DMS (Database Migration Service)

Aurora移行の手法

以下の3つの手法について事例を紹介します。

※ 紹介する事例は契約上タイトル名が公開できない旨、ご了承くささい。

Page 12: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• mysqldump

• XtraBackup

• DMS (Database Migration Service)

Aurora移行の手法

Page 13: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

MySQL 5.6

mysqldump + mysqlimport (Bulk Data Loading)

Aurora移行の手法

dump.sql

Cluster Volume

※ システム構成図は簡略してデータベースの1クラスタだけ表しました。

Replication

Master Slave Standby

Aurora Cluster

作業用 EC2

① mysqldump取得 ② mysqldump転送

③ mysqlimport

mysqldumpでテーブル定義とテーブルデータを整形して

データを抽出

mysqlimportでデータを 並列でロード

writes

プロダクト:某ソーシャルゲーム DAU :約4万 (2016/06 システム移行当時)

DBエンジン :MySQL 5.6 DBクラスター数:7以上 DBレコード数 :3億件以上

Page 14: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• MySQL の機能だけで済む • 別途インストールなど不要

• Bulk Data Loading でデータ移行の高速化 • 並列して2本以上のデータの流し込みが可能なので

テーブルインポートや DB インポートより早い

mysqldump + mysqlimport (Bulk Data Loading)

Aurora移行の手法

• mysqlimport の際にやりすぎて Aurora が ハングアップした • 1000万件(1.78GB/csv)を9本並列を流し仕込んだ

• aurora (db.r3.8xlarge) が耐えられなかった

• トランザクションが長すぎたため、トランザクションの サイズを小さくした

• 流す本数を減らして対応した(100万件を5本並列に変更)

よかったところ

大変だったところ

Page 15: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• データ量が少ないデータベース • レコード数が少なければテーブルインポートや

DBインポートでも良い

mysqldump + mysqlimport (Bulk Data Loading)

Aurora移行の手法

• サービス停止を伴う • データ量に比例して長時間かかるケースがある

• 13時間くらい所要

• レコード数3億件の規模

Page 16: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• mysqldump

• XtraBackup

• DMS (Database Migration Service)

Aurora移行の手法

Page 17: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

MySQL 5.6

XtraBackup

Aurora移行の手法

Cluster Volume

※ システム構成図は簡略してデータベースの1クラスタだけ表しました。

Replication

Master Slave Standby

Aurora Cluster

③ aurora 構築

DBサーバーに XtraBackup を インストールする

writes S3

bucket

プロダクト:某ソーシャルゲーム DAU :約6万 (2016/11 システム移行当時)

DBエンジン :MySQL 5.6 DBクラスター数:20以上 DBレコード数 :6億件以上

① XtraBackup取得 ② S3 bucket に backup 転送

Page 18: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• mysqldump と比べて Backup, Restore が高速

• Aurora 構築が簡単 • XtraBackup から直接 Aurora の構築が可能

XtraBackup

Aurora移行の手法

• DBサーバーに XtraBackup をインストール • 作業自体は大して大変ではなかった

よかったところ

大変だったところ

Page 19: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• 簡単かつ確実に移行可能 • テーブルの定義を手動でインポートしたりしなくても済む

XtraBackup

Aurora移行の手法

• サービス停止を伴う • データ量に比例して長時間かかるケースがある

• 5時間くらい所要

• レコード数6億件規模

• いくつか制約あり • http://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/UserGuide/Aur

ora.Migrate.MySQL.html#Aurora.Migrate.MySQL.S3

• プロシージャは対応しない、など

Page 20: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• mysqldump

• Xtrabackup

• DMS (Database Migration Service)

Aurora移行の手法

Page 21: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

DMS

MySQL 5.1 → 5.5

MySQL 5.1

DMS (Database Migration Service)

Aurora移行の手法

Cluster Volume

※ システム構成図は簡略してデータベースの1クラスタ(MySQL5.1ケース)だけ表しました。

Master Slave Standby

Aurora Cluster

① snapshot 取得

snap shot

オンプレ環境とAWSの間を 通してReplicationする

Stunnel 以外に Direct Connect でも可能

writes

プロダクト:某ソーシャルゲーム DAU :約8万 (2017/06 システム移行当時)

DBエンジン :MySQL 5.1, 5.6 DBクラスター数:25以上 DBレコード数 :60億以上

Replication

proxy

Replication

Replication

Replication

Stunnel

⑤ Replication Instance 構築

⑥ DMSタスクでデータ移行

④ Aurora構築

DMSはデータとキーしか 移行できないため、テーブル

定義などは mysqldump で移行

⑧ Replication設定

⑦ Replication設定

③ 5.1から5.5へVerUP

② snapshotで構築

Page 22: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• 移行当日の作業が簡単 • Behind がないことを確認して

• Aurora へ Endpoint を変更するだけ

• サービスのメンテナンス時間が短縮できる

DMS (Database Migration Service)

Aurora移行の手法

• 事前準備として構築作業が発生 • AWS中に MySQL on EC2 + DMS + Aurora を

各クラスター分構築するので手間がかかる

• MyISAM など replication ができないテーブルは 手動でテーブルを作成

よかったところ

大変だったところ

Page 23: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

• 長時間サービス停止が困難なシステム

DMS (Database Migration Service)

Aurora移行の手法

• オンプレとAWS間のNW品質によって レプリケーションが影響を受ける • Stunnel はほとんど behind が発生しなかった

• DMSの制約あり • http://docs.aws.amazon.com/ja_jp/dms/latest/userguide/CHAP_Sour

ce.MySQL.html

• Drop Table、Rename Table できない、など

Page 24: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved. Copyright © funplex, Inc. All Rights Reserved.

さいごに

Page 25: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

mysqldump XtraBackup DMS

各移行手法の工数

事前準備の工数 メンテ作業の工数 サービス停止時間

まとめ

Page 26: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.

システムの規模や状況に応じて、

適切な移行方法を選びましょう!!

さいごに

Aurora 専用のかっこいいアイコンがほしいです→

Page 27: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved. Copyright © funplex, Inc. All Rights Reserved.

ご静聴 ありがとうございました!!

Page 28: PowerPoint template v1.3.pptx / パワーポイントテ … PowerPoint_template_v1.3.pptx / パワーポイントテンプレート Author Hiroto Nishimura Created Date 7/19/2017

Copyright © funplex, Inc. All Rights Reserved.