Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
オンプレMySQLをTiDB Cloudへ移行した手順紹介 @TiUG #0
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Tao Watanabe
January 29, 2024
Technology
540
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
オンプレMySQLをTiDB Cloudへ移行した手順紹介 @TiUG #0
TiUG #0 (
https://tiug.connpass.com/event/303186/)のLT資料です
。
Tao Watanabe
January 29, 2024
More Decks by Tao Watanabe
See All by Tao Watanabe
マイクロサービスの効率的な監視〜不安定な依存先との闘い〜
taowata
6
2.9k
Other Decks in Technology
See All in Technology
お客様の「やりたい」の先を見通す合意形成プロセス ~裏にある課題と不安を解きほぐすコツ~
yukakoseki
0
110
AI時代に求められる優秀なTechLeadの振る舞い
pospome
11
15k
Kiro Crew の Bot (続く役目を任せる窓口) | 目指せ Kiro マスター 12
inariku
PRO
2
290
【dbts2026】AIエージェントの 判断と探索を変える、 データベース エンジニアリング― 既存DBの処理と依存関係から作る、オペレーショナルオントロジー ―
shisyu_gaku
0
240
Shared Signals Framework 仕様解説
oidfj
0
190
SLOを阻む不安
sraku2159
0
230
2026 Apache Flink Community Checkpoint
rmetzger
0
200
Flutter Widget Previewerで始めるUIプレビューとVRTの自動化
sakusaku3939
0
210
AIコーディングはじめました
miso
0
150
AIがGISを代替する日:〜すべてをAIが創る時代に、私たちがFOSS4Gに関わる意味〜
lehupa
1
210
基本から分かる!AWSセキュリティ運用の考え方と任せ方
cmusudakeisuke
1
450
顧客合意を取りながら進めるAWSコスト削減の実践
optim
0
130
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
96
6.9k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
290
So, you think you're a good person
axbom
PRO
2
2.3k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
510
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.8k
Building the Perfect Custom Keyboard
takai
2
950
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
350
Git: the NoSQL Database
bkeepers
PRO
433
67k
Odyssey Design
rkendrick25
PRO
2
930
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Ethics towards AI in product and experience design
skipperchong
2
460
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
680
Transcript
オンプレMySQLを TiDB Cloudへ移行した手順紹介 TiUG #0
自己紹介 DMM.com プラットフォーム事業本部 渡部太緒 (わたなべ たお) X: @tao_wata 認証APIの開発・運用を行っています
発表内容 • オンプレMySQLをTiDB Cloudへ移行した手順 • 差分チェックツール sync-diff-inspector の詰まりどころ
オンプレMySQLをTiDB Cloudへ 移行した手順
移行の要件 サービス無停止
移行手順 1. 既存データdump&import 2. 並行書き込み 3. 差分チェックと差分解消 4. 参照先をMySQLからTiDBへ切り替え
オンプレ環境 既存データをdumpし、S3へアップロード MySQL .sql ファイル Amazon S3
TiDB CloudへS3経由でデータimport コンソールからimportできる 空のテーブルを作成しておく Amazon S3 TiDB Cloud
オンプレ環境 並行書き込み API MySQL 書き込み (Upsert) 書き込み 読み取り MySQLとTiDB片方の書き込みが 失敗した場合
両方ロールバックして整合性を担保 TiDBへの書き込みはUpsert
差分チェックと解消 オンプレMySQLのデータdump から 並行書き込み開始 までの間に 更新のあったデータはTiDBに同期されていない → sync-diff-inspectorで差分チェックし、差分解消クエリを実行する
sync-diff-inspectorとは GitHub: pingcap/tidb-tools リポジトリで管理されているツール MySQLとTiDB, MySQLとMySQL, TiDBとTiDBのデータを比較できる 少量のデータに差分があるシナリオで差分解消ができる
sync-diff-inspectorの実行 オンプレ環境 API MySQL 書き込み 書き込み 読み取り sync-diff-inspector 読み取り 読み取り
差分解析結果と 差分解消クエリの出力
差分解消クエリの実行 sync-diff-inspectorによって出力された差分解消クエリを TiDBに対して実行 → 再度sync-diff-inspectorを実行し、差分がないことを確認
意外とうまくいった 実は、sync-diff-inspectorはデータ書き込みのあるMySQLとTiDB 間 のオンラインチェックをサポートしていない 確かにエラーの発生で差分チェックが中断することがあったが... [FATAL] [diff.go:548] ["the count is
not correct"] 出力できたところまでの差分解消クエリの実行と差分チェックの再実行 を繰り返すことでデータ同期が完了
参照先をMySQLからTiDBへ切り替え 既存のSQLがそのまま使えるので、苦戦することなく切り替え完了 オンプレ環境 API MySQL 書き込み 書き込み 読み取り 読み取り
結果 サービス無停止でのDB移行ができた
sync-diff-inspectorの 詰まりどころ
現象: 差分解消クエリが文字化け ↓ BINARY型カラムのデータがそのまま出力されていたため文字化けしてしまった REPLACE INTO `table_name`(...,`binary_column`, ...) VALUES (...,'ßä���<95>ko^P��«',
...); REPLACE INTO `sbtest`.`sbtest99`(`id`,`k`,`c`,`pad`) VALUES (3700000,2501808,'hello','world');
解決策: 16進数形式でクエリを出力するよう改修 sync-diff-inspectorをフォーク 16進数表記にデータ変換し、 UNHEX関数を利用してクエリを出力するよう改修 REPLACE INTO `table_name`(...,`binary_column`, ...) VALUES
(...,UNHEX('hexadecimal representation'), ...);
Feature Request 投げました sync-diff-inspector: use UNHEX for BINARY and VARBINARY
types #746 https://github.com/pingcap/tidb-tools/issues/746
まとめ
まとめ TiDB Cloudのimport 機能とsync-diff-inspectorを利用して 無停止移行ができた sync-diff-inspectorがもっと使いやすくなると嬉しい