主頁 >  其他 > k8s實戰案例之基于StatefulSet控制器運行MySQL一主多從

k8s實戰案例之基于StatefulSet控制器運行MySQL一主多從

2023-06-16 08:00:11 其他

1、前言

Pod調度運?時,如果應?不需要任何穩定的標示、有序的部署、洗掉和擴展,則應該使??組?狀態副本的控制器來部署應?,例如 Deployment 或 ReplicaSet更適合?狀態服務需求,?StatefulSet適合管理所有有狀態的服務,?如MySQL、MongoDB集群等,

2、StatefulSet控制器運行MySQL一主多從架構圖

StatefulSet本質上是Deployment的?種變體,在v1.9版本中已成為GA版本,它為了解決有狀態服務的問題,它所管理的Pod擁有固定的Pod名稱,啟停順序,在StatefulSet中,Pod名字稱為?絡標識(hostname),還必須要?到共享存盤,
在Deployment中,與之對應的服務是service,?在StatefulSet中與之對應的headless service,headless service,即?頭服務,與service的區別就是它沒有Cluster IP,決議它的名稱時將回傳該Headless Service對應的全部Pod的Endpoint串列,

2.1、StatefulSet控制器特點

  • 給每個pod分配固定且唯?的?絡識別符號
  • 給每個pod分配固定且持久化的外部存盤
  • 對pod進?有序的部署和擴展
  • 對pod進有序的洗掉和終?
  • 對pod進有序的?動滾動更新

2.2、StatefulSet的組成部分

  • Headless Service:?來定義Pod?絡標識( DNS domain),指的是短的service(丟失了domainname),
  • StatefulSet:定義具體應?,有多少個Pod副本,并為每個Pod定義了?個域名,
  • volumeClaimTemplates: 存盤卷申請模板,創建PVC,指定pvc名稱??,將?動創建pvc,且pvc必須由存盤類供應,

3、在k8s上部署mysql一主多從

3.1、基礎鏡像準備

3.1.1、準備mysql鏡像

下載鏡像

root@k8s-master01:~# nerdctl pull mysql:5.7.36

修改鏡像tag為本地harbor地址

root@k8s-master01:~# nerdctl tag mysql:5.7.36 harbor.ik8s.cc/magedu/mysql:5.7.36

上傳鏡像至本地harbor

root@k8s-master01:~# nerdctl push harbor.ik8s.cc/magedu/mysql:5.7.36

3.1.2、準備xtrabackup鏡像

下載鏡像

root@k8s-master01:~# nerdctl pull registry.cn-hangzhou.aliyuncs.com/hxpdocker/xtrabackup:1.0

修改鏡像tag為本地harbor地址

root@k8s-master01:~# nerdctl tag registry.cn-hangzhou.aliyuncs.com/hxpdocker/xtrabackup:1.0 harbor.ik8s.cc/magedu/xtrabackup:1.0

上傳鏡像至本地harbor

root@k8s-master01:~# nerdctl push harbor.ik8s.cc/magedu/xtrabackup:1.0

3.1.3、驗證鏡像是否上傳至harbor?

3.2、準備pv

3.2.1、在nfs服務器上創建資料存盤目錄

root@harbor:~# mkdir -pv /data/k8sdata/magedu/mysql-datadir-{1..5}
mkdir: created directory '/data/k8sdata/magedu/mysql-datadir-1'
mkdir: created directory '/data/k8sdata/magedu/mysql-datadir-2'
mkdir: created directory '/data/k8sdata/magedu/mysql-datadir-3'
mkdir: created directory '/data/k8sdata/magedu/mysql-datadir-4'
mkdir: created directory '/data/k8sdata/magedu/mysql-datadir-5'
root@harbor:~# 

3.2.2、在nfs服務器上匯出資料存盤目錄

root@harbor:/data/k8sdata/magedu# cat /etc/exports 
# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/data/k8sdata/kuboard *(rw,no_root_squash)
/data/volumes *(rw,no_root_squash)
/pod-vol *(rw,no_root_squash)
/data/k8sdata/myserver *(rw,no_root_squash)
/data/k8sdata/mysite *(rw,no_root_squash)

/data/k8sdata/magedu/images *(rw,no_root_squash)
/data/k8sdata/magedu/static *(rw,no_root_squash)


/data/k8sdata/magedu/zookeeper-datadir-1 *(rw,no_root_squash)
/data/k8sdata/magedu/zookeeper-datadir-2 *(rw,no_root_squash)
/data/k8sdata/magedu/zookeeper-datadir-3 *(rw,no_root_squash)


