部署方式:可以看这篇:
helm-charthttps://heidaodageshiwo.github.io/helm-chart/
1.前言:
本人找遍csdn都没有找打部署seata1.5.0以上版本的教程。只能自己动手了。
如需转载请注明出处。谢谢!
Seata1.5.1目前应该是不在使用 registory.conf file.conf那种部署了。
本人按照官网的方式部署了2天都没有成功!
后来看到有人提了issues:
1.5.2版本 Kubernetes部署如何指定环境变量 · Issue #4820 · seata/seata · GitHub
恍然大悟。
我是直接挂载的seata1.5.1这个版本的resource下的文件.
按照这个老哥说的使用 configmap,我也没有操作成功!
本人直接全部挂载!全部挂载!全部挂载!全部挂载!全部挂载!
本人当前使用 hostpath挂载! 挂载
seata的resource文件:
GitHub - seata/seata at v1.5.1
请先下载这些文件:
https://github.com/seata/seata/tree/v1.5.1
下载:到本地:
一会把这些文件全部挂载:
2.
.版本说明 官方指定1.5.1版本。 那就部署1.5.1版本了
3.application.yml 只对这个文件做了修改:
- server:
- port: 7091
-
- spring:
- application:
- name: seata-server
-
- logging:
- config: classpath:logback-spring.xml
- file:
- path: ${user.home}/logs/seata
- extend:
- logstash-appender:
- destination: 127.0.0.1:4560
- kafka-appender:
- bootstrap-servers: 127.0.0.1:9092
- topic: logback_to_logstash
- console:
- user:
- username: seata
- password: seata
-
- seata:
- config:
- # support: nacos 、 consul 、 apollo 、 zk 、 etcd3
- type: nacos
- nacos:
- server-addr: 192.168.56.211:31460
- namespace: public
- group: SEATA_GROUP
- username: nacos
- password: nacos
- ##if use MSE Nacos with auth, mutex with username/password attribute
- #access-key: ""
- #secret-key: ""
- data-id: seata.properties
- registry:
- # support: nacos 、 eureka 、 redis 、 zk 、 consul 、 etcd3 、 sofa
- type: nacos
- preferred-networks: 192.168.*
- nacos:
- application: seata-server
- server-addr: 192.168.56.211:31460
- group: SEATA_GROUP
- namespace: public
- cluster: default
- username: nacos
- password: nacos
- ##if use MSE Nacos with auth, mutex with username/password attribute
- #access-key: ""
- #secret-key: ""
-
- store:
- # support: file 、 db 、 redis
- mode: db
- session:
- mode: db
- lock:
- mode: db
- file:
- dir: sessionStore
- max-branch-session-size: 16384
- max-global-session-size: 512
- file-write-buffer-cache-size: 16384
- session-reload-read-size: 100
- flush-disk-mode: async
- db:
- datasource: druid
- db-type: mysql
- driver-class-name: com.mysql.jdbc.Driver
- url: jdbc:mysql://192.168.56.211:31306/seata?rewriteBatchedStatements=true
- user: root
- password: s00J8De852
- min-conn: 5
- max-conn: 100
- global-table: global_table
- branch-table: branch_table
- lock-table: lock_table
- distributed-lock-table: distributed_lock
- query-limit: 100
- max-wait: 5000
- security:
- secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
- tokenValidityInMilliseconds: 1800000
- ignore:
- urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login
4.上传:把文件上传到服务器 因为我是hostpath配置的,没有使用nfs,所以k8s每个node节点都需要复制一份。指不定被调度到那个节点了呢。(给文件执行权限:)
[root@node2 resources]# chmod 777 *
4.1需要在nacos文件里面填写 配置文件:
dataid:
seata.properties |
datagroup:
SEATA_GROUP
内容:请自行修改mysql地址:
- #For details about configuration items, see https://seata.io/zh-cn/docs/user/configurations.html
- #Transport configuration, for client and server
- transport.type=TCP
- transport.server=NIO
- transport.heartbeat=true
- transport.enableTmClientBatchSendRequest=false
- transport.enableRmClientBatchSendRequest=true
- transport.enableTcServerBatchSendResponse=false
- transport.rpcRmRequestTimeout=30000
- transport.rpcTmRequestTimeout=30000
- transport.rpcTcRequestTimeout=30000
- transport.threadFactory.bossThreadPrefix=NettyBoss
- transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
- transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
- transport.threadFactory.shareBossWorker=false
- transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
- transport.threadFactory.clientSelectorThreadSize=1
- transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
- transport.threadFactory.bossThreadSize=1
- transport.threadFactory.workerThreadSize=default
- transport.shutdown.wait=3
- transport.serialization=seata
- transport.compressor=none
-
- #Transaction routing rules configuration, only for the client
- service.vgroupMapping.default_tx_group=default
- #If you use a registry, you can ignore it
- #service.default.grouplist=192.168.56.211:8091
- service.default.grouplist=192.168.56.211:31460
- service.enableDegrade=false
- service.disableGlobalTransaction=false
-
- #Transaction rule configuration, only for the client
- client.rm.asyncCommitBufferLimit=10000
- client.rm.lock.retryInterval=10
- client.rm.lock.retryTimes=30
- client.rm.lock.retryPolicyBranchRollbackOnConflict=true
- client.rm.reportRetryCount=5
- client.rm.tableMetaCheckEnable=true
- client.rm.tableMetaCheckerInterval=60000
- client.rm.sqlParserType=druid
- client.rm.reportSuccessEnable=false
- client.rm.sagaBranchRegisterEnable=false
- client.rm.sagaJsonParser=fastjson
- client.rm.tccActionInterceptorOrder=-2147482648
- client.tm.commitRetryCount=5
- client.tm.rollbackRetryCount=5
- client.tm.defaultGlobalTransactionTimeout=60000
- client.tm.degradeCheck=false
- client.tm.degradeCheckAllowTimes=10
- client.tm.degradeCheckPeriod=2000
- client.tm.interceptorOrder=-2147482648
- client.undo.dataValidation=true
- client.undo.logSerialization=jackson
- client.undo.onlyCareUpdateColumns=true
- server.undo.logSaveDays=7
- server.undo.logDeletePeriod=86400000
- client.undo.logTable=undo_log
- client.undo.compress.enable=true
- client.undo.compress.type=zip
- client.undo.compress.threshold=64k
- #For TCC transaction mode
- tcc.fence.logTableName=tcc_fence_log
- tcc.fence.cleanPeriod=1h
-
- #Log rule configuration, for client and server
- log.exceptionRate=100
-
- #Transaction storage configuration, only for the server. The file, DB, and redis configuration values are optional.
- store.mode=db
- store.lock.mode=db
- store.session.mode=db
- #Used for password encryption
- store.publicKey=
-
- #If `store.mode,store.lock.mode,store.session.mode` are not equal to `file`, you can remove the configuration block.
- store.file.dir=file_store/data
- store.file.maxBranchSessionSize=16384
- store.file.maxGlobalSessionSize=512
- store.file.fileWriteBufferCacheSize=16384
- store.file.flushDiskMode=async
- store.file.sessionReloadReadSize=100
-
- #These configurations are required if the `store mode` is `db`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `db`, you can remove the configuration block.
- store.db.datasource=druid
- store.db.dbType=mysql
- store.db.driverClassName=com.mysql.jdbc.Driver
- store.db.url=jdbc:mysql://192.168.56.211:31306/seata?useUnicode=true&rewriteBatchedStatements=true
- store.db.user=root
- store.db.password=s00J8De852
- store.db.minConn=5
- store.db.maxConn=30
- store.db.globalTable=global_table
- store.db.branchTable=branch_table
- store.db.distributedLockTable=distributed_lock
- store.db.queryLimit=100
- store.db.lockTable=lock_table
- store.db.maxWait=5000
-
- #These configurations are required if the `store mode` is `redis`. If `store.mode,store.lock.mode,store.session.mode` are not equal to `redis`, you can remove the configuration block.
- store.redis.mode=single
- store.redis.single.host=127.0.0.1
- store.redis.single.port=6379
- store.redis.sentinel.masterName=
- store.redis.sentinel.sentinelHosts=
- store.redis.maxConn=10
- store.redis.minConn=1
- store.redis.maxTotal=100
- store.redis.database=0
- store.redis.password=
- store.redis.queryLimit=100
-
- #Transaction rule configuration, only for the server
- server.recovery.committingRetryPeriod=1000
- server.recovery.asynCommittingRetryPeriod=1000
- server.recovery.rollbackingRetryPeriod=1000
- server.recovery.timeoutRetryPeriod=1000
- server.maxCommitRetryTimeout=-1
- server.maxRollbackRetryTimeout=-1
- server.rollbackRetryTimeoutUnlockEnable=false
- server.distributedLockExpireTime=10000
- server.xaerNotaRetryTimeout=60000
- server.session.branchAsyncQueueSize=5000
- server.session.enableBranchAsyncRemove=false
-
- #Metrics configuration, only for the server
- metrics.enabled=false
- metrics.registryType=compact
- metrics.exporterList=prometheus
- metrics.exporterPrometheusPort=9898
在MySQL中的sql文件:
我是直接一股脑把全部sql都弄进去了:
- -- -------------------------------- The script use tcc fence --------------------------------
- CREATE TABLE IF NOT EXISTS `tcc_fence_log`
- (
- `xid` VARCHAR(128) NOT NULL COMMENT 'global id',
- `branch_id` BIGINT NOT NULL COMMENT 'branch id',
- `action_name` VARCHAR(64) NOT NULL COMMENT 'action name',
- `status` TINYINT NOT NULL COMMENT 'status(tried:1;committed:2;rollbacked:3;suspended:4)',
- `gmt_create` DATETIME(3) NOT NULL COMMENT 'create time',
- `gmt_modified` DATETIME(3) NOT NULL COMMENT 'update time',
- PRIMARY KEY (`xid`, `branch_id`),
- KEY `idx_gmt_modified` (`gmt_modified`),
- KEY `idx_status` (`status`)
- ) ENGINE = InnoDB
- DEFAULT CHARSET = utf8mb4;
-
-
- -- for AT mode you must to init this sql for you business database. the seata server not need it.
- CREATE TABLE IF NOT EXISTS `undo_log`
- (
- `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
- `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
- `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
- `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
- `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
- `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
- `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
- UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
- ) ENGINE = InnoDB
- AUTO_INCREMENT = 1
- DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
-
-
- -- -------------------------------- The script used for sage --------------------------------
-
-
- CREATE TABLE IF NOT EXISTS `seata_state_machine_def`
- (
- `id` VARCHAR(32) NOT NULL COMMENT 'id',
- `name` VARCHAR(128) NOT NULL COMMENT 'name',
- `tenant_id` VARCHAR(32) NOT NULL COMMENT 'tenant id',
- `app_name` VARCHAR(32) NOT NULL COMMENT 'application name',
- `type` VARCHAR(20) COMMENT 'state language type',
- `comment_` VARCHAR(255) COMMENT 'comment',
- `ver` VARCHAR(16) NOT NULL COMMENT 'version',
- `gmt_create` DATETIME(3) NOT NULL COMMENT 'create time',
- `status` VARCHAR(2) NOT NULL COMMENT 'status(AC:active|IN:inactive)',
- `content` TEXT COMMENT 'content',
- `recover_strategy` VARCHAR(16) COMMENT 'transaction recover strategy(compensate|retry)',
- PRIMARY KEY (`id`)
- ) ENGINE = InnoDB
- DEFAULT CHARSET = utf8mb4;
-
- CREATE TABLE IF NOT EXISTS `seata_state_machine_inst`
- (
- `id` VARCHAR(128) NOT NULL COMMENT 'id',
- `machine_id` VARCHAR(32) NOT NULL COMMENT 'state machine definition id',
- `tenant_id` VARCHAR(32) NOT NULL COMMENT 'tenant id',
- `parent_id` VARCHAR(128) COMMENT 'parent id',
- `gmt_started` DATETIME(3) NOT NULL COMMENT 'start time',
- `business_key` VARCHAR(48) COMMENT 'business key',
- `start_params` TEXT COMMENT 'start parameters',
- `gmt_end` DATETIME(3) COMMENT 'end time',
- `excep` BLOB COMMENT 'exception',
- `end_params` TEXT COMMENT 'end parameters',
- `status` VARCHAR(2) COMMENT 'status(SU succeed|FA failed|UN unknown|SK skipped|RU running)',
- `compensation_status` VARCHAR(2) COMMENT 'compensation status(SU succeed|FA failed|UN unknown|SK skipped|RU running)',
- `is_running` TINYINT(1) COMMENT 'is running(0 no|1 yes)',
- `gmt_updated` DATETIME(3) NOT NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY `unikey_buz_tenant` (`business_key`, `tenant_id`)
- ) ENGINE = InnoDB
- DEFAULT CHARSET = utf8mb4;
-
- CREATE TABLE IF NOT EXISTS `seata_state_inst`
- (
- `id` VARCHAR(48) NOT NULL COMMENT 'id',
- `machine_inst_id` VARCHAR(128) NOT NULL COMMENT 'state machine instance id',
- `name` VARCHAR(128) NOT NULL COMMENT 'state name',
- `type` VARCHAR(20) COMMENT 'state type',
- `service_name` VARCHAR(128) COMMENT 'service name',
- `service_method` VARCHAR(128) COMMENT 'method name',
- `service_type` VARCHAR(16) COMMENT 'service type',
- `business_key` VARCHAR(48) COMMENT 'business key',
- `state_id_compensated_for` VARCHAR(50) COMMENT 'state compensated for',
- `state_id_retried_for` VARCHAR(50) COMMENT 'state retried for',
- `gmt_started` DATETIME(3) NOT NULL COMMENT 'start time',
- `is_for_update` TINYINT(1) COMMENT 'is service for update',
- `input_params` TEXT COMMENT 'input parameters',
- `output_params` TEXT COMMENT 'output parameters',
- `status` VARCHAR(2) NOT NULL COMMENT 'status(SU succeed|FA failed|UN unknown|SK skipped|RU running)',
- `excep` BLOB COMMENT 'exception',
- `gmt_updated` DATETIME(3) COMMENT 'update time',
- `gmt_end` DATETIME(3) COMMENT 'end time',
- PRIMARY KEY (`id`, `machine_inst_id`)
- ) ENGINE = InnoDB
- DEFAULT CHARSET = utf8mb4;
-
-
- -- -------------------------------- The script used when storeMode is 'db' --------------------------------
- -- the table to store GlobalSession data
- CREATE TABLE IF NOT EXISTS `global_table`
- (
- `xid` VARCHAR(128) NOT NULL,
- `transaction_id` BIGINT,
- `status` TINYINT NOT NULL,
- `application_id` VARCHAR(32),
- `transaction_service_group` VARCHAR(32),
- `transaction_name` VARCHAR(128),
- `timeout` INT,
- `begin_time` BIGINT,
- `application_data` VARCHAR(2000),
- `gmt_create` DATETIME,
- `gmt_modified` DATETIME,
- PRIMARY KEY (`xid`),
- KEY `idx_status_gmt_modified` (`status` , `gmt_modified`),
- KEY `idx_transaction_id` (`transaction_id`)
- ) ENGINE = InnoDB
- DEFAULT CHARSET = utf8mb4;
-
- -- the table to store BranchSession data
- CREATE TABLE IF NOT EXISTS `branch_table`
- (
- `branch_id` BIGINT NOT NULL,
- `xid` VARCHAR(128) NOT NULL,
- `transaction_id` BIGINT,
- `resource_group_id` VARCHAR(32),
- `resource_id` VARCHAR(256),
- `branch_type` VARCHAR(8),
- `status` TINYINT,
- `client_id` VARCHAR(64),
- `application_data` VARCHAR(2000),
- `gmt_create` DATETIME(6),
- `gmt_modified` DATETIME(6),
- PRIMARY KEY (`branch_id`),
- KEY `idx_xid` (`xid`)
- ) ENGINE = InnoDB
- DEFAULT CHARSET = utf8mb4;
-
- -- the table to store lock data
- CREATE TABLE IF NOT EXISTS `lock_table`
- (
- `row_key` VARCHAR(128) NOT NULL,
- `xid` VARCHAR(128),
- `transaction_id` BIGINT,
- `branch_id` BIGINT NOT NULL,
- `resource_id` VARCHAR(256),
- `table_name` VARCHAR(32),
- `pk` VARCHAR(36),
- `status` TINYINT NOT NULL DEFAULT '0' COMMENT '0:locked ,1:rollbacking',
- `gmt_create` DATETIME,
- `gmt_modified` DATETIME,
- PRIMARY KEY (`row_key`),
- KEY `idx_status` (`status`),
- KEY `idx_branch_id` (`branch_id`),
- KEY `idx_xid_and_branch_id` (`xid` , `branch_id`)
- ) ENGINE = InnoDB
- DEFAULT CHARSET = utf8mb4;
-
- CREATE TABLE IF NOT EXISTS `distributed_lock`
- (
- `lock_key` CHAR(20) NOT NULL,
- `lock_value` VARCHAR(20) NOT NULL,
- `expire` BIGINT,
- primary key (`lock_key`)
- ) ENGINE = InnoDB
- DEFAULT CHARSET = utf8mb4;
-
- INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
- INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
- INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
- INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
5. seata.yaml文件:
- apiVersion: v1
- kind: Service
- metadata:
- name: seata-server
- namespace: default
- labels:
- k8s-app: seata-server
- spec:
- type: NodePort
- ports:
- - port: 8091
- nodePort: 30091
- protocol: TCP
- name: http
- selector:
- k8s-app: seata-server
-
- ---
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: seata-server
- namespace: default
- labels:
- k8s-app: seata-server
- spec:
- replicas: 1
- selector:
- matchLabels:
- k8s-app: seata-server
- template:
- metadata:
- labels:
- k8s-app: seata-server
- spec:
- containers:
- - name: seata-server
- image: docker.io/seataio/seata-server:1.5.1
- imagePullPolicy: IfNotPresent
- ports:
- - name: http
- containerPort: 8091
- protocol: TCP
- volumeMounts:
- - name: seata-config
- mountPath: /seata-server/resources
- volumes:
- - name: seata-config
- hostPath:
- path: /root/resources
本人是将
volumeMounts: - name: seata-config mountPath: /seata-server/resources volumes: - name: seata-config hostPath: path: /root/resources
给挂载了出来。
可以进入pod查看这个文件
本人已经挂载出来了,所以会是这个样子的,你们没有在没有挂载出来可以进去看看
我是把这些文件放到了 /root/resources 这个下面
6.配置就这些!搞了好几天
7.
执行!
kubectl apply -f seata.yaml
看nacos!
8.当查看pod时有报错问题
对于这个问题官网也有issues:
https://github.com/seata/seata/issues/2116
开发人员已经给出了答案升级 MySQL版本!。但应该是不影响使用,要是修改版本,还要自己去打镜像。太麻烦我就没有搞,但是应该是可以使用的了。已经祖册到了nacos中。
9.
踩坑有点多!后续会出helm的!
我是在csdn没找到部署这1.5.0以上版本的。只能自己部署了。
10.完结!