Seata Server in k8s


1.部署 seata-server

1.創建seata-server需要的表
具體的 SQL 參考 https://github.com/seata/seata/tree/develop/script/server/db,這里使用的是 MySQL 的腳本,數據庫名稱為 seata
同時,也需要創建 undo_log 表, 可以參考 https://github.com/seata/seata/tree/develop/script/client/at/db
2.修改seata-server配置
將以下配置添加到 Nacos 配置中心,具體添加方法可以參考 https://github.com/seata/seata/tree/develop/script/config-center
[root@k8s-matser01 ~]# cat config.txt 
ervice.vgroupMapping.my_test_tx_group=default
store.mode=db
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://10.2.1.12:30060/seata?useUnicode=true  # 數據庫地址
store.db.user=root # seata數據庫的賬號
store.db.password=123456 # seata數據庫的密碼
[root@k8s-matser01 ~]# sh ./nacos/nacos-config.sh -h 10.2.1.12 -p 8848 -g SEATA_GROUP -u nacos -w nacos
參數說明:

-h: Nacos主機地址,默認是localhost

-p: Nacos主機端口,默認是8848

-g: 配置分組, the default value is 'SEATA_GROUP'.

-t: 租戶信息, 與Nacos的 "命名空間ID" 字段相對應, the default value is ''.

-u: Nacos用戶名, the default value is ''.

-w: Nacos密碼, the default value is ''.

[root@k8s-matser01 nacos]# cat nacos-config.sh  
...
   100	count=0
    # 我這里改成了絕對路徑
   101	for line in $(cat /root/nacos/config.txt | sed s/[[:space:]]//g); do
   102	    count=`expr $count + 1`
   103		key=${line%%=*}
   104	    value=${line#*=}
···

2.部署 seata-server 到 Kubernetes

[root@k8s-matser01 ~]# cat seata.yaml 
apiVersion: v1
kind: Service
metadata:
  name: seata-ha-server
  namespace: default
  labels:
    app.kubernetes.io/name: seata-ha-server
spec:
  type: ClusterIP
  ports:
    - port: 8091
      protocol: TCP
      name: http
  selector:
    app.kubernetes.io/name: seata-ha-server

---

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: seata-ha-server
  namespace: default
  labels:
    app.kubernetes.io/name: seata-ha-server
spec:
  serviceName: seata-ha-server
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: seata-ha-server
  template:
    metadata:
      labels:
        app.kubernetes.io/name: seata-ha-server
    spec:
      containers:
        - name: seata-ha-server
          image: seataio/seata-server:1.3.0
          imagePullPolicy: IfNotPresent
          env:
            - name: SEATA_CONFIG_NAME
              value: file:/root/seata-config/registry
          ports:
            - name: http
              containerPort: 8091
              protocol: TCP
          volumeMounts:
            - name: seata-config
              mountPath: /root/seata-config
      volumes:
        - name: seata-config
          configMap:
            name: seata-ha-server-config


---
apiVersion: v1
kind: ConfigMap
metadata:
  name: seata-ha-server-config
data:
  registry.conf: |
    registry {
        type = "nacos"
        nacos {
          application = "seata-server"
          serverAddr = "10.2.1.12" #nacos的ip
        }
    }
    config {
      type = "nacos"
      nacos {
        serverAddr = "10.2.1.12" # nacos的ip
        group = "SEATA_GROUP"
      }
    }

3.問題

# 這是我用的最新的seata鏡像,換成了seata:1.3.0就ok了,百度說了是jdk的問題


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM