• k8s Seata1.5.1


    部署方式:可以看这篇:

    k8s helm Seata1.5.1_hunheidaode的博客-CSDN博客4.我只是改动了values.yaml与templates下的deployment.yaml。在上面添加了些许改动,只不过是用helm部署了,其余的操作还是跟上篇博文一样子的。3.下载seta helm部署yaml文件:文件位于:不知道的可看上篇博文。把/seata-server/resources 下的文件挂载到。7.访问nacos 看到已经被注册到nacos中。2.环境:k8s 、nfs环境 或是动态存储。seataConfigName:后面的内容。/data/k8s/resource下。......https://blog.csdn.net/hunheidaode/article/details/126623672

    helm-charticon-default.png?t=M85Bhttps://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  只对这个文件做了修改:

    1. server:
    2. port: 7091
    3. spring:
    4. application:
    5. name: seata-server
    6. logging:
    7. config: classpath:logback-spring.xml
    8. file:
    9. path: ${user.home}/logs/seata
    10. extend:
    11. logstash-appender:
    12. destination: 127.0.0.1:4560
    13. kafka-appender:
    14. bootstrap-servers: 127.0.0.1:9092
    15. topic: logback_to_logstash
    16. console:
    17. user:
    18. username: seata
    19. password: seata
    20. seata:
    21. config:
    22. # support: nacos 、 consul 、 apollo 、 zk 、 etcd3
    23. type: nacos
    24. nacos:
    25. server-addr: 192.168.56.211:31460
    26. namespace: public
    27. group: SEATA_GROUP
    28. username: nacos
    29. password: nacos
    30. ##if use MSE Nacos with auth, mutex with username/password attribute
    31. #access-key: ""
    32. #secret-key: ""
    33. data-id: seata.properties
    34. registry:
    35. # support: nacos 、 eureka 、 redis 、 zk 、 consul 、 etcd3 、 sofa
    36. type: nacos
    37. preferred-networks: 192.168.*
    38. nacos:
    39. application: seata-server
    40. server-addr: 192.168.56.211:31460
    41. group: SEATA_GROUP
    42. namespace: public
    43. cluster: default
    44. username: nacos
    45. password: nacos
    46. ##if use MSE Nacos with auth, mutex with username/password attribute
    47. #access-key: ""
    48. #secret-key: ""
    49. store:
    50. # support: file 、 db 、 redis
    51. mode: db
    52. session:
    53. mode: db
    54. lock:
    55. mode: db
    56. file:
    57. dir: sessionStore
    58. max-branch-session-size: 16384
    59. max-global-session-size: 512
    60. file-write-buffer-cache-size: 16384
    61. session-reload-read-size: 100
    62. flush-disk-mode: async
    63. db:
    64. datasource: druid
    65. db-type: mysql
    66. driver-class-name: com.mysql.jdbc.Driver
    67. url: jdbc:mysql://192.168.56.211:31306/seata?rewriteBatchedStatements=true
    68. user: root
    69. password: s00J8De852
    70. min-conn: 5
    71. max-conn: 100
    72. global-table: global_table
    73. branch-table: branch_table
    74. lock-table: lock_table
    75. distributed-lock-table: distributed_lock
    76. query-limit: 100
    77. max-wait: 5000
    78. security:
    79. secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
    80. tokenValidityInMilliseconds: 1800000
    81. ignore:
    82. 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地址:

    1. #For details about configuration items, see https://seata.io/zh-cn/docs/user/configurations.html
    2. #Transport configuration, for client and server
    3. transport.type=TCP
    4. transport.server=NIO
    5. transport.heartbeat=true
    6. transport.enableTmClientBatchSendRequest=false
    7. transport.enableRmClientBatchSendRequest=true
    8. transport.enableTcServerBatchSendResponse=false
    9. transport.rpcRmRequestTimeout=30000
    10. transport.rpcTmRequestTimeout=30000
    11. transport.rpcTcRequestTimeout=30000
    12. transport.threadFactory.bossThreadPrefix=NettyBoss
    13. transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
    14. transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
    15. transport.threadFactory.shareBossWorker=false
    16. transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
    17. transport.threadFactory.clientSelectorThreadSize=1
    18. transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
    19. transport.threadFactory.bossThreadSize=1
    20. transport.threadFactory.workerThreadSize=default
    21. transport.shutdown.wait=3
    22. transport.serialization=seata
    23. transport.compressor=none
    24. #Transaction routing rules configuration, only for the client
    25. service.vgroupMapping.default_tx_group=default
    26. #If you use a registry, you can ignore it
    27. #service.default.grouplist=192.168.56.211:8091
    28. service.default.grouplist=192.168.56.211:31460
    29. service.enableDegrade=false
    30. service.disableGlobalTransaction=false
    31. #Transaction rule configuration, only for the client
    32. client.rm.asyncCommitBufferLimit=10000
    33. client.rm.lock.retryInterval=10
    34. client.rm.lock.retryTimes=30
    35. client.rm.lock.retryPolicyBranchRollbackOnConflict=true
    36. client.rm.reportRetryCount=5
    37. client.rm.tableMetaCheckEnable=true
    38. client.rm.tableMetaCheckerInterval=60000
    39. client.rm.sqlParserType=druid
    40. client.rm.reportSuccessEnable=false
    41. client.rm.sagaBranchRegisterEnable=false
    42. client.rm.sagaJsonParser=fastjson
    43. client.rm.tccActionInterceptorOrder=-2147482648
    44. client.tm.commitRetryCount=5
    45. client.tm.rollbackRetryCount=5
    46. client.tm.defaultGlobalTransactionTimeout=60000
    47. client.tm.degradeCheck=false
    48. client.tm.degradeCheckAllowTimes=10
    49. client.tm.degradeCheckPeriod=2000
    50. client.tm.interceptorOrder=-2147482648
    51. client.undo.dataValidation=true
    52. client.undo.logSerialization=jackson
    53. client.undo.onlyCareUpdateColumns=true
    54. server.undo.logSaveDays=7
    55. server.undo.logDeletePeriod=86400000
    56. client.undo.logTable=undo_log
    57. client.undo.compress.enable=true
    58. client.undo.compress.type=zip
    59. client.undo.compress.threshold=64k
    60. #For TCC transaction mode
    61. tcc.fence.logTableName=tcc_fence_log
    62. tcc.fence.cleanPeriod=1h
    63. #Log rule configuration, for client and server
    64. log.exceptionRate=100
    65. #Transaction storage configuration, only for the server. The file, DB, and redis configuration values are optional.
    66. store.mode=db
    67. store.lock.mode=db
    68. store.session.mode=db
    69. #Used for password encryption
    70. store.publicKey=
    71. #If `store.mode,store.lock.mode,store.session.mode` are not equal to `file`, you can remove the configuration block.
    72. store.file.dir=file_store/data
    73. store.file.maxBranchSessionSize=16384
    74. store.file.maxGlobalSessionSize=512
    75. store.file.fileWriteBufferCacheSize=16384
    76. store.file.flushDiskMode=async
    77. store.file.sessionReloadReadSize=100
    78. #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.
    79. store.db.datasource=druid
    80. store.db.dbType=mysql
    81. store.db.driverClassName=com.mysql.jdbc.Driver
    82. store.db.url=jdbc:mysql://192.168.56.211:31306/seata?useUnicode=true&rewriteBatchedStatements=true
    83. store.db.user=root
    84. store.db.password=s00J8De852
    85. store.db.minConn=5
    86. store.db.maxConn=30
    87. store.db.globalTable=global_table
    88. store.db.branchTable=branch_table
    89. store.db.distributedLockTable=distributed_lock
    90. store.db.queryLimit=100
    91. store.db.lockTable=lock_table
    92. store.db.maxWait=5000
    93. #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.
    94. store.redis.mode=single
    95. store.redis.single.host=127.0.0.1
    96. store.redis.single.port=6379
    97. store.redis.sentinel.masterName=
    98. store.redis.sentinel.sentinelHosts=
    99. store.redis.maxConn=10
    100. store.redis.minConn=1
    101. store.redis.maxTotal=100
    102. store.redis.database=0
    103. store.redis.password=
    104. store.redis.queryLimit=100
    105. #Transaction rule configuration, only for the server
    106. server.recovery.committingRetryPeriod=1000
    107. server.recovery.asynCommittingRetryPeriod=1000
    108. server.recovery.rollbackingRetryPeriod=1000
    109. server.recovery.timeoutRetryPeriod=1000
    110. server.maxCommitRetryTimeout=-1
    111. server.maxRollbackRetryTimeout=-1
    112. server.rollbackRetryTimeoutUnlockEnable=false
    113. server.distributedLockExpireTime=10000
    114. server.xaerNotaRetryTimeout=60000
    115. server.session.branchAsyncQueueSize=5000
    116. server.session.enableBranchAsyncRemove=false
    117. #Metrics configuration, only for the server
    118. metrics.enabled=false
    119. metrics.registryType=compact
    120. metrics.exporterList=prometheus
    121. metrics.exporterPrometheusPort=9898

    在MySQL中的sql文件:

    我是直接一股脑把全部sql都弄进去了:

    1. -- -------------------------------- The script use tcc fence --------------------------------
    2. CREATE TABLE IF NOT EXISTS `tcc_fence_log`
    3. (
    4. `xid` VARCHAR(128) NOT NULL COMMENT 'global id',
    5. `branch_id` BIGINT NOT NULL COMMENT 'branch id',
    6. `action_name` VARCHAR(64) NOT NULL COMMENT 'action name',
    7. `status` TINYINT NOT NULL COMMENT 'status(tried:1;committed:2;rollbacked:3;suspended:4)',
    8. `gmt_create` DATETIME(3) NOT NULL COMMENT 'create time',
    9. `gmt_modified` DATETIME(3) NOT NULL COMMENT 'update time',
    10. PRIMARY KEY (`xid`, `branch_id`),
    11. KEY `idx_gmt_modified` (`gmt_modified`),
    12. KEY `idx_status` (`status`)
    13. ) ENGINE = InnoDB
    14. DEFAULT CHARSET = utf8mb4;
    15. -- for AT mode you must to init this sql for you business database. the seata server not need it.
    16. CREATE TABLE IF NOT EXISTS `undo_log`
    17. (
    18. `branch_id` BIGINT NOT NULL COMMENT 'branch transaction id',
    19. `xid` VARCHAR(128) NOT NULL COMMENT 'global transaction id',
    20. `context` VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
    21. `rollback_info` LONGBLOB NOT NULL COMMENT 'rollback info',
    22. `log_status` INT(11) NOT NULL COMMENT '0:normal status,1:defense status',
    23. `log_created` DATETIME(6) NOT NULL COMMENT 'create datetime',
    24. `log_modified` DATETIME(6) NOT NULL COMMENT 'modify datetime',
    25. UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
    26. ) ENGINE = InnoDB
    27. AUTO_INCREMENT = 1
    28. DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
    29. -- -------------------------------- The script used for sage --------------------------------
    30. CREATE TABLE IF NOT EXISTS `seata_state_machine_def`
    31. (
    32. `id` VARCHAR(32) NOT NULL COMMENT 'id',
    33. `name` VARCHAR(128) NOT NULL COMMENT 'name',
    34. `tenant_id` VARCHAR(32) NOT NULL COMMENT 'tenant id',
    35. `app_name` VARCHAR(32) NOT NULL COMMENT 'application name',
    36. `type` VARCHAR(20) COMMENT 'state language type',
    37. `comment_` VARCHAR(255) COMMENT 'comment',
    38. `ver` VARCHAR(16) NOT NULL COMMENT 'version',
    39. `gmt_create` DATETIME(3) NOT NULL COMMENT 'create time',
    40. `status` VARCHAR(2) NOT NULL COMMENT 'status(AC:active|IN:inactive)',
    41. `content` TEXT COMMENT 'content',
    42. `recover_strategy` VARCHAR(16) COMMENT 'transaction recover strategy(compensate|retry)',
    43. PRIMARY KEY (`id`)
    44. ) ENGINE = InnoDB
    45. DEFAULT CHARSET = utf8mb4;
    46. CREATE TABLE IF NOT EXISTS `seata_state_machine_inst`
    47. (
    48. `id` VARCHAR(128) NOT NULL COMMENT 'id',
    49. `machine_id` VARCHAR(32) NOT NULL COMMENT 'state machine definition id',
    50. `tenant_id` VARCHAR(32) NOT NULL COMMENT 'tenant id',
    51. `parent_id` VARCHAR(128) COMMENT 'parent id',
    52. `gmt_started` DATETIME(3) NOT NULL COMMENT 'start time',
    53. `business_key` VARCHAR(48) COMMENT 'business key',
    54. `start_params` TEXT COMMENT 'start parameters',
    55. `gmt_end` DATETIME(3) COMMENT 'end time',
    56. `excep` BLOB COMMENT 'exception',
    57. `end_params` TEXT COMMENT 'end parameters',
    58. `status` VARCHAR(2) COMMENT 'status(SU succeed|FA failed|UN unknown|SK skipped|RU running)',
    59. `compensation_status` VARCHAR(2) COMMENT 'compensation status(SU succeed|FA failed|UN unknown|SK skipped|RU running)',
    60. `is_running` TINYINT(1) COMMENT 'is running(0 no|1 yes)',
    61. `gmt_updated` DATETIME(3) NOT NULL,
    62. PRIMARY KEY (`id`),
    63. UNIQUE KEY `unikey_buz_tenant` (`business_key`, `tenant_id`)
    64. ) ENGINE = InnoDB
    65. DEFAULT CHARSET = utf8mb4;
    66. CREATE TABLE IF NOT EXISTS `seata_state_inst`
    67. (
    68. `id` VARCHAR(48) NOT NULL COMMENT 'id',
    69. `machine_inst_id` VARCHAR(128) NOT NULL COMMENT 'state machine instance id',
    70. `name` VARCHAR(128) NOT NULL COMMENT 'state name',
    71. `type` VARCHAR(20) COMMENT 'state type',
    72. `service_name` VARCHAR(128) COMMENT 'service name',
    73. `service_method` VARCHAR(128) COMMENT 'method name',
    74. `service_type` VARCHAR(16) COMMENT 'service type',
    75. `business_key` VARCHAR(48) COMMENT 'business key',
    76. `state_id_compensated_for` VARCHAR(50) COMMENT 'state compensated for',
    77. `state_id_retried_for` VARCHAR(50) COMMENT 'state retried for',
    78. `gmt_started` DATETIME(3) NOT NULL COMMENT 'start time',
    79. `is_for_update` TINYINT(1) COMMENT 'is service for update',
    80. `input_params` TEXT COMMENT 'input parameters',
    81. `output_params` TEXT COMMENT 'output parameters',
    82. `status` VARCHAR(2) NOT NULL COMMENT 'status(SU succeed|FA failed|UN unknown|SK skipped|RU running)',
    83. `excep` BLOB COMMENT 'exception',
    84. `gmt_updated` DATETIME(3) COMMENT 'update time',
    85. `gmt_end` DATETIME(3) COMMENT 'end time',
    86. PRIMARY KEY (`id`, `machine_inst_id`)
    87. ) ENGINE = InnoDB
    88. DEFAULT CHARSET = utf8mb4;
    89. -- -------------------------------- The script used when storeMode is 'db' --------------------------------
    90. -- the table to store GlobalSession data
    91. CREATE TABLE IF NOT EXISTS `global_table`
    92. (
    93. `xid` VARCHAR(128) NOT NULL,
    94. `transaction_id` BIGINT,
    95. `status` TINYINT NOT NULL,
    96. `application_id` VARCHAR(32),
    97. `transaction_service_group` VARCHAR(32),
    98. `transaction_name` VARCHAR(128),
    99. `timeout` INT,
    100. `begin_time` BIGINT,
    101. `application_data` VARCHAR(2000),
    102. `gmt_create` DATETIME,
    103. `gmt_modified` DATETIME,
    104. PRIMARY KEY (`xid`),
    105. KEY `idx_status_gmt_modified` (`status` , `gmt_modified`),
    106. KEY `idx_transaction_id` (`transaction_id`)
    107. ) ENGINE = InnoDB
    108. DEFAULT CHARSET = utf8mb4;
    109. -- the table to store BranchSession data
    110. CREATE TABLE IF NOT EXISTS `branch_table`
    111. (
    112. `branch_id` BIGINT NOT NULL,
    113. `xid` VARCHAR(128) NOT NULL,
    114. `transaction_id` BIGINT,
    115. `resource_group_id` VARCHAR(32),
    116. `resource_id` VARCHAR(256),
    117. `branch_type` VARCHAR(8),
    118. `status` TINYINT,
    119. `client_id` VARCHAR(64),
    120. `application_data` VARCHAR(2000),
    121. `gmt_create` DATETIME(6),
    122. `gmt_modified` DATETIME(6),
    123. PRIMARY KEY (`branch_id`),
    124. KEY `idx_xid` (`xid`)
    125. ) ENGINE = InnoDB
    126. DEFAULT CHARSET = utf8mb4;
    127. -- the table to store lock data
    128. CREATE TABLE IF NOT EXISTS `lock_table`
    129. (
    130. `row_key` VARCHAR(128) NOT NULL,
    131. `xid` VARCHAR(128),
    132. `transaction_id` BIGINT,
    133. `branch_id` BIGINT NOT NULL,
    134. `resource_id` VARCHAR(256),
    135. `table_name` VARCHAR(32),
    136. `pk` VARCHAR(36),
    137. `status` TINYINT NOT NULL DEFAULT '0' COMMENT '0:locked ,1:rollbacking',
    138. `gmt_create` DATETIME,
    139. `gmt_modified` DATETIME,
    140. PRIMARY KEY (`row_key`),
    141. KEY `idx_status` (`status`),
    142. KEY `idx_branch_id` (`branch_id`),
    143. KEY `idx_xid_and_branch_id` (`xid` , `branch_id`)
    144. ) ENGINE = InnoDB
    145. DEFAULT CHARSET = utf8mb4;
    146. CREATE TABLE IF NOT EXISTS `distributed_lock`
    147. (
    148. `lock_key` CHAR(20) NOT NULL,
    149. `lock_value` VARCHAR(20) NOT NULL,
    150. `expire` BIGINT,
    151. primary key (`lock_key`)
    152. ) ENGINE = InnoDB
    153. DEFAULT CHARSET = utf8mb4;
    154. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
    155. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
    156. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
    157. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);

    5. seata.yaml文件:

    1. apiVersion: v1
    2. kind: Service
    3. metadata:
    4. name: seata-server
    5. namespace: default
    6. labels:
    7. k8s-app: seata-server
    8. spec:
    9. type: NodePort
    10. ports:
    11. - port: 8091
    12. nodePort: 30091
    13. protocol: TCP
    14. name: http
    15. selector:
    16. k8s-app: seata-server
    17. ---
    18. apiVersion: apps/v1
    19. kind: Deployment
    20. metadata:
    21. name: seata-server
    22. namespace: default
    23. labels:
    24. k8s-app: seata-server
    25. spec:
    26. replicas: 1
    27. selector:
    28. matchLabels:
    29. k8s-app: seata-server
    30. template:
    31. metadata:
    32. labels:
    33. k8s-app: seata-server
    34. spec:
    35. containers:
    36. - name: seata-server
    37. image: docker.io/seataio/seata-server:1.5.1
    38. imagePullPolicy: IfNotPresent
    39. ports:
    40. - name: http
    41. containerPort: 8091
    42. protocol: TCP
    43. volumeMounts:
    44. - name: seata-config
    45. mountPath: /seata-server/resources
    46. volumes:
    47. - name: seata-config
    48. hostPath:
    49. 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.完结!

  • 相关阅读:
    Linux之vim的使用详细解析
    【Centos】深度解析:CentOS下安装pip的完整指南
    攻防世界-web-unseping
    【宏基因组学】微生物宏基因组学论文摘要集锦
    基于httpd和lvs的dr模式简单测试
    程序员的底层思维
    伦敦银怎么算自己的收益?
    每日shell脚本之mysql健康查询
    当 AI 邂逅绘画艺术,能迸发出怎样的火花?
    亳州市的自然风光与旅游资源:欣赏安徽省中部的壮丽景色
  • 原文地址:https://blog.csdn.net/hunheidaode/article/details/126619308