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
イベント駆動で成長して委員会
happymana
1
320
Amazon Qを使ってIaCを触ろう!
maruto
0
400
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
100
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
200
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Quine, Polyglot, 良いコード
qnighy
4
640
ヤプリ新卒SREの オンボーディング
masaki12
0
130
as(型アサーション)を書く前にできること
marokanatani
9
2.6k
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
cmp.Or に感動した
otakakot
1
120
Featured
See All Featured
Designing for Performance
lara
604
68k
Visualization
eitanlees
145
15k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Building an army of robots
kneath
302
43k
It's Worth the Effort
3n
183
27k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Thoughts on Productivity
jonyablonski
67
4.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
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ʕ⊙౪⚆ʔ