/data/k8sdata/magedu/redis-datadir-1 *(rw,no_root_squash) 

/data/k8sdata/magedu/redis0 *(rw,no_root_squash)
/data/k8sdata/magedu/redis1 *(rw,no_root_squash)
/data/k8sdata/magedu/redis2 *(rw,no_root_squash)
/data/k8sdata/magedu/redis3 *(rw,no_root_squash)
/data/k8sdata/magedu/redis4 *(rw,no_root_squash)
/data/k8sdata/magedu/redis5 *(rw,no_root_squash)



/data/k8sdata/magedu/mysql-datadir-1 *(rw,no_root_squash)
/data/k8sdata/magedu/mysql-datadir-2 *(rw,no_root_squash)
/data/k8sdata/magedu/mysql-datadir-3 *(rw,no_root_squash)
/data/k8sdata/magedu/mysql-datadir-4 *(rw,no_root_squash)
/data/k8sdata/magedu/mysql-datadir-5 *(rw,no_root_squash)
root@harbor:/data/k8sdata/magedu# exportfs -av
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/kuboard".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/volumes".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [3]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/pod-vol".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [4]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/myserver".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [5]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/mysite".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [7]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/images".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [8]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/static".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [11]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/zookeeper-datadir-1".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [12]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/zookeeper-datadir-2".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [13]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/zookeeper-datadir-3".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [16]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/redis-datadir-1".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [18]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/redis0".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [19]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/redis1".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [20]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/redis2".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [21]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/redis3".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [22]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/redis4".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [23]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/redis5".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [27]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/mysql-datadir-1".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [28]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/mysql-datadir-2".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [29]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/mysql-datadir-3".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [30]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/mysql-datadir-4".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exportfs: /etc/exports [31]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/data/k8sdata/magedu/mysql-datadir-5".
  Assuming default behaviour ('no_subtree_check').
  NOTE: this default has changed since nfs-utils version 1.0.x

exporting *:/data/k8sdata/magedu/mysql-datadir-5
exporting *:/data/k8sdata/magedu/mysql-datadir-4
exporting *:/data/k8sdata/magedu/mysql-datadir-3
exporting *:/data/k8sdata/magedu/mysql-datadir-2
exporting *:/data/k8sdata/magedu/mysql-datadir-1
exporting *:/data/k8sdata/magedu/redis5
exporting *:/data/k8sdata/magedu/redis4
exporting *:/data/k8sdata/magedu/redis3
exporting *:/data/k8sdata/magedu/redis2
exporting *:/data/k8sdata/magedu/redis1
exporting *:/data/k8sdata/magedu/redis0
exporting *:/data/k8sdata/magedu/redis-datadir-1
exporting *:/data/k8sdata/magedu/zookeeper-datadir-3
exporting *:/data/k8sdata/magedu/zookeeper-datadir-2
exporting *:/data/k8sdata/magedu/zookeeper-datadir-1
exporting *:/data/k8sdata/magedu/static
exporting *:/data/k8sdata/magedu/images
exporting *:/data/k8sdata/mysite
exporting *:/data/k8sdata/myserver
exporting *:/pod-vol
exporting *:/data/volumes
exporting *:/data/k8sdata/kuboard
root@harbor:/data/k8sdata/magedu# 

3.2.2、創建pv

創建pv配置清單

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-datadir-1
  namespace: magedu
spec:
  capacity:
    storage: 50Gi
  accessModes:
    - ReadWriteOnce
  nfs:
    path: /data/k8sdata/magedu/mysql-datadir-1 
    server: 192.168.0.42
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-datadir-2
  namespace: magedu
spec:
  capacity:
    storage: 50Gi
  accessModes:
    - ReadWriteOnce
  nfs:
    path: /data/k8sdata/magedu/mysql-datadir-2
    server: 192.168.0.42
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-datadir-3
  namespace: magedu
spec:
  capacity:
    storage: 50Gi
  accessModes:
    - ReadWriteOnce
  nfs:
    path: /data/k8sdata/magedu/mysql-datadir-3
    server: 192.168.0.42
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-datadir-4
  namespace: magedu
spec:
  capacity:
    storage: 50Gi
  accessModes:
    - ReadWriteOnce
  nfs:
    path: /data/k8sdata/magedu/mysql-datadir-4
    server: 192.168.0.42
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-datadir-5
  namespace: magedu
