Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CockroachDBって何 / What is CockroachDB
Search
linyows
March 02, 2020
Programming
1
490
CockroachDBって何 / What is CockroachDB
Mar 2, 2020 Fukuoka.go#15 でお話しした資料です。
linyows
March 02, 2020
Tweet
Share
More Decks by linyows
See All by linyows
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
研究の再現性を高める 仕組みをGoでつくる / Creating a system to improve the reproducibility of research using go
linyows
1
120
奥が深いメールのシステム / The depth of Email system
linyows
3
420
IaCにおけるテスト考察 / Tests in IaC
linyows
2
440
リバースエンジニアリングとGoでSlackの認知負荷を下げる / Reducing cognitive load in Slack with Reverse-engineering and Go
linyows
2
280
透過型SMTPプロキシによる送信メールの可観測性向上 / Improved observability of outgoing emails with transparent smtp proxy
linyows
2
960
プロダクションで使うGo Pluginの利便性とパフォーマンス性 / Simplicity and Performance of Go plugin for Production
linyows
0
510
求められるソフトウェアエンジニア像とキャリア戦略 / Engineers and Career Strategies Required Now
linyows
2
480
CloudflareのCAPTCHAを使って ユーザ体験を下げず不正利用を排除する / Cloudflare's captcha case study that does not degrade ux
linyows
0
360
Other Decks in Programming
See All in Programming
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
EventSourcingの理想と現実
wenas
6
2.3k
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
C++でシェーダを書く
fadis
6
4.1k
cmp.Or に感動した
otakakot
2
140
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
900
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
290
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.5k
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
100
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Being A Developer After 40
akosma
86
590k
Making Projects Easy
brettharned
115
5.9k
4 Signs Your Business is Dying
shpigford
180
21k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Scaling GitHub
holman
458
140k
Transcript
Fukuoka.go#15 with Kagoshima Gophers Tomohisa Oda / Mar 2, 2020
What isCockroachDB
Fukuoka.go#15 with Kagoshima Gophers @linyows blog: tomohisaoda.com affiliation: GMO pepabo,
inc.
Fukuoka.go#15 with Kagoshima Gophers Private Projects ΞϓϦέʔγϣϯ͕ࣗϦϙδτϦ͔Β࠷৽ͷίʔυΛݕ ͯࣗ͠ಈͰσϓϩΠͱσϦόϦʔΛߦ͏πʔϧ MJOVYͷVTFS໊લղܾΛ(JU)VCͷ5FBNϝϯόʔϦϙδτ ϦͷΞΫηεݖݶऀ͔Βߦ͏πʔϧ
Fukuoka.go#15 with Kagoshima Gophers ͓ͼ"CockroachDBίʔυϦʔσΟϯά" "CockroachDBͬͯԿ" ʹͳΓ·ͨ͠ɻ
Fukuoka.go#15 with Kagoshima Gophers CockroachDBͱ
Fukuoka.go#15 with Kagoshima Gophers ๏ ཧతࢄ42-σʔλϕʔε ๏ 3%#ͱ/P42-ͷਐԽܥͰ͋Δ/FX42- ๏ ࣗಈ'BJMPWFSͱࣗಈ3FQBJS
๏ .VMUJ"DUJWFͳՄ༻ੑ ๏ 1PTUHSF42-ޓͰطଘͷυϥΠό͕༻Ͱ͖Δ CockroachDB
Fukuoka.go#15 with Kagoshima Gophers
Fukuoka.go#15 with Kagoshima Gophers Design ਫฏͷεέʔϥϏϦςΟ ๏ ཧతʹແݶʹ૿ͤΔ ๏ ΫΤϦࢄͰ୯ҰΫΤϦΛશମత
εϧʔϓοτ্ ߴ͍ੜଘੑ ๏ ϚγϯࢄɺϥοΫࢄɺཧత ࢄ ๏ ࣗݾम෮ɺࣗݾෛՙόϥϯγϯά ڧ͍Ұ؏ੑ ๏ ߹ҙϕʔεͷϨϓϦέʔγϣϯ ๏ "$*%ηϚϯςΟΫεΛຬͨ͢ ࢄτϥϯβΫγϣϯ
Fukuoka.go#15 with Kagoshima Gophers ๏ 42-*OUFSGBDF͕ͩதࢄ,74UPSF -FWFM%#ͷϑΥʔΫ3PDLT%# ๏ ςʔϒϧΛ3BOHFͱ͍͏.#ҎͷαΠζʹͨ͠୯ҐͰׂ
๏ 3BOHF͕ϨϓϦέʔγϣϯͷ୯ҐͰ/PEFؒͰ4IBSEJOH͢Δ ๏ ϨϓϦέʔγϣϯ3BGUΞϧΰϦζϜͰߦ͍ɺ5SJQMJDBUFEʢ̏ॏʣߦ͑Δ ๏ ϨϓϦΧͷ૯/' ͱ͢Δͱ࠷େ'ݸͷোʹ͑Δ Architecture
Fukuoka.go#15 with Kagoshima Gophers SQL Transactional Distribution Replication Storage Client
Foo : ID = [1, 51] Foo : ID = [51, 103] … Table Foo Index FooIdx Table Bar … Node1 Node2 Node3 Node4 64M Ranges Range Index 64M
Fukuoka.go#15 with Kagoshima Gophers CockroachDB͕ͬͯ͘ΕΔ͜ͱ
Fukuoka.go#15 with Kagoshima Gophers ReplicasͷϦόϥϯγϯάۉҰԽ $MVTUFSʹ/PEFΛ৽͘͠Ճ͢Δ $PDLSPBDI%#3BOHFΛஔ͢Δ $PDLSPBDI%#$MVTUFSΛۉʹ͢Δ
Fukuoka.go#15 with Kagoshima Gophers ReplicasͷϦόϥϯγϯάम෮ ো͕ൃੜ͠/PEFΛফࣦ͢Δ $PDLSPBDI%#3FQMJDBͷܽམΛೝࣝͯ͠ "DUJWF/PEF্ʹϨϓϦΧΛஔ͖͑Δ ো͕Ұ࣌తͰ/PEF͕෮ؼͨ͠Β -FBTIPMEFSͱݺΕΔ3BGU-FBEFS͕
ϨϓϦΧΛΩϟονΞοϓ͢Δ
Fukuoka.go#15 with Kagoshima Gophers ๏ 51$$ϕϯνϚʔΫʹ͓͍ͯ"NB[PO"VSPSB ͱൺֱ͢Δͱഒͷεϧʔϓοτ͕͋Δ ๏ ͜ͷεϧʔϓοτ51$$ϥϯΩϯάͰ൪ ʹେ͖͍
๏ ,7 SFBE XSJUF Ͱ/PEFͷ૿Ճʹ ΑͬͯτϥϯβΫγϣϯͷॲཧೳྗ͕ઢܗʹ ্͍ͯ͘͜͠ͱ͕Θ͔͍ͬͯΔ ๏ $PDLSPBDI%#ʹཧ্ͷεέʔϦϯά੍ ݶͳ͍ͱͷ͜ͱ Performance
Fukuoka.go#15 with Kagoshima Gophers CockroachDBͷ࣮
Fukuoka.go#15 with Kagoshima Gophers ๏ (P Ҏ্ඇਪ ๏
$ DPNQJMFS͕ඞཁ 3PDLT%#$SZQUP ɺ,FSCFSPTɺ4OBQQZͳͲʹґଘ ๏ (Pͷσ ΟϨΫτϦߏࢸͬͯී௨QLHʹ࣮͕͋Δ ๏ ֎෦QLHఔͳͷͰنతʹґଘ͕গͳ͍Α͏ʹݟ͑Δ https://github.com/cockroachdb/cockroach ࣮ʹ͍ͭͯ $ tree pkg | grep .go | grep -v test.go | wc -l 2405 // ͜ͷϑΝΠϧͰίʔυϦʔσΟϯά͢Δؾ͕ͳ͘ͳͬͨ $ grep 'name =' Gopkg.toml | grep -v golang | grep -v cockroach | wc -l 20
Fukuoka.go#15 with Kagoshima Gophers CockroachDBΛ͞ΘͬͯΈΔ
Fukuoka.go#15 with Kagoshima Gophers ๏ IFMNͰ$PDLSPBDI%#ΫϥελΛ࡞ 4UBUFGVM4FUͷͭͷ1PE͕ىಈ helm install
my-release --values my-values.yaml stable/cockroachdb kubectl get csr ๏ $PDLSPBDI%#ϊʔυͷূ໌ॻʹॺ໊͢ΔͨΊͷ$43Λঝೝ kubectl certificate approve default.node.my-release-cockroachdb-0 kubectl certificate approve default.client.root kubectl get pv ๏ #VJMUJO$MJFOUͷ४උ kubectl create -f client-secure.yaml kubectl exec -it cockroachdb-client-secure -- ./cockroach sql --certs-dir=/cockroach-certs —host=my-release-cockroachdb-public https://www.cockroachlabs.com/docs/stable/orchestrate-a-local-cluster-with-kubernetes.html KubernetesΛͬͯDemo: ४උ
Fukuoka.go#15 with Kagoshima Gophers ๏ 42-ͷ࣮ߦ CREATE DATABASE bank; CREATE
TABLE bank.accounts (id INT PRIMARY KEY, balance DECIMAL); INSERT INTO bank.accounts VALUES (1, 1000.50); SELECT * FROM bank.accounts; CREATE USER roach WITH PASSWORD 'Q7gc8rEdS'; INSERT INTO system.role_members (role, member, "isAdmin") VALUES ('admin', 'roach', true); ๏ ίϯιʔϧϩάΠϯ kubectl port-forward my-release-cockroachdb-0 8080 ๏ /PEF'BJMPWFSɺ/PEFͷՃɺআ kubectl delete pod my-release-cockroachdb-2 helm upgrade my-release stable/cockroachdb --set statefulset.replicas=4 —reuse-values kubectl certificate approve default.node.my-release-cockroachdb-3 kubectl exec -it cockroachdb-client-secure -- ./cockroach node status --certs-dir=/cockroach-certs —host=my-release-cockroachdb-public kubectl exec -it cockroachdb-client-secure -- ./cockroach node decommission 2 --certs-dir=/cockroach-certs —host=my-release-cockroachdb-public helm upgrade my-release stable/cockroachdb --set statefulset.replicas=3 --reuse-values https://www.cockroachlabs.com/docs/stable/orchestrate-a-local-cluster-with-kubernetes.html KubernetesΛͬͯDemo: ૢ࡞
Fukuoka.go#15 with Kagoshima Gophers add node to cluster delete a
pod
Fukuoka.go#15 with Kagoshima Gophers ๏ IUUQTHJUIVCDPNDPDLSPBDIECDPDLSPBDICMPCNBTUFSEPDTEFTJHONE ๏ IUUQTXXXDPDLSPBDIMBCTDPNEPDTTUBCMFBSDIJUFDUVSFPWFSWJFXIUNM ๏ IUUQTXXXDPDLSPBDIMBCTDPNEPDTTUBCMFDPDLSPBDIECJODPNQBSJTPOIUNM
๏ IUUQTXXXDPDLSPBDIMBCTDPNEPDTTUBCMFNVMUJBDUJWFBWBJMBCJMJUZIUNM ๏ IUUQTXXXDPDLSPBDIMBCTDPNCMPHMJNJUTPGUIFDBQUIFPSFN ๏ IUUQTXXXJOGPRDPNQSFTFOUBUJPOTDPDLSPBDIECEJTUSJCVUFETRM ๏ IUUQTXXXDPDLSPBDIMBCTDPNCMPHUQDDL ๏ IUUQTXXXDPDLSPBDIMBCTDPNEPDTTUBCMFPSDIFTUSBUFBMPDBMDMVTUFSXJUILVCFSOFUFTIUNM References
Fukuoka.go#15 with Kagoshima Gophers Thank youaʕ⊙౪⚆ʔ