CockroachDBって何 / What is CockroachDB

5d769d109697012317c09c6a27a6a4bf?s=47 linyows
March 02, 2020

CockroachDBって何 / What is CockroachDB

Mar 2, 2020 Fukuoka.go#15 でお話しした資料です。

5d769d109697012317c09c6a27a6a4bf?s=128

linyows

March 02, 2020
Tweet

Transcript

  1. 8.

    Fukuoka.go#15 with Kagoshima Gophers Design ਫฏͷεέʔϥϏϦςΟ ๏ ࿦ཧతʹ͸ແݶʹ૿΍ͤΔ ๏ ΫΤϦ෼ࢄͰ୯ҰΫΤϦΛશମత

    εϧʔϓοτ޲্ ߴ͍ੜଘੑ ๏ Ϛγϯ෼ࢄɺϥοΫ෼ࢄɺ஍ཧత ෼ࢄ ๏ ࣗݾम෮ɺࣗݾෛՙόϥϯγϯά ڧ͍Ұ؏ੑ ๏ ߹ҙϕʔεͷϨϓϦέʔγϣϯ ๏ "$*%ηϚϯςΟΫεΛຬͨ͢෼ ࢄτϥϯβΫγϣϯ
  2. 9.

    Fukuoka.go#15 with Kagoshima Gophers ๏ 42-*OUFSGBDF͕ͩத਎͸෼ࢄ,74UPSF -FWFM%#ͷϑΥʔΫ3PDLT%#  ๏ ςʔϒϧΛ3BOHFͱ͍͏.#Ҏ಺ͷαΠζʹͨ͠୯ҐͰ෼ׂ

    ๏ 3BOHF͕ϨϓϦέʔγϣϯͷ୯ҐͰ/PEFؒͰ4IBSEJOH͢Δ ๏ ϨϓϦέʔγϣϯ͸3BGUΞϧΰϦζϜͰߦ͍ɺ5SJQMJDBUFEʢ̏ॏʣߦ͑Δ ๏ ϨϓϦΧͷ૯਺/' ͱ͢Δͱ࠷େ'ݸͷো֐ʹ଱͑Δ Architecture
  3. 10.

    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
  4. 14.

    Fukuoka.go#15 with Kagoshima Gophers ๏ 51$$ϕϯνϚʔΫʹ͓͍ͯ"NB[PO"VSPSB ͱൺֱ͢Δͱഒͷεϧʔϓοτ͕͋Δ ๏ ͜ͷεϧʔϓοτ͸51$$ϥϯΩϯάͰ൪ ໨ʹେ͖͍

    ๏ ,7 SFBE XSJUF Ͱ/PEF਺ͷ૿Ճʹ ΑͬͯτϥϯβΫγϣϯͷॲཧೳྗ͕ઢܗʹ ޲্͍ͯ͘͜͠ͱ͕Θ͔͍ͬͯΔ ๏ $PDLSPBDI%#ʹ͸ཧ࿦্ͷεέʔϦϯά੍ ݶ͸ͳ͍ͱͷ͜ͱ Performance
  5. 16.

    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
  6. 18.

    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: ४උ
  7. 19.

    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: ૢ࡞
  8. 21.

    Fukuoka.go#15 with Kagoshima Gophers ๏ IUUQTHJUIVCDPNDPDLSPBDIECDPDLSPBDICMPCNBTUFSEPDTEFTJHONE ๏ IUUQTXXXDPDLSPBDIMBCTDPNEPDTTUBCMFBSDIJUFDUVSFPWFSWJFXIUNM ๏ IUUQTXXXDPDLSPBDIMBCTDPNEPDTTUBCMFDPDLSPBDIECJODPNQBSJTPOIUNM

    ๏ IUUQTXXXDPDLSPBDIMBCTDPNEPDTTUBCMFNVMUJBDUJWFBWBJMBCJMJUZIUNM ๏ IUUQTXXXDPDLSPBDIMBCTDPNCMPHMJNJUTPGUIFDBQUIFPSFN ๏ IUUQTXXXJOGPRDPNQSFTFOUBUJPOTDPDLSPBDIECEJTUSJCVUFETRM ๏ IUUQTXXXDPDLSPBDIMBCTDPNCMPHUQDDL ๏ IUUQTXXXDPDLSPBDIMBCTDPNEPDTTUBCMFPSDIFTUSBUFBMPDBMDMVTUFSXJUILVCFSOFUFTIUNM References