spec:
  capacity:
    storage: 50Gi
  accessModes:
    - ReadWriteOnce
  nfs:
    path: /data/k8sdata/magedu/mysql-datadir-5
    server: 192.168.0.42

創建pv

root@k8s-master01:~/k8s-data/yaml/magedu/mysql# kubectl apply -f pv/mysql-persistentvolume.yaml
persistentvolume/mysql-datadir-1 created
persistentvolume/mysql-datadir-2 created
persistentvolume/mysql-datadir-3 created
persistentvolume/mysql-datadir-4 created
persistentvolume/mysql-datadir-5 created
root@k8s-master01:~/k8s-data/yaml/magedu/mysql#

3.2.3、驗證pv

root@k8s-master01:~/k8s-data/yaml/magedu/mysql# kubectl get pv
NAME                     CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                            STORAGECLASS   REASON   AGE
mysql-datadir-1          50Gi       RWO            Retain           Available                                                            5s
mysql-datadir-2          50Gi       RWO            Retain           Available                                                            5s
mysql-datadir-3          50Gi       RWO            Retain           Available                                                            5s
mysql-datadir-4          50Gi       RWO            Retain           Available                                                            5s
mysql-datadir-5          50Gi       RWO            Retain           Available                                                            5s
redis-cluster-pv0        5Gi        RWO            Retain           Bound       magedu/data-redis-1                                      8d
redis-cluster-pv1        5Gi        RWO            Retain           Bound       magedu/data-redis-3                                      8d
redis-cluster-pv2        5Gi        RWO            Retain           Bound       magedu/data-redis-4                                      8d
redis-cluster-pv3        5Gi        RWO            Retain           Bound       magedu/data-redis-0                                      8d
redis-cluster-pv4        5Gi        RWO            Retain           Bound       magedu/data-redis-5                                      8d
redis-cluster-pv5        5Gi        RWO            Retain           Bound       magedu/data-redis-2                                      8d
redis-datadir-pv-1       10Gi       RWO            Retain           Bound       magedu/redis-datadir-pvc-1                               9d
zookeeper-datadir-pv-1   20Gi       RWO            Retain           Bound       magedu/zookeeper-datadir-pvc-1                           10d
zookeeper-datadir-pv-2   20Gi       RWO            Retain           Bound       magedu/zookeeper-datadir-pvc-2                           10d
zookeeper-datadir-pv-3   20Gi       RWO            Retain           Bound       magedu/zookeeper-datadir-pvc-3                           10d
root@k8s-master01:~/k8s-data/yaml/magedu/mysql# 

3.3、運行mysql服務

MYSQL CONFIGMAP配置清單

apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql
  namespace: magedu
  labels:
    app: mysql
data:
  master.cnf: |
    # Apply this config only on the master.
    [mysqld]
    log-bin
    log_bin_trust_function_creators=1
    lower_case_table_names=1
  slave.cnf: |
    # Apply this config only on slaves.
    [mysqld]
    super-read-only
    log_bin_trust_function_creators=1

MYSQL POD配置清單

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mysql
  namespace: magedu
