20 Nisan 2022 Çarşamba

PlanetScale Vitess Operator - operator.yaml

Giriş
Normalde bu dosyayı değiştirmek gerekmiyor. 

kubectl get vtk komutu
PlanetScale Vitess Operator bilgilerini görmek için şöyle yaparız. Burada hata şöyle
"Failed to determine status of the condition."
Prune Keyspaces: true Prune Shard Cells: true Prune Shards: true Prune Srv Keyspaces: true Prune Tablets: true Register Cells: true Register Cells Aliases: true Turndown Policy: Immediate Update Strategy: Type: Immediate Zone Map: az1: Status: Conditions: Last Transition Time: 2022-09-06T08:08:22Z Message: Some tablet Pods for the serving partitioning are not Ready. Reason: TabletsNotReady Status: False Type: Ready Last Transition Time: 2022-09-06T08:08:24Z Message: Failed to determine status of the condition. Reason: ReconcileFailed Status: Unknown Type: ReshardingInSync Last Transition Time: 2022-09-06T08:08:24Z Message: Failed to determine status of the condition. Reason: ReconcileFailed Status: Unknown Type: ReshardingActive Idle: False Observed Generation: 1 Partitionings: Desired Shards: 1 Desired Tablets: 3 Serving Writes: True Shard Names: - Tablets: 3 Shards: -: Cells: az1 Desired Tablets: 3 Has Master: False Serving Writes: True Tablets: 3 Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Created 36m vitesskeyspace-controller created VitessShard adv-vitess-cluster-adv-x-x-6510f0e0 Normal Updated 36m vitesskeyspace-controller updated VitessShard adv-vitess-cluster-adv-x-x-6510f0e0 Warning TopoConnectFailed 35m (x23 over 36m) vitesskeyspace-controller failed to connect to global lockserver: context deadline exceeded Warning ListAllWorkflowsFailed 67s (x428 over 35m) vitesskeyspace-controller failed to list all workflows: no primary found for shard ADV/-
Örnek
Şöyle yaparız. Burada hata şöyle. 
"No active resharding workflow found"
$ kubectl describe vtk -n rlwy-04
Name:         adv-vitess-cluster-adv-c55923a7
Namespace:    rlwy-04
Labels:       planetscale.com/cluster=adv-vitess-cluster
              planetscale.com/keyspace=ADV
Annotations:  <none>
API Version:  planetscale.com/v2
Kind:         VitessKeyspace
Metadata:
  Creation Timestamp:  2022-08-26T08:13:04Z
  Generation:          1
  Managed Fields:
    API Version:  planetscale.com/v2
    Fields Type:  FieldsV1
    fieldsV1:
      ...
    Manager:      vitess-operator
    Operation:    Update
    Time:         2022-08-26T08:13:04Z
    API Version:  planetscale.com/v2
    Fields Type:  FieldsV1
    fieldsV1:
      ...
    Manager:      vitess-operator
    Operation:    Update
    Subresource:  status
    Time:         2022-09-25T23:41:04Z
  Owner References:
    API Version:           planetscale.com/v2
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  VitessCluster
    Name:                  adv-vitess-cluster
    UID:                   9fc67fc7-aad0-4f11-98eb-c1e0c3e2f986
  Resource Version:        9504323
  UID:                     95073cf0-5164-419f-90f9-e8799f0d1807
Spec:
  Global Lockserver:
    Address:         adv-vitess-cluster-etcd-07a83994-client.rlwy-04.svc:2379
    Implementation:  etcd2
    Root Path:       /vitess/adv-vitess-cluster/global
  Image Pull Policies:
  Images:
    Mysqld:
      mysql80Compatible:  gcr.io/product-spanner/oce/vitess/lite:v12.0.3-mysql80
    Mysqld Exporter:      gcr.io/product-spanner/oce/prom/mysqld-exporter:v0.11.0
    Vtbackup:             gcr.io/product-spanner/oce/vitess/lite:v12.0.3-mysql80
    Vtorc:                vitess/lite:v12.0.0
    Vttablet:             gcr.io/product-spanner/oce/vitess/lite:v12.0.3-mysql80
  Name:                   ADV
  Partitionings:
    Equal:
      Parts:  1
      Shard Template:
        Database Init Script Secret:
          Key:   init_db.sql
          Name:  adv-vitess-cluster-config
        Replication:
          Initialize Backup:         true
          Initialize Master:         true
          Recover Restarted Master:  true
        Tablet Pools:
          Cell:  az1
          Mysqld:
            Config Overrides:  [mysqld]
lower_case_table_names = 1

            Resources:
              Limits:
                Memory:  1256Mi
              Requests:
                Cpu:     200m
                Memory:  256Mi
          Replicas:      2
          Type:          replica
          Vttablet:
            Extra Flags:
              db_charset:  utf8mb4
            Lifecycle:
            Resources:
              Limits:
                Memory:  256Mi
              Requests:
                Cpu:     200m
                Memory:  256Mi
          Cell:          az1
          Data Volume Claim Template:
            Access Modes:
              ReadWriteOnce
            Resources:
              Requests:
                Storage:         1Gi
            Storage Class Name:  standard
          Mysqld:
            Config Overrides:  [mysqld]
