k8s安装seata单机版

1.初始seata数据库

wget  https://raw.githubusercontent.com/apache/incubator-seata/1.3.0/script/server/db/mysql.sql
mysql -uroot -p
CREATE DATABASE IF NOT EXISTS seata DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
use seata;
source  /root/mysql.sql;
CREATE USER 'seata'@'%' IDENTIFIED BY 'MXl#GX8hw0wEv!ID';
GRANT ALL PRIVILEGES ON seata.* TO 'seata'@'%';
FLUSH PRIVILEGES;
exit;

2.创建seata配置文件

registry.conf

apiVersion: v1
kind: ConfigMap
metadata:
  name: t1-zdbl-seata-server-registry-config
  namespace: t1-zdbl
data:
  registry.conf: |
    registry {
        type = "nacos"
        nacos {
          application = "seata-server"
          serverAddr = "t1-zdbl-nacos.t1-zdbl.svc.cluster.local:8848"
          group = "SEATA_GROUP"
          namespace = "seata"
          cluster = "default"
          username = "nacos"
          password = "m5LqrxYsD7N1F6Cb"
        }
    }
    config {
      type = "file"
      file {
            name = "file:/seata-server/resources/file.conf"
          }
    }

file.conf

apiVersion: v1
kind: ConfigMap
metadata:
  name: t1-zdbl-seata-server-file-config
  namespace: t1-zdbl
data:
  file.conf: |
    store {
        mode = "db"    
        db {
           datasource = "druid"
           dbType = "mysql"
           driverClassName = "com.mysql.cj.jdbc.Driver"
           url = "jdbc:mysql://t1-zdbl-mysql.t1-zdbl.svc.cluster.local:3306/t1_zdbl_seata?useUnicode=true&characterEncoding=UTF-8"
           user = "seata"
           password = "xxxxx"  #连接nacos的密码不能包含特殊字符,否则会报错,403无法注册
           minConn = 5
           maxConn = 100
           globalTable = "global_table"
           branchTable = "branch_table"
           lockTable = "lock_table"
           queryLimit = 100
           maxWait = 5000
        }
    }

3.创建部署文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: t1-zdbl-seata-server
  namespace: t1-zdbl
  labels:
    k8s-app: t1-zdbl-seata-server
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: t1-zdbl-seata-server
  template:
    metadata:
      labels:
        k8s-app: t1-zdbl-seata-server
    spec:
      containers:
        - name: seata-server
          image: seataio/seata-server:1.3.0
          #command: ["/bin/sh","-c","sleep 3600000"]
          env:
            - name: SEATA_PORT
              value: "8091"
          ports:
            - name: http
              containerPort: 8091
              protocol: TCP
          volumeMounts:
          - mountPath: /seata-server/resources/file.conf
            name: seata-file-conf
            subPath: file.conf
          - mountPath: /seata-server/resources/registry.conf
            name: seata-register-conf
            subPath: registry.conf
      volumes:
      - name: seata-file-conf
        configMap:
          defaultMode: 420
          name: t1-zdbl-seata-server-file-config
      - name: seata-register-conf
        configMap:
          defaultMode: 420
          name: t1-zdbl-seata-server-registry-config

4.创建svc文件

apiVersion: v1
kind: Service
metadata:
  name: t1-zdbl-seata-server
  namespace: t1-zdbl
  labels:
    k8s-app: t1-zdbl-seata-server
spec:
  ports:
    - port: 8091
      targetPort: 8091
      protocol: TCP
      name: http
  selector:
    k8s-app: t1-zdbl-seata-server

初始化数据库后,应用以上文件即可

 

posted @ 2024-04-17 17:05  百衲本  阅读(97)  评论(0编辑  收藏  举报
cnblogs_post_body { color: black; font: 0.875em/1.5em "微软雅黑" , "PTSans" , "Arial" ,sans-serif; font-size: 15px; } cnblogs_post_body h1 { text-align:center; background: #333366; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 23px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } cnblogs_post_body h2 { text-align:center; background: #006699; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 20px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } cnblogs_post_body h3 { background: #2B6695; border-radius: 6px 6px 6px 6px; box-shadow: 0 0 0 1px #5F5A4B, 1px 1px 6px 1px rgba(10, 10, 0, 0.5); color: #FFFFFF; font-family: "微软雅黑" , "宋体" , "黑体" ,Arial; font-size: 18px; font-weight: bold; height: 25px; line-height: 25px; margin: 18px 0 !important; padding: 8px 0 5px 5px; text-shadow: 2px 2px 3px #222222; } 回到顶部 博客侧边栏 回到顶部 页首代码 回到顶部 页脚代码