spec:
  selector:
    matchLabels:
      app: mysql
  serviceName: mysql
  replicas: 2
  template:
    metadata:
      labels:
        app: mysql
    spec:
      initContainers:
      - name: init-mysql #初始化容器1、基于當前pod name匹配角色是master還是slave,并動態生成相對應的組態檔
        image: harbor.ik8s.cc/magedu/mysql:5.7.36
        command:
        - bash
        - "-c"
        - |
          set -ex
          # Generate mysql server-id from pod ordinal index.
          [[ `hostname` =~ -([0-9]+)$ ]] || exit 1 #匹配hostname的最后一位、最后是一個順序疊加的整數
          ordinal=${BASH_REMATCH[1]} 
          echo [mysqld] > /mnt/conf.d/server-id.cnf
          # Add an offset to avoid reserved server-id=0 value.
          echo server-id=$((100 + $ordinal)) >> /mnt/conf.d/server-id.cnf
          # Copy appropriate conf.d files from config-map to emptyDir.
          if [[ $ordinal -eq 0 ]]; then #如果是master、則cpmaster組態檔
            cp /mnt/config-map/master.cnf /mnt/conf.d/
          else #否則cp slave組態檔
            cp /mnt/config-map/slave.cnf /mnt/conf.d/
          fi
        volumeMounts:
        - name: conf #臨時卷、emptyDir
          mountPath: /mnt/conf.d
        - name: config-map
          mountPath: /mnt/config-map
      - name: clone-mysql #初始化容器2、用于生成mysql組態檔、并從上一個pod完成首次的全量資料clone(slave 3從slave2 clone,而不是每個slave都從master clone實作首次全量同步,但是后期都是與master實作增量同步)
        image: harbor.ik8s.cc/magedu/xtrabackup:1.0 
        command:
        - bash
        - "-c"
        - |
          set -ex
          # Skip the clone if data already exists.
          [[ -d /var/lib/mysql/mysql ]] && exit 0
          # Skip the clone on master (ordinal index 0).
          [[ `hostname` =~ -([0-9]+)$ ]] || exit 1
          ordinal=${BASH_REMATCH[1]}
          [[ $ordinal -eq 0 ]] && exit 0 #如果最后一位是0(master)則退出clone程序
          # Clone data from previous peer.
          ncat --recv-only mysql-$(($ordinal-1)).mysql 3307 | xbstream -x -C /var/lib/mysql #從上一個pod執行clone(binlog),xbstream為解壓縮命令
          # Prepare the backup.xue
          xtrabackup --prepare --target-dir=/var/lib/mysql #通過xtrabackup恢復binlog
        volumeMounts:
        - name: data
          mountPath: /var/lib/mysql
          subPath: mysql
        - name: conf
          mountPath: /etc/mysql/conf.d
      containers:
      - name: mysql #業務容器1(mysql主容器)
        image: harbor.ik8s.cc/magedu/mysql:5.7.36
        env:
        - name: MYSQL_ALLOW_EMPTY_PASSWORD
          value: "1"
        ports:
        - name: mysql
          containerPort: 3306
        volumeMounts:
        - name: data #掛載資料目錄至/var/lib/mysql
          mountPath: /var/lib/mysql
          subPath: mysql
        - name: conf #組態檔/etc/mysql/conf.d
          mountPath: /etc/mysql/conf.d
        resources: #資源限制
          requests:
            cpu: 500m
            memory: 1Gi
        livenessProbe: #存活探針
          exec:
            command: ["mysqladmin", "ping"]
          initialDelaySeconds: 30
          periodSeconds: 10
          timeoutSeconds: 5
        readinessProbe: #就緒探針
          exec:
            # Check we can execute queries over TCP (skip-networking is off).
            command: ["mysql", "-h", "127.0.0.1", "-e", "SELECT 1"]
          initialDelaySeconds: 5
          periodSeconds: 2
          timeoutSeconds: 1
      - name: xtrabackup #業務容器2(xtrabackup),用于后期同步master 的binglog并恢復資料
        image: harbor.ik8s.cc/magedu/xtrabackup:1.0 
        ports:
        - name: xtrabackup
          containerPort: 3307
        command:
        - bash
        - "-c"
        - |
          set -ex
          cd /var/lib/mysql
          # Determine binlog position of cloned data, if any.
          if [[ -f xtrabackup_slave_info ]]; then
            # XtraBackup already generated a partial "CHANGE MASTER TO" query
            # because we're cloning from an existing slave.
            mv xtrabackup_slave_info change_master_to.sql.in
            # Ignore xtrabackup_binlog_info in this case (it's useless).
            rm -f xtrabackup_binlog_info
          elif [[ -f xtrabackup_binlog_info ]]; then
            # We're cloning directly from master. Parse binlog position.
            [[ `cat xtrabackup_binlog_info` =~ ^(.*?)[[:space:]]+(.*?)$ ]] || exit 1
            rm xtrabackup_binlog_info
            echo "CHANGE MASTER TO MASTER_LOG_FILE='${BASH_REMATCH[1]}',\
                  MASTER_LOG_POS=${BASH_REMATCH[2]}" > change_master_to.sql.in #生成CHANGE MASTER命令
          fi
          # Check if we need to complete a clone by starting replication.
          if [[ -f change_master_to.sql.in ]]; then
            echo "Waiting for mysqld to be ready (accepting connections)"
            until mysql -h 127.0.0.1 -e "SELECT 1"; do sleep 1; done
            echo "Initializing replication from clone position"
            # In case of container restart, attempt this at-most-once.
            mv change_master_to.sql.in change_master_to.sql.orig 
            #執行CHANGE MASTER操作并啟動SLAVE
            mysql -h 127.0.0.1 <<EOF
          $(<change_master_to.sql.orig),
            MASTER_HOST='mysql-0.mysql',
            MASTER_USER='root',
            MASTER_PASSWORD='',
            MASTER_CONNECT_RETRY=10;
          START SLAVE;
          EOF
          fi
          # Start a server to send backups when requested by peers. #監聽在3307埠,用于為下一個pod同步全量資料
          exec ncat --listen --keep-open --send-only --max-conns=1 3307 -c \
            "xtrabackup --backup --slave-info --stream=xbstream --host=127.0.0.1 --user=root"
        volumeMounts:
        - name: data
          mountPath: /var/lib/mysql
          subPath: mysql
        - name: conf
          mountPath: /etc/mysql/conf.d
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
      volumes:
      - name: conf
        emptyDir: {}
      - name: config-map
        configMap:
          name: mysql
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: ["ReadWriteOnce"]
      resources:
        requests:
          storage: 10Gi