lower_case_table_names = 1

            Resources:
              Limits:
                Memory:  1256Mi
              Requests:
                Cpu:     200m
                Memory:  256Mi
          Replicas:      1
          Type:          rdonly
          Vttablet:
            Extra Flags:
              db_charset:  utf8mb4
            Lifecycle:
            Resources:
              Limits:
                Memory:  256Mi
              Requests:
                Cpu:     200m
                Memory:  256Mi
  Topology Reconciliation:
    Prune Cells:             true
    Prune Keyspaces:         true
    Prune Shard Cells:       true
    Prune Shards:            true
    Prune Srv Keyspaces:     true
    Prune Tablets:           true
    Register Cells:          true
    Register Cells Aliases:  true
  Turndown Policy:           Immediate
  Update Strategy:
    External:
    Type:  External
  Zone Map:
    az1:
Status:
  Conditions:
    Last Transition Time:  2022-09-07T01:38:10Z
    Message:               Some tablet Pods for the serving partitioning are not Ready.
    Reason:                TabletsNotReady
    Status:                False
    Type:                  Ready
    Last Transition Time:  2022-09-25T23:41:03Z
    Message:               No active resharding workflow found.
    Reason:                NoActiveReshardingWorkflow
    Status:                False
    Type:                  ReshardingActive
    Last Transition Time:  2022-09-25T23:41:03Z
    Message:               No active resharding workflow found.
    Reason:                NoActiveReshardingWorkflow
    Status:                False
    Type:                  ReshardingInSync
  Idle:                    False
  Observed Generation:     1
  Partitionings:
    Desired Shards:   1
    Desired Tablets:  3
    Ready Tablets:    1
    Serving Writes:   True
    Shard Names:
      -
    Tablets:  3
  Shards:
    -:
      Cells:
        az1
      Desired Tablets:  3
      Has Master:       True
      Ready Tablets:    1
      Serving Writes:   True
      Tablets:          3
Events:                 <none>

Resource Tipleri
Bu dosyada 3 tane önemli Resource var. Bunlar şöyle
Resource Types
Custom Resource İsimleri
operator.yaml dosyası oldukça büyük. Yaratılan Custom Resource isimleri şöyle
etcdlockservers.planetscale.com
vitessbackups.planetscale.com
vitessbackupstorages.planetscale.com
vitesscells.planetscale.com
vitessclusters.planetscale.com
vitesskeyspaces.planetscale.com
vitessshards.planetscale.com
Deployment
En sondaki deployment kısmı önemli. Burası şöyle. Kullanılan image ismi planetscale/vitess-operator:v2.6.0
apiVersion: apps/v1
kind: Deployment
metadata: {name: vitess-operator}
spec:
  replicas: 1
  selector:
    matchLabels: {app: vitess-operator}
  template:
    metadata:
      labels: {app: vitess-operator}
    spec:
      containers:
      - args: [--logtostderr, -v=4]
        command: [vitess-operator]
        env:
        - {name: WATCH_NAMESPACE, value: ''}
        - name: POD_NAME
          valueFrom:
            fieldRef: {fieldPath: metadata.name}
        - name: PS_OPERATOR_POD_NAMESPACE
          valueFrom:
            fieldRef: {fieldPath: metadata.namespace}
        - name: PS_OPERATOR_POD_NAME
          valueFrom:
            fieldRef: {fieldPath: metadata.name}
        - {name: OPERATOR_NAME, value: vitess-operator}
        image: planetscale/vitess-operator:v2.6.0
        name: vitess-operator
        resources:
          limits: {memory: 128Mi}
          requests: {cpu: 100m, memory: 128Mi}
      priorityClassName: vitess-operator-control-plane
      serviceAccountName: vitess-operator

19 Nisan 2022 Salı

Vitess Cross-Shard Join

Örnek
Şu hata veriyor. Sebebi ise WHERE kısmında OR yapılması
SELECT *
 FROM INFORMATION_SCHEMA.TABLES tables
 LEFT JOIN GSRSYS_TABLE_DICT td ON tables.table_name = td.name
 WHERE (tables.table_name LIKE 'GSR%' OR tables.table_name LIKE 'RW50%') AND tables.table_type = 'BASE TABLE'
 ORDER BY td.display_name
Şöyle yaparız
SELECT *
 FROM INFORMATION_SCHEMA.TABLES tables
 LEFT JOIN GSRSYS_TABLE_DICT td ON tables.table_name = td.name
 WHERE tables.table_name LIKE 'GSR%' AND tables.table_type = 'BASE TABLE'
 ORDER BY td.display_name

CREATE EVENT - Scheduled Task İçindir

Örnek Şöyle yaparız CREATE EVENT myevent     ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR     DO       UPDATE myschema.mytable SET myc...