• Centos7 安装Seata1.5.1


    一、环境说明

    IP操作系统程序备注
    10.0.61.22centos7.9PostgreSQL-14.11已提前部署
    10.0.61.21centos7.9Nacos-2.1.0已提前部署
    10.0.61.22centos7.9seata-server-1.5.1本文将要部署

    二、部署

    1. 下载

    wget https://github.com/seata/seata/releases/download/v1.5.1/seata-server-1.5.1.tar.gz
    

    2. 解压

    1. tar -zxvf seata-server-1.5.1.tar.gz
    2. # 解压出的文件名 seata,改个名,标注版本
    3. mv seata seata-1.5.1

    3. 配置

    3.1 application.yml 配置

    1. cd seata-1.5.1
    2. # 备份
    3. cp seata-1.5.1/conf/application.yml seata-1.5.1/conf/application.yml.bak
    4. # 修改
    5. vim seata-1.5.1/conf/application.yml

            内容如下,具体配置参照 application.example.yml 中配置修改

    1. server:
    2. port: 8891
    3. spring:
    4. application:
    5. name: seata-server
    6. logging:
    7. config: classpath:logback-spring.xml
    8. file:
    9. path: ./logs/seata
    10. console:
    11. user:
    12. username: seata
    13. password: seata
    14. seata:
    15. config:
    16. type: nacos
    17. nacos:
    18. server-addr: 10.0.61.21:8848
    19. group: SEATA_GROUP
    20. namespace: b1b4b131-0fa9-47cf-8ddb-afe1a4c3e7e2
    21. username: xxxx
    22. password: xxxx
    23. registry:
    24. type: nacos
    25. nacos:
    26. application: seata-server
    27. server-addr: 10.0.61.21:8848
    28. group: SEATA_GROUP
    29. namespace: b1b4b131-0fa9-47cf-8ddb-afe1a4c3e7e2
    30. cluster: default
    31. username: xxxx
    32. password: xxxx
    33. security:
    34. secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
    35. tokenValidityInMilliseconds: 1800000
    36. ignore:
    37. urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login

    3.2 seataServer.properties配置

            属性配置官方文档说明(未更新,还是1.4.2版本):https://seata.io/zh-cn/docs/user/configurations.html
    详细配置(由于Github访问限制,给个Gitee仓库的链接):https://gitee.com/seata-io/seata/blob/v1.5.1/script/config-center/config.txt

    • 创建 seataServer.properties ,注意 namespace 、 group 、data-id 和上述 application.yml 配置中心的配置 保持一致,内容参照 详细配置链接 中配置按需配即可
    • 事务分组概念: https://seata.io/zh-cn/docs/user/txgroup/transaction-group.html

    在这里插入图片描述

    1. #transport
    2. transport.compressor=none
    3. transport.enableRmClientBatchSendRequest=true
    4. transport.enableTcServerBatchSendResponse=false
    5. transport.enableTmClientBatchSendRequest=false
    6. transport.heartbeat=true
    7. transport.rpcRmRequestTimeout=30000
    8. transport.rpcTcRequestTimeout=30000
    9. transport.rpcTmRequestTimeout=30000
    10. transport.serialization=seata
    11. transport.server=NIO
    12. transport.shutdown.wait=3
    13. transport.threadFactory.bossThreadPrefix=NettyBoss
    14. transport.threadFactory.bossThreadSize=1
    15. transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
    16. transport.threadFactory.clientSelectorThreadSize=1
    17. transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
    18. transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
    19. transport.threadFactory.shareBossWorker=false
    20. transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
    21. transport.threadFactory.workerThreadSize=default
    22. transport.type=TCP
    23. #service
    24. service.default.grouplist=10.0.61.21:8891
    25. service.disableGlobalTransaction=false
    26. service.enableDegrade=false
    27. service.vgroupMapping.swkj_tx_group=default
    28. #client
    29. client.rm.asyncCommitBufferLimit=10000
    30. client.rm.lock.retryInterval=10
    31. client.rm.lock.retryPolicyBranchRollbackOnConflict=true
    32. client.rm.lock.retryTimes=30
    33. client.rm.reportRetryCount=5
    34. client.rm.reportSuccessEnable=false
    35. client.rm.sagaBranchRegisterEnable=false
    36. client.rm.sagaJsonParser=fastjson
    37. client.rm.sqlParserType=druid
    38. client.rm.tableMetaCheckEnable=true
    39. client.rm.tableMetaCheckerInterval=60000
    40. client.rm.tccActionInterceptorOrder=-2147482648
    41. client.tm.commitRetryCount=5
    42. client.tm.defaultGlobalTransactionTimeout=60000
    43. client.tm.degradeCheck=false
    44. client.tm.degradeCheckAllowTimes=10
    45. client.tm.degradeCheckPeriod=2000
    46. client.tm.interceptorOrder=-2147482648
    47. client.tm.rollbackRetryCount=5
    48. client.undo.compress.enable=true
    49. client.undo.compress.threshold=64k
    50. client.undo.compress.type=zip
    51. client.undo.dataValidation=true
    52. client.undo.logSerialization=jackson
    53. client.undo.logTable=undo_log
    54. client.undo.onlyCareUpdateColumns=true
    55. #server
    56. server.distributedLockExpireTime=10000
    57. server.enableParallelRequestHandle=false
    58. server.maxCommitRetryTimeout=-1
    59. server.maxRollbackRetryTimeout=-1
    60. server.recovery.asynCommittingRetryPeriod=1000
    61. server.recovery.committingRetryPeriod=1000
    62. server.recovery.rollbackingRetryPeriod=1000
    63. server.recovery.timeoutRetryPeriod=1000
    64. server.rollbackRetryTimeoutUnlockEnable=false
    65. server.session.branchAsyncQueueSize=5000
    66. server.session.enableBranchAsyncRemove=false
    67. server.undo.logDeletePeriod=86400000
    68. server.undo.logSaveDays=7
    69. server.xaerNotaRetryTimeout=60000
    70. #tcc
    71. tcc.fence.cleanPeriod=1h
    72. tcc.fence.logTableName=tcc_fence_log
    73. #log
    74. log.exceptionRate=100
    75. #store
    76. store.db.branchTable=branch_table
    77. store.db.datasource=druid
    78. store.db.dbType=postgresql
    79. store.db.distributedLockTable=distributed_lock
    80. store.db.driverClassName=org.postgresql.Driver
    81. store.db.globalTable=global_table
    82. store.db.lockTable=lock_table
    83. store.db.maxConn=30
    84. store.db.maxWait=5000
    85. store.db.minConn=5
    86. store.db.password=xxx
    87. store.db.queryLimit=100
    88. store.db.url=jdbc:postgresql://10.0.61.22:8832/postgres?useUnicode=true&characterEncoding=UTF-8&useSSL=false
    89. store.db.user=postgres
    90. store.file.dir=file_store/data
    91. store.file.fileWriteBufferCacheSize=16384
    92. store.file.flushDiskMode=async
    93. store.file.maxBranchSessionSize=16384
    94. store.file.maxGlobalSessionSize=512
    95. store.file.sessionReloadReadSize=100
    96. store.lock.mode=db
    97. store.mode=db
    98. store.redis.database=0
    99. store.redis.maxConn=10
    100. store.redis.maxTotal=100
    101. store.redis.minConn=1
    102. store.redis.mode=single
    103. store.redis.password=xxx
    104. store.redis.queryLimit=100
    105. store.redis.single.host=10.0.61.21
    106. store.redis.single.port=8879
    107. store.session.mode=db
    108. #metrics
    109. metrics.enabled=false
    110. metrics.exporterList=prometheus
    111. metrics.exporterPrometheusPort=9898
    112. metrics.registryType=compact

    3.3 PostgreSQL脚本

            client端:

    1. -- for AT mode you must to init this sql for you business database. the seata server not need it.
    2. CREATE TABLE IF NOT EXISTS public.undo_log
    3. (
    4. id SERIAL NOT NULL,
    5. branch_id BIGINT NOT NULL,
    6. xid VARCHAR(128) NOT NULL,
    7. context VARCHAR(128) NOT NULL,
    8. rollback_info BYTEA NOT NULL,
    9. log_status INT NOT NULL,
    10. log_created TIMESTAMP(0) NOT NULL,
    11. log_modified TIMESTAMP(0) NOT NULL,
    12. CONSTRAINT pk_undo_log PRIMARY KEY (id),
    13. CONSTRAINT ux_undo_log UNIQUE (xid, branch_id)
    14. );
    15. CREATE SEQUENCE IF NOT EXISTS undo_log_id_seq INCREMENT BY 1 MINVALUE 1 ;

            Server端: 

    1. -- -------------------------------- The script used when storeMode is 'db' --------------------------------
    2. -- the table to store GlobalSession data
    3. CREATE TABLE IF NOT EXISTS public.global_table
    4. (
    5. xid VARCHAR(128) NOT NULL,
    6. transaction_id BIGINT,
    7. status SMALLINT NOT NULL,
    8. application_id VARCHAR(32),
    9. transaction_service_group VARCHAR(32),
    10. transaction_name VARCHAR(128),
    11. timeout INT,
    12. begin_time BIGINT,
    13. application_data VARCHAR(2000),
    14. gmt_create TIMESTAMP(0),
    15. gmt_modified TIMESTAMP(0),
    16. CONSTRAINT pk_global_table PRIMARY KEY (xid)
    17. );
    18. CREATE INDEX idx_status_gmt_modified ON public.global_table (status, gmt_modified);
    19. CREATE INDEX idx_transaction_id ON public.global_table (transaction_id);
    20. -- the table to store BranchSession data
    21. CREATE TABLE IF NOT EXISTS public.branch_table
    22. (
    23. branch_id BIGINT NOT NULL,
    24. xid VARCHAR(128) NOT NULL,
    25. transaction_id BIGINT,
    26. resource_group_id VARCHAR(32),
    27. resource_id VARCHAR(256),
    28. branch_type VARCHAR(8),
    29. status SMALLINT,
    30. client_id VARCHAR(64),
    31. application_data VARCHAR(2000),
    32. gmt_create TIMESTAMP(6),
    33. gmt_modified TIMESTAMP(6),
    34. CONSTRAINT pk_branch_table PRIMARY KEY (branch_id)
    35. );
    36. CREATE INDEX idx_xid ON public.branch_table (xid);
    37. -- the table to store lock data
    38. CREATE TABLE IF NOT EXISTS public.lock_table
    39. (
    40. row_key VARCHAR(128) NOT NULL,
    41. xid VARCHAR(128),
    42. transaction_id BIGINT,
    43. branch_id BIGINT NOT NULL,
    44. resource_id VARCHAR(256),
    45. table_name VARCHAR(32),
    46. pk VARCHAR(36),
    47. status SMALLINT NOT NULL DEFAULT 0,
    48. gmt_create TIMESTAMP(0),
    49. gmt_modified TIMESTAMP(0),
    50. CONSTRAINT pk_lock_table PRIMARY KEY (row_key)
    51. );
    52. comment on column public.lock_table.status is '0:locked ,1:rollbacking';
    53. CREATE INDEX idx_branch_id ON public.lock_table (branch_id);
    54. CREATE INDEX idx_xid ON public.lock_table (xid);
    55. CREATE INDEX idx_status ON public.lock_table (status);
    56. CREATE TABLE distributed_lock (
    57. lock_key VARCHAR(20) NOT NULL,
    58. lock_value VARCHAR(20) NOT NULL,
    59. expire BIGINT NOT NULL,
    60. CONSTRAINT pk_distributed_lock_table PRIMARY KEY (lock_key)
    61. );
    62. INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
    63. INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
    64. INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
    65. INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);

           注:在部署过程中遇到一个问题导致Seata无法启动,要注意Seata Server端需要配置环境变量在/etc/profile中:

    1. #seata
    2. export SEATA_IP=10.0.61.22

           环境变量生效,命令如下:

    # source /etc/profile

            启动 seata-server,命令如下:

    # nohup sh ./bin/seata-server.sh -h 10.0.61.22 -m db &> seata.log &

            开启以下端口:

    88919891

            到此Centos7 安装Seata1.5.1介绍完成。

  • 相关阅读:
    Avue树结构懒加载子节点不刷新
    Python趣味算法入门 - 兔子产子
    基于DotNetty实现自动发布 - 实现一键打包发布
    Python与pycharm-----windows安装与运行
    Android webView加载高德地图定位不显示问题
    python Calendar日历模块函数介绍
    【算法训练营】 井字棋
    【JAVA程序设计】基于SSH(非maven)便利店管理系统-有文档
    全相联映射、直接映射、组相连映射
    java学习笔记.md版本
  • 原文地址:https://blog.csdn.net/qq_19734597/article/details/127961630