上述配置清單主要定義兩個mysqlPod,其中每個pod中運行4個容器,第一個容器init容器主要目的是通過sts控制器創建pod的名稱id來確定掛載master和slave配置;第二個初始化容器主要目的是用于克隆上一個pod的資料,即salve1從master上克隆資料,slave2從slave1克隆資料,以此類推;第三個就是mysql主容器,運行mysql實體;第四個容器主要用于給mysql主容器同步后期的增量資料的;

MYSQL SERVICE配置清單

# Headless service for stable DNS entries of StatefulSet members.
apiVersion: v1
kind: Service
metadata:
  namespace: magedu
  name: mysql
  labels:
    app: mysql
spec:
  ports:
  - name: mysql
    port: 3306
  clusterIP: None
  selector:
    app: mysql
---
# Client service for connecting to any MySQL instance for reads.
# For writes, you must instead connect to the master: mysql-0.mysql.
apiVersion: v1
kind: Service
metadata:
  name: mysql-read
  namespace: magedu
  labels:
    app: mysql
spec:
  ports:
  - name: mysql
    port: 3306
  selector:
    app: mysql

上述配置清單主要創建了兩個service,第一個是一個無頭service 用戶回傳后端所有pod端點;第二個service是一個默認clusterip型別service,這兩個service都是可以的;

3.3.1、創建mysql pod

root@k8s-master01:~/k8s-data/yaml/magedu/mysql# kubectl apply -f mysql-configmap.yaml -f mysql-services.yaml -f mysql-statefulset.yaml 
configmap/mysql created
service/mysql created
service/mysql-read created
statefulset.apps/mysql created
root@k8s-master01:~/k8s-data/yaml/magedu/mysql# 

3.3.2、驗證MySQL Pod狀態

root@k8s-master01:~/k8s-data/yaml/magedu/mysql# kubectl get pods -n magedu 
NAME                                             READY   STATUS      RESTARTS       AGE
magedu-nginx-deployment-5589bbf4bc-6gd2w         1/1     Running     8 (113m ago)   11d
magedu-tomcat-app1-deployment-7754c8549c-c7rtb   1/1     Running     4 (114m ago)   11d
magedu-tomcat-app1-deployment-7754c8549c-prglk   1/1     Running     4 (114m ago)   11d
mysql-0                                          2/2     Running     0              47s
mysql-1                                          2/2     Running     0              23s
redis-0                                          1/1     Running     2 (114m ago)   8d
redis-1                                          1/1     Running     2 (114m ago)   8d
redis-2                                          1/1     Running     2 (114m ago)   8d
redis-3                                          1/1     Running     2 (114m ago)   8d
redis-4                                          1/1     Running     2 (114m ago)   8d
redis-5                                          1/1     Running     2 (114m ago)   8d
ubuntu1804                                       0/1     Completed   0              8d
zookeeper1-675c5477cb-vmwwq                      1/1     Running     4 (114m ago)   10d
zookeeper2-759fb6c6f-7jktr                       1/1     Running     4 (114m ago)   10d
zookeeper3-5c78bb5974-vxpbh                      1/1     Running     4 (114m ago)   10d
root@k8s-master01:~/k8s-data/yaml/magedu/mysql# 

修改配置清單pod副本為3,看看對應pod是否能夠正常running?

應用配置清單

3.3.3、驗證MySQL主從同步是否正常

驗證master狀態

root@k8s-master01:~# kubectl exec -it mysql-0 -n magedu  bash 
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
Defaulted container "mysql" out of: mysql, xtrabackup, init-mysql (init), clone-mysql (init)
root@mysql-0:/# mysql 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 691
Server version: 5.7.36-log MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show master status\G
*************************** 1. row ***************************
             File: mysql-0-bin.000003
         Position: 313
     Binlog_Do_DB: 
 Binlog_Ignore_DB: 
