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的问题