Download - RDBのDBAから見た GCP Managed Database
![Page 1: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/1.jpg)
https://gcpug.jp
RDBのDBAから見たGCP Managed Database
(Cloud SQL / Big Query)
熊野 良(Ryo Kumano)第21回 中国地方DB勉強会 in 山口 (2017/08/26)
![Page 2: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/2.jpg)
https://gcpug.jp
-本スライドは発表後、アップロードします。- レイアウト崩れや明らかに間違った表現などは修正後にアップロードをする場合があります。
-基本的に自分で触って経験した内容を発表させていただきます。
- H/W構成など、いわゆる「クラウドの向こう側」は別途公開されている資料などを参照ください。
最初に
![Page 3: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/3.jpg)
https://gcpug.jp
熊野 良 (Ryo Kumano) Twitter: @ryok0607
2014/06 〜 株式会社グルーヴノーツ(福岡)- 肩書:『サーバエンジニア・DBエンジニア』 -> 『クラウドエンジニア』実務で触ったRDB(GCP Managed DB以外)- Oracle Database: 7.3.4 / 8.1 / 9.0.1 / 9.2 / 10.1 / 10.2 / 11.2- MySQL: 4.0 / 5.1 / 5.5 / 5.6過去に携わったDB関連業務- DBA (動画配信サイト・ブログ・ソシャゲ / 営業支援ツール・大学講義履修)- Oracle Database サポートエンジニア- SI (DB設計・構築・コンサル)
自己紹介
![Page 4: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/4.jpg)
https://gcpug.jp
2点 宣伝させてください。
早速ですいませんが
![Page 5: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/5.jpg)
https://gcpug.jp
宣伝 その1
![Page 6: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/6.jpg)
https://gcpug.jp
GoogleCloudPlatform略してGCP
使ってますか??
宣伝 その1
![Page 7: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/7.jpg)
https://gcpug.jp
情報収集どうすればいいの?
GCP、興味あるし使いたいけど...
![Page 8: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/8.jpg)
https://gcpug.jp
GCPUGGoogle Cloud Platform User Group
https://gcpug.jp
Slack: GCPUG Slack entry form (Google Forms)https://docs.google.com/forms/d/e/1FAIpQLScYxAGwuosFFNvH-5yOj-_p-pAKdqZpmM2cgKh9Q8Zu6531Bw/viewform
GCPのユーザコミュニティがあるらしい
![Page 9: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/9.jpg)
https://gcpug.jp
https://gcpug-hiroshima.connpass.com/
中国地方には広島にある!
![Page 10: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/10.jpg)
https://gcpug.jp
https://plus.google.com/communities/115366422273280046817
そして、岡山にもある!
![Page 12: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/12.jpg)
https://gcpug.jp
宣伝 その2
![Page 13: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/13.jpg)
https://gcpug.jp
機械学習による様々な分析-需要予測-分類予測-画像解析-音声解析-言語翻訳-自然言語解析
もっと簡単に使いたいなぁ。。。
機械学習(ML)に興味あるんだけど
![Page 14: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/14.jpg)
https://gcpug.jp
https://www.magellanic-clouds.com
MAGELLAN BLOCKS
![Page 15: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/15.jpg)
https://gcpug.jp
ここから本題
![Page 16: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/16.jpg)
https://gcpug.jp
GCP Managed Database
-RDBのDBAから見た Cloud SQL
-RDBのDBAから見た BigQuery
Agenda
![Page 17: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/17.jpg)
https://gcpug.jp
RDBのDBAから見た
Cloud SQL
![Page 18: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/18.jpg)
https://gcpug.jp
フルマネージドのMySQL および PostgreSQL の
データベース サービス(https://cloud.google.com/sql/?hl=ja より)
PostgreSQLは2017/8/26現在はbeta
Cloud SQL とは
![Page 19: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/19.jpg)
https://gcpug.jp
レプリケーション、管理、バックアップでユーザーの操作が不要になり、デベロッパーは他の作業に時間を充てることができます。
(https://cloud.google.com/sql/?hl=ja より)
ユーザーの操作? 他の作業?
「フルマネージド」とは
![Page 20: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/20.jpg)
https://gcpug.jp
操作が不要な訳ではない。
ALTER文やツール(mysqldump)ではなくブラウザベースの画面(CloudConsole)からレプリケーション・管理・バックアップを実施することが可能。
ユーザの操作が不要、とは
![Page 21: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/21.jpg)
https://gcpug.jp
-スキーマ・テーブル設計/構築/メンテナンス-DBチューニング-セキュリティといった
DBA本来の業務に注力できる!
他の作業、とは
![Page 22: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/22.jpg)
https://gcpug.jp
Instanceあたり●vCPU:32core●RAM:208GB●SSD:10TBまで搭載可能。
https://cloud.google.com/sql/pricing?hl=en#2nd-gen-instance-pricing
Machine Type(H/Wスペック)
![Page 23: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/23.jpg)
https://gcpug.jp
db-n1-highmem16 (vCPU:16core / RAM:104GB)で測定。
パフォーマンスは?(sysbenchで測定)
Qiita: Amazon Auroraと同じbenchmark testをGoogle Cloud SQLでやってみたhttp://qiita.com/kumanoryo/items/7141cbe4fe4d0a6f1de4
![Page 24: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/24.jpg)
https://gcpug.jp
Read Replica参照専用のCloud SQL InstanceいわゆるMySQLの Slave Database
Failover ReplicaホットスタンバイのCloud SQL InstanceMasterDB障害検知・コマンド発行で切り替え
Replication
![Page 25: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/25.jpg)
https://gcpug.jp
Read Replica
Read Replicaを追加するケースアクセス過多によるDB高負荷が発生している
QPSがサービス要件を満たせないCPU(user)の高騰コネクション数過多によるメモリ不足
![Page 26: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/26.jpg)
https://gcpug.jp
Read Replica
ダメなRead Replica追加例Read Replicaを1台だけ追加するのはダメ、絶対!
Masterの負荷は下がったがRead Replicaの負荷が増設前と同等
増設前のMasterと同等の負荷
![Page 27: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/27.jpg)
https://gcpug.jp
Read Replica
理想のRead Replica追加例
readが分散されるようRead Replicaを複数台構築。
Read Replicaが2台の場合1台が応答不能になると前述のダメな状態になるので3台以上で構築する必要がある。
![Page 28: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/28.jpg)
https://gcpug.jp
Failover Replica
Failover Replicaを追加するケースサービスの停止が許されない環境
Master障害時にStandbyしているCloudSQLに切り替える
MasterがSPOF(単一障害点)
![Page 29: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/29.jpg)
https://gcpug.jp
Failover Replica
Failover Replicaの追加例
障害発生時やメンテナンス時にMasterが切り替わってくれる
![Page 30: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/30.jpg)
https://gcpug.jp
昔はAPIでしかFailoverできなかったがgcloudコマンドでfailoverを手動で実行できる。
手動でFailoverさせる方法
$ gcloud sql instances failover INSTANCE
https://cloud.google.com/sdk/gcloud/reference/sql/instances/failover
![Page 31: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/31.jpg)
https://gcpug.jp
注意オンプレミスのMySQLと
ここが違う!
![Page 32: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/32.jpg)
https://gcpug.jp
rootにSUPER権限がないので- sessionのkillができない。
- app用DBアカウントでログインしてkillする運用。
- change master コマンドが実行できない。- 手動オペレーションによるslave設定不可。- Cloud SQLをmaster / 他環境をslaveは可能。- Auroraをmaster / Cloud SQLをslaveにしたい。
rootにSUPER権限がない
![Page 33: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/33.jpg)
https://gcpug.jp
replication中にselect now() from dual
を実行し、応答有無を測定。10回測定したところ- replication直後- 50-80secの間にそれぞれ応答が無い時間帯があることがわかった。
Failover時に応答できないタイミングがある
replication直後20-30sec応答なし 5-10sec応答なし
![Page 34: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/34.jpg)
https://gcpug.jp
RDBのDBAから見た
Big Query
![Page 35: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/35.jpg)
https://gcpug.jp
フルマネージド の
エンタープライズ 向け
アナリティクスデータ ウェアハウスです。
(https://cloud.google.com/bigquery/?hl=ja) より
Big Query とは
![Page 36: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/36.jpg)
https://gcpug.jp
-H/W障害対応作業- オンプレだったら数百台規模のnodeやdiskを管理
- 毎月何かしらH/W交換するのしんどい
-H/W増設作業- オンプレの場合、データが増えてくるとnodeやdiskの増設作業が発生する場合がある
- サーバーラックに設置位置を決めるパズルは勘弁
フルマネージド・サーバーレスであることのメリット
![Page 37: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/37.jpg)
https://gcpug.jp
BigQueryは大量のH/W管理作業から解放される!
データサイズもGB・TBはもちろんPBでもドンとこい!
フルマネージド・サーバーレスであることのメリット
![Page 38: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/38.jpg)
https://gcpug.jp
SQL:2011に準拠しているのでDBAで培ったSQLスキルをBigQueryで使える。
機能(一部)-with句- select句やwhere句でのサブクエリ-相関サブクエリ(EXISTS)-ユーザ定義関数
SQL:2011 に準拠している
![Page 39: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/39.jpg)
https://gcpug.jp
BigQueryはサーバレスなのでH/Wリソースを管理・監視する必要がない。
故に「誰だよ本番マスタDBに重いクエリ流した奴!」っていうDBA警察をやる必要がなくなる。Replication遅延もないしシステムも止まらない。
クソクエリを流してもシステムが落ちることがない
![Page 40: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/40.jpg)
https://gcpug.jp
注意オンプレミス・クラウドの
RDBとここが違う!
![Page 41: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/41.jpg)
https://gcpug.jp
料金体系はクエリとデータ量で課金される
![Page 42: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/42.jpg)
https://gcpug.jp
複雑なクエリだとさらに費用がかかることも
![Page 43: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/43.jpg)
https://gcpug.jp
非正規形にして一つのデータの中に複数行とかBigQueryではよくある。
JOINを避けて料金を抑えるテクニック。RDBに慣れてると非常に違和感を感じる。あと取得用のSQLがパッと出てこない。
正規化をしないという選択
![Page 44: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/44.jpg)
https://gcpug.jp
OLTP用途のDBではないので、チューニングで速度を稼ぐ、という事はやらない。(できない)
同じクエリでも実行速度はバラバラで、連続で実行しても10sec単位で違うこともある。
チューニングで速度をあげる概念がない
![Page 45: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/45.jpg)
https://gcpug.jp
BigQueryのコンセプトがH/Wを並べて力技(フルスキャン)という理由からかIndexがない。
前述のとおり速度チューニングの概念がないのでそういうものだと割り切る。
tableにIndexがない
![Page 46: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/46.jpg)
https://gcpug.jp
https://cloud.google.com/bigquery/docs/reference/standard-sql/data-manipulation-language#quotas
DML文の実行回数制限(quota)がある
![Page 47: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/47.jpg)
https://gcpug.jp
オペミスしてもROLLBACKできないよ!やるときは腹を括って実行しましょう。
transactionがない
![Page 48: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/48.jpg)
https://gcpug.jp
GCPの無料トライアルを開始した時点でBigQueryのサンプルデータも触れる状態になっています。ぜひBigQueryを触ってみて体験してみてください。
無料トライアル ($300/最大12ヶ月有効)https://cloud.google.com/free/?hl=ja
ウェブ UI を使用したクイックスタートhttps://cloud.google.com/bigquery/quickstart-web-ui
BigQueryを触ってみよう
![Page 49: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/49.jpg)
https://gcpug.jp
https://cloud.google.com/bigquery/sample-tables
BigQueryのサンプルテーブル一覧
![Page 50: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/50.jpg)
https://gcpug.jp
サンプル:シェイクスピアの作品から単語と数を格納
![Page 51: RDBのDBAから見た GCP Managed Database](https://reader034.vdocuments.pub/reader034/viewer/2022050614/5a64762f7f8b9afc4d8b4603/html5/thumbnails/51.jpg)
https://gcpug.jp
Thank You!