Executed_Gtid_Set: 
1 row in set (0.01 sec)

mysql> exit
Bye
root@mysql-0:/# exit
exit
root@k8s-master01:~# 

驗證slave狀態

root@k8s-master01:~# kubectl exec -it mysql-1 -n magedu  bash  
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
Defaulted container "mysql" out of: mysql, xtrabackup, init-mysql (init), clone-mysql (init)
root@mysql-1:/# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 708
Server version: 5.7.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: mysql-0.mysql
                  Master_User: root
                  Master_Port: 3306
                Connect_Retry: 10
              Master_Log_File: mysql-0-bin.000003
          Read_Master_Log_Pos: 313
               Relay_Log_File: mysql-1-relay-bin.000002
                Relay_Log_Pos: 481
        Relay_Master_Log_File: mysql-0-bin.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 313
              Relay_Log_Space: 690
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 100
                  Master_UUID: 72724f41-0b65-11ee-b561-16065cd6961a
             Master_Info_File: /var/lib/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
1 row in set (0.00 sec)

mysql> exit 
Bye
root@mysql-1:/# exit
exit
root@k8s-master01:~# kubectl exec -it mysql-2 -n magedu  bash  
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
Defaulted container "mysql" out of: mysql, xtrabackup, init-mysql (init), clone-mysql (init)
root@mysql-2:/# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 632
Server version: 5.7.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: mysql-0.mysql
                  Master_User: root
                  Master_Port: 3306
                Connect_Retry: 10
              Master_Log_File: mysql-0-bin.000003
          Read_Master_Log_Pos: 313
               Relay_Log_File: mysql-2-relay-bin.000002
                Relay_Log_Pos: 481
        Relay_Master_Log_File: mysql-0-bin.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 313
              Relay_Log_Space: 690
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 100
                  Master_UUID: 72724f41-0b65-11ee-b561-16065cd6961a
             Master_Info_File: /var/lib/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
1 row in set (0.00 sec)

mysql> exit
Bye
root@mysql-2:/# exit
exit
root@k8s-master01:~#

能夠在slave上看到IO和SQL執行緒正常running,說明slave狀態沒有問題;

進入mysql-0創建資料庫

root@k8s-master01:~/k8s-data/yaml/magedu/mysql# kubectl exec -it mysql-0 -n magedu  bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
Defaulted container "mysql" out of: mysql, xtrabackup, init-mysql (init), clone-mysql (init)
root@mysql-0:/# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 355
Server version: 5.7.36-log MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+------------------------+
| Database               |
+------------------------+
| information_schema     |
| mysql                  |
| performance_schema     |
| sys                    |
| xtrabackup_backupfiles |
+------------------------+
5 rows in set (0.02 sec)

mysql> create database mydb;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+------------------------+
| Database               |
+------------------------+
| information_schema     |
| mydb                   |
| mysql                  |
| performance_schema     |
| sys                    |
| xtrabackup_backupfiles |
+------------------------+
6 rows in set (0.00 sec)

mysql> 

在slave pod中驗證資料是否同步?

root@k8s-master01:~/k8s-data/yaml/magedu/mysql# kubectl exec -it mysql-1 -n magedu  bash 
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
Defaulted container "mysql" out of: mysql, xtrabackup, init-mysql (init), clone-mysql (init)
root@mysql-1:/# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 437
Server version: 5.7.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+------------------------+
| Database               |
+------------------------+
| information_schema     |
| mydb                   |
| mysql                  |
| performance_schema     |
| sys                    |
| xtrabackup_backupfiles |
+------------------------+
6 rows in set (0.01 sec)

mysql> exit
Bye
root@mysql-1:/# exit
exit
root@k8s-master01:~/k8s-data/yaml/magedu/mysql# kubectl exec -it mysql-2 -n magedu  bash  
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
Defaulted container "mysql" out of: mysql, xtrabackup, init-mysql (init), clone-mysql (init)
root@mysql-2:/# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 361
Server version: 5.7.36 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+------------------------+
| Database               |
+------------------------+
| information_schema     |
| mydb                   |
| mysql                  |
| performance_schema     |
| sys                    |
| xtrabackup_backupfiles |
+------------------------+
6 rows in set (0.02 sec)

mysql> exit
Bye
root@mysql-2:/# exit
exit
root@k8s-master01:~/k8s-data/yaml/magedu/mysql#

能夠通過上述在主庫創建資料庫,從庫能夠正常同步,則說明mysql主從同步沒有問題;

