• seata-server-1.5.2的部署


    配置文件位置

    使用的是nacos和mysql数据库,简单部署在Win10上,Linux上配置修改相同,启动命令不同。

    找到 seata-server-1.5.2\seata\conf目录下的application.yml和application.example.yml

    编辑 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: file
    24. registry:
    25. # support: nacos, eureka, redis, zk, consul, etcd3, sofa
    26. type: file
    27. store:
    28. # support: file 、 db 、 redis
    29. mode: file
    30. # server:
    31. # service-port: 8091 #If not configured, the default is '${server.port} + 1000'
    32. security:
    33. secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
    34. tokenValidityInMilliseconds: 1800000
    35. ignore:
    36. urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login

    seata-nacos

    使用的是nacos,找到seata config位置,type改为nacos,下面的几列内容直接去application.example.yml(参考前面的位置,改文件与application.yml同一目录)找到对应代码段,复制到application.yml,再修改为自己nacos的配置

     namespace默认为public,补齐其他信息

    再去nacos中,新建一个名为seata-server.properties的配置,该配置中文件内容来源:


    配置地址https://github.com/seata/seata/blob/1.5.2/script/config-center/config.txt

     seata-server-1.5.2-test\seata\script\config-center目录下也有

    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=127.0.0.1:8091
    28. service.enableDegrade=false
    29. service.disableGlobalTransaction=false
    30. #Transaction rule configuration, only for the client
    31. client.rm.asyncCommitBufferLimit=10000
    32. client.rm.lock.retryInterval=10
    33. client.rm.lock.retryTimes=30
    34. client.rm.lock.retryPolicyBranchRollbackOnConflict=true
    35. client.rm.reportRetryCount=5
    36. client.rm.tableMetaCheckEnable=true
    37. client.rm.tableMetaCheckerInterval=60000
    38. client.rm.sqlParserType=druid
    39. client.rm.reportSuccessEnable=false
    40. client.rm.sagaBranchRegisterEnable=false
    41. client.rm.sagaJsonParser=fastjson
    42. client.rm.tccActionInterceptorOrder=-2147482648
    43. client.tm.commitRetryCount=5
    44. client.tm.rollbackRetryCount=5
    45. client.tm.defaultGlobalTransactionTimeout=60000
    46. client.tm.degradeCheck=false
    47. client.tm.degradeCheckAllowTimes=10
    48. client.tm.degradeCheckPeriod=2000
    49. client.tm.interceptorOrder=-2147482648
    50. client.undo.dataValidation=true
    51. client.undo.logSerialization=jackson
    52. client.undo.onlyCareUpdateColumns=true
    53. server.undo.logSaveDays=7
    54. server.undo.logDeletePeriod=86400000
    55. client.undo.logTable=undo_log
    56. client.undo.compress.enable=true
    57. client.undo.compress.type=zip
    58. client.undo.compress.threshold=64k
    59. #For TCC transaction mode
    60. tcc.fence.logTableName=tcc_fence_log
    61. tcc.fence.cleanPeriod=1h
    62. #Log rule configuration, for client and server
    63. log.exceptionRate=100
    64. #Transaction storage configuration, only for the server. The file, DB, and redis configuration values are optional.
    65. store.mode=file
    66. store.lock.mode=file
    67. store.session.mode=file
    68. #Used for password encryption
    69. store.publicKey=
    70. #If `store.mode,store.lock.mode,store.session.mode` are not equal to `file`, you can remove the configuration block.
    71. store.file.dir=file_store/data
    72. store.file.maxBranchSessionSize=16384
    73. store.file.maxGlobalSessionSize=512
    74. store.file.fileWriteBufferCacheSize=16384
    75. store.file.flushDiskMode=async
    76. store.file.sessionReloadReadSize=100
    77. #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.
    78. store.db.datasource=druid
    79. store.db.dbType=mysql
    80. store.db.driverClassName=com.mysql.jdbc.Driver
    81. store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true&rewriteBatchedStatements=true
    82. store.db.user=username
    83. store.db.password=password
    84. store.db.minConn=5
    85. store.db.maxConn=30
    86. store.db.globalTable=global_table
    87. store.db.branchTable=branch_table
    88. store.db.distributedLockTable=distributed_lock
    89. store.db.queryLimit=100
    90. store.db.lockTable=lock_table
    91. store.db.maxWait=5000
    92. #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.
    93. store.redis.mode=single
    94. store.redis.single.host=127.0.0.1
    95. store.redis.single.port=6379
    96. store.redis.sentinel.masterName=
    97. store.redis.sentinel.sentinelHosts=
    98. store.redis.maxConn=10
    99. store.redis.minConn=1
    100. store.redis.maxTotal=100
    101. store.redis.database=0
    102. store.redis.password=
    103. store.redis.queryLimit=100
    104. #Transaction rule configuration, only for the server
    105. server.recovery.committingRetryPeriod=1000
    106. server.recovery.asynCommittingRetryPeriod=1000
    107. server.recovery.rollbackingRetryPeriod=1000
    108. server.recovery.timeoutRetryPeriod=1000
    109. server.maxCommitRetryTimeout=-1
    110. server.maxRollbackRetryTimeout=-1
    111. server.rollbackRetryTimeoutUnlockEnable=false
    112. server.distributedLockExpireTime=10000
    113. server.xaerNotaRetryTimeout=60000
    114. server.session.branchAsyncQueueSize=5000
    115. server.session.enableBranchAsyncRemove=false
    116. server.enableParallelRequestHandle=false
    117. #Metrics configuration, only for the server
    118. metrics.enabled=false
    119. metrics.registryType=compact
    120. metrics.exporterList=prometheus
    121. metrics.exporterPrometheusPort=9898

    seata-db 

    找到store mode中使用mysql数据库,修改为db,内容同样是从application.example.yml对应位置复制而来,将配置修改为自己对应数据库的配置

     在数据库创建名为seata的数据库,执行seata-server-1.5.2\seata\script\server\db下的mysql.sql

    mysql.sql

    1. -- -------------------------------- The script used when storeMode is 'db' --------------------------------
    2. -- the table to store GlobalSession data
    3. CREATE TABLE IF NOT EXISTS `global_table`
    4. (
    5. `xid` VARCHAR(128) NOT NULL,
    6. `transaction_id` BIGINT,
    7. `status` TINYINT 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` DATETIME,
    15. `gmt_modified` DATETIME,
    16. PRIMARY KEY (`xid`),
    17. KEY `idx_status_gmt_modified` (`status` , `gmt_modified`),
    18. KEY `idx_transaction_id` (`transaction_id`)
    19. ) ENGINE = InnoDB
    20. DEFAULT CHARSET = utf8mb4;
    21. -- the table to store BranchSession data
    22. CREATE TABLE IF NOT EXISTS `branch_table`
    23. (
    24. `branch_id` BIGINT NOT NULL,
    25. `xid` VARCHAR(128) NOT NULL,
    26. `transaction_id` BIGINT,
    27. `resource_group_id` VARCHAR(32),
    28. `resource_id` VARCHAR(256),
    29. `branch_type` VARCHAR(8),
    30. `status` TINYINT,
    31. `client_id` VARCHAR(64),
    32. `application_data` VARCHAR(2000),
    33. `gmt_create` DATETIME(6),
    34. `gmt_modified` DATETIME(6),
    35. PRIMARY KEY (`branch_id`),
    36. KEY `idx_xid` (`xid`)
    37. ) ENGINE = InnoDB
    38. DEFAULT CHARSET = utf8mb4;
    39. -- the table to store lock data
    40. CREATE TABLE IF NOT EXISTS `lock_table`
    41. (
    42. `row_key` VARCHAR(128) NOT NULL,
    43. `xid` VARCHAR(128),
    44. `transaction_id` BIGINT,
    45. `branch_id` BIGINT NOT NULL,
    46. `resource_id` VARCHAR(256),
    47. `table_name` VARCHAR(32),
    48. `pk` VARCHAR(36),
    49. `status` TINYINT NOT NULL DEFAULT '0' COMMENT '0:locked ,1:rollbacking',
    50. `gmt_create` DATETIME,
    51. `gmt_modified` DATETIME,
    52. PRIMARY KEY (`row_key`),
    53. KEY `idx_status` (`status`),
    54. KEY `idx_branch_id` (`branch_id`),
    55. KEY `idx_xid_and_branch_id` (`xid` , `branch_id`)
    56. ) ENGINE = InnoDB
    57. DEFAULT CHARSET = utf8mb4;
    58. CREATE TABLE IF NOT EXISTS `distributed_lock`
    59. (
    60. `lock_key` CHAR(20) NOT NULL,
    61. `lock_value` VARCHAR(20) NOT NULL,
    62. `expire` BIGINT,
    63. primary key (`lock_key`)
    64. ) ENGINE = InnoDB
    65. DEFAULT CHARSET = utf8mb4;
    66. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
    67. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
    68. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
    69. INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);

    运行seata-server-1.5.2\seata\bin目录下的运行程序,windows系统执行seata-server.bat文件,linux系统执行seata-server.sh文件

    执行时后面要加后缀 -p 指定 server 启动的端口  -h  指定在注册中心注册的 IP   -m 事务日志存储方式

    seata-server.bat -p 8091 -h 127.0.0.1 -m db

    启动后成功注册进nacos

  • 相关阅读:
    EDUCoder编程练习题解(编辑与调试)
    01序列 卡特兰数
    【VMware16 安装 Centos7 并配置固定IP】
    C++ Tutorials: C++ Language: Compound data types: Dynamic memory
    MybatisPlus
    Unity 最新DOTS系列之《Baking与Baker的详解》
    计算机网络—概述
    simulink中比scope模块还好用的平替出图工具?
    解决国外镜像无法访问导致的R包无法安装问题
    Mysql(Mariadb) 数据库安装在ArchLinux
  • 原文地址:https://blog.csdn.net/weixin_45009521/article/details/128183662