Skip to main content
GeekCity

GeekCity

diff -r live/ evil/

blog
source code for this blog
Commands
Commands
a set of commands for shell, java, git and so on
Qemu
Qemu
QEMU is a generic and open source machine & userspace emulator and virtualizer
Linux
Linux
Linux is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released by Linus Torvalds
Docker
Docker
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers
Kubernetes
Kubernetes
Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications
Data-Lake
Data-Lake
A data lake is a centralized repository that allows you to store all your structured and unstructured data at any scale
about me
about me
backup and restore

reference

  • https://docs.pingcap.com/zh/tidb-in-kubernetes/stable/backup-restore-cr
  • https://github.com/pingcap/tidb-operator/blob/master/pkg/apis/pingcap/v1alpha1/types.go#L1912
  • https://asktug.com/t/topic/1042360

introduction

prepare

  1. optional: only for local storage
  2. requirements
    • for backup/restore by br, local:// protocol requires a local path in tikv to store the backup/restore files
    • therefore, we need to create a pvc to mount the local path in tikv
  3. prepare backup.pvc.yaml
    • apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: tidb-cluster-backup-pvc
        namespace: tidb-cluster
      spec:
        accessModes:
          - ReadWriteMany
        resources:
          requests:
            storage: 20Gi
        storageClassName: 
      
      
    • apply to the cluster
      • kubectl -n tidb-cluster apply -f backup.pvc.yaml
        
  4. patch the tidb cluster
    • kubectl -n tidb-cluster patch tidbcluster basic --type=merge -p '{"spec":{"tikv":{"additionalVolumes":[{"name":"backup","persistentVolumeClaim":{"claimName":"tidb-cluster-backup-pvc"}}],"additionalVolumeMounts":[{"name":"backup","mountPath":"/backup"}]}}}'
      
    • check and waiting for the cluster status to be ready
      • kubectl -n tidb-cluster get tidbcluster basic -w
        
  5. perpare default service account tidb-backup-manager
    • apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: tidb-backup-manager
        namespace: tidb-cluster
      
      ---
      apiVersion: rbac.authorization.k8s.io/v1
      kind: Role
      metadata:
        name: tidb-backup-manager-role
        namespace: tidb-cluster
      rules:
      - apiGroups: ["pingcap.com"]
        resources: 
          - backups
          - restores
        verbs:
          - list
          - get
          - update
          - watch
          - patch
          - create
          - delete
      
      ---
      apiVersion: rbac.authorization.k8s.io/v1
      kind: RoleBinding
      metadata:
        name: tidb-backup-manager-rolebinding
        namespace: tidb-cluster
      subjects:
      - kind: ServiceAccount
        name: tidb-backup-manager
        namespace: tidb-cluster
      roleRef:
        kind: Role
        name: tidb-backup-manager-role
        apiGroup: rbac.authorization.k8s.io
      
      

ben.wangzAbout 1 min
intro

Wang Zhi

  • email: ben.wangz@foxmail.com
  • blog: https://blog.geekcity.tech

Summary

  • experienced Java developer with 8+ years of expertise in designing and implementing scalable data processing platforms.
  • proficient in Apache Flink, Kubernetes, and handling large volumes of data.
  • proven ability to lead teams and deliver high-performance systems.
  • achieved developing data processing platforms for various companies, including Alibaba Group, ZhejiangLab and tianrang-inc.

ben.wangzAbout 3 min
commands

what

  • record some useful commands

ben.wangzLess than 1 minutecommandslinuxshelltool
git

init global config

git config --global user.name "ben.wangz"
git config --global user.email ben.wangz@foxmail.com
git config --global pager.branch false
git config --global pull.ff only
git --no-pager diff

ben.wangzLess than 1 minute
java

show gc info

jstat -gcutil $pid 1000 100

ben.wangzLess than 1 minute
k8s

completion for bash

source<(kubectl completionbash)

port forwarding


ben.wangzLess than 1 minute
mac

install rosetta for apple m1 chip

/usr/sbin/softwareupdate --install-rosetta --agree-to-license

mac chrome access https with self-signed certificate

just type thisisunsafe after open the website


ben.wangzLess than 1 minute
mysql

show transaction info

select 
    trx_id, 
    trx_started, 
    trx_wait_started, 
    trx_mysql_thread_id, 
    trx_query, 
    trx_operation_state, 
    trx_tables_locked 
from information_schema.INNODB_TRX;

ben.wangzLess than 1 minute