3.3.4、mysql?可?測驗

3.3.4.1、洗掉master pod驗證mysql高可用性


進入master,驗證master資料是否丟失?

能夠看到master資料并未丟失,這是因為該資料存放至遠端nfs存盤之上;

3.3.4.2、洗掉slave pod驗證mysql高可用性

root@k8s-master01:~# kubectl get pods -n magedu 
NAME                                             READY   STATUS      RESTARTS       AGE
magedu-nginx-deployment-5589bbf4bc-6gd2w         1/1     Running     8 (143m ago)   11d
magedu-tomcat-app1-deployment-7754c8549c-c7rtb   1/1     Running     4 (143m ago)   11d
magedu-tomcat-app1-deployment-7754c8549c-prglk   1/1     Running     4 (143m ago)   11d
mysql-0                                          2/2     Running     0              3m6s
mysql-1                                          2/2     Running     0              29m
mysql-2                                          2/2     Running     0              27m
redis-0                                          1/1     Running     2 (143m ago)   8d
redis-1                                          1/1     Running     2 (143m ago)   8d
redis-2                                          1/1     Running     2 (143m ago)   8d
redis-3                                          1/1     Running     2 (143m ago)   8d
redis-4                                          1/1     Running     2 (143m ago)   8d
redis-5                                          1/1     Running     2 (143m ago)   8d
ubuntu1804                                       0/1     Completed   0              8d
zookeeper1-675c5477cb-vmwwq                      1/1     Running     4 (143m ago)   10d
zookeeper2-759fb6c6f-7jktr                       1/1     Running     4 (143m ago)   10d
zookeeper3-5c78bb5974-vxpbh                      1/1     Running     4 (143m ago)   10d
root@k8s-master01:~# kubectl delete pods mysql-1 -n magedu 
pod "mysql-1" deleted
root@k8s-master01:~# kubectl get pods -n magedu 
NAME                                             READY   STATUS      RESTARTS       AGE
magedu-nginx-deployment-5589bbf4bc-6gd2w         1/1     Running     8 (144m ago)   11d
magedu-tomcat-app1-deployment-7754c8549c-c7rtb   1/1     Running     4 (145m ago)   11d
magedu-tomcat-app1-deployment-7754c8549c-prglk   1/1     Running     4 (145m ago)   11d
mysql-0                                          2/2     Running     0              4m55s
mysql-1                                          2/2     Running     0              55s
mysql-2                                          2/2     Running     0              28m
redis-0                                          1/1     Running     2 (145m ago)   8d
redis-1                                          1/1     Running     2 (145m ago)   8d
redis-2                                          1/1     Running     2 (145m ago)   8d
redis-3                                          1/1     Running     2 (145m ago)   8d
redis-4                                          1/1     Running     2 (145m ago)   8d
redis-5                                          1/1     Running     2 (145m ago)   8d
ubuntu1804                                       0/1     Completed   0              8d
zookeeper1-675c5477cb-vmwwq                      1/1     Running     4 (145m ago)   10d
zookeeper2-759fb6c6f-7jktr                       1/1     Running     4 (145m ago)   10d
zookeeper3-5c78bb5974-vxpbh                      1/1     Running     4 (145m ago)   10d
root@k8s-master01:~# 

進入slave驗證資料

作者:Linux-1874 出處:https://www.cnblogs.com/qiuhom-1874/ 本文著作權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段宣告,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利.

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/555279.html

標籤:其他

上一篇:UE開發使用Rider時快取干爆C盤的解決方案

下一篇:返回列表

標籤雲
其他(161071) Python(38230) JavaScript(25496) Java(18240) C(15237) 區塊鏈(8271) C#(7972) AI(7469) 爪哇(7425) MySQL(7253) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5875) 数组(5741) R(5409) Linux(5347) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4594) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2435) ASP.NET(2404) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) .NET技术(1984) 功能(1967) HtmlCss(1966) Web開發(1951) C++(1940) python-3.x(1918) 弹簧靴(1913) xml(1889) PostgreSQL(1881) .NETCore(1863) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • k8s實戰案例之基于StatefulSet控制器運行MySQL一主多從

    StatefulSet本質上是Deployment的?種變體,在v1.9版本中已成為GA版本,它為了解決有狀態服務的問題,它所管理的Pod擁有固定的Pod名稱,啟停順序,在StatefulSet中,Pod名字稱為?絡標識(hostname),還必須要?到共享存盤。在Deployment中,與之對應的... ......

    uj5u.com 2023-06-16 08:00:11 more
  • UE開發使用Rider時快取干爆C盤的解決方案

    我們在使用Rider開發UE時,Ride會為每一個專案創建一個解決方案快取,如果開幾個新專案寫測驗demo,我們的C盤會逐漸捉急 ![默認情況下](https://img2023.cnblogs.com/blog/2003597/202306/2003597-20230615183008462-89 ......

    uj5u.com 2023-06-16 07:59:58 more
  • 大促質量備戰之三化戰役:“常態化、精細化、一體化”

    大促作為JD一年兩度的盛事,質量備戰是不可或缺的重要環節。每逢大促都是一次大型的聯合戰役,在這種戰役中,不僅有各種“海陸空”技術爭奇斗艷,還會讓我們的技術視野變得更寬闊,讓我們協同變得更默契,所謂以戰養兵。測驗團隊作為質量備戰團隊,沉淀了“常態化”、“精細化”、“一體化”的三化備戰策略,希望與君共勉... ......

    uj5u.com 2023-06-16 07:59:52 more
  • web基礎與HTTP協議

    目錄 一、DNS 二、域名 三、web基礎 四、HTTP 五、總結 摘要:簡單敘述web基礎,網頁的概念,域名決議,域名結構,HTML超文本傳輸語言,cookie和session擴展 一、DNS 1.DNS概念 內網和外網無法通信,為了內網可以和外網通信,dns技術解決問題,可以將公網和私網互相通信 ......

    uj5u.com 2023-06-16 07:59:35 more
  • SQL查詢面試題,會這些基本夠用了

    ### 寫在前面 我已經記不起來,有多久沒更新文章了。 5月中旬我還在上班,中旬以后一系列發生的事情,真的遠遠超出了可承受范圍,只能硬著頭皮面對! 我是誰,我應該是誰,又能怎樣,只能向前····· ### 資料庫實體 #### class表 ![image.png](https://p6-jueji ......

    uj5u.com 2023-06-16 07:58:43 more
  • 科普|一文看懂虛擬人技術原理

    本文作者來自即構開發者社區@ Daniel 投稿,為我們分享時下熱門的數字人技術。IDC 預計,到 2026 年,中國 AI 數字人市場規模將達到 102.4 億元。開發者有必要對數字人技術有完整的認知和理解。 ......

    uj5u.com 2023-06-16 07:58:35 more
  • Open AI ChatGPT Prompt 學習之基礎篇

    2023 年,最火的可能就是 openAI 了,其組織代表的產品 chatGTP,相信大家已經有所耳聞。不少同學已經開始著手使用,并截圖曬出 ChatGPT 是多么得智能與神奇。而有的同學在使用之后覺得有點差強人意,指出頂多算是一個比較聰明的聊天機器人而已。

    其實,ChatGPT 的難點,在于 P... ......

    uj5u.com 2023-06-16 07:58:31 more
  • 批量生成,本地推理,人工智能聲音克隆框架PaddleSpeech本地批量克

    云端煉丹固然是極好的,但不能否認的是,成本要比本地高得多,同時考慮到深度學習的訓練相對于推理來說成本也更高,這主要是因為它需要大量的資料、計算資源和時間等資源,并且對超引數的調整也要求較高,更適合在云端進行。 在推理階段,模型的權重和引數不再調整。相反,模型根據輸入資料的特征進行計算,并輸出預測結果 ......

    uj5u.com 2023-06-16 07:58:24 more
  • ChatGPT+Mermaid自然語言流程圖形化產出小試

    本文旨在介紹如何使用ChatGPT和Mermaid語言生成流程圖的技術。在現代軟體開發中,流程圖是一種重要的工具,用于可視化和呈現各種流程和結構。結合ChatGPT的自然語言處理能力和Mermaid的簡單語法,可以輕松地將文本描述轉化為圖形表示,使技術檔案更具可讀性和易懂性。 ......

    uj5u.com 2023-06-16 07:58:15 more
  • web3產品介紹:mask將Web3的隱私和優勢引入像Facebook和Twitter這

    介紹: Mask Network是一個開源的瀏覽器擴展,將Web3的隱私和優勢引入像Facebook和Twitter這樣的社交媒體平臺。它是一個功能強大的工具,允許用戶在社交媒體上享受區塊鏈的隱私保護和其他Web3的好處。讓我們一起探索Mask Network的主要特點和為用戶帶來的益處。 主要特點 ......

    uj5u.com 2023-06-16 07:58:11 more