Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to quickly deploy a seata project

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to quickly deploy a seata project, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Step 1: download the source code:

Git clone https://gitee.com/leitingweb/seata-demo.git

After importing the project, the overall structure of the project is shown in the following figure:

Step 2: modify the seata-server configuration file:

Seata-server is the transaction coordinator in seata, and the project consists of two main configuration files, registy.conf and file.conf, whose location is shown in the following figure:

(1) registry.conf

By default, the configuration mode of seata-server is file mode, which is determined by the registy.type and config.type attributes of registy.conf. In this mode, the configuration of seata-server is a walking configuration file. The name of the configuration file is determined in the registry.file.name and config.file.name attributes, and the default is file.conf. Therefore, the project can start normally without modifying the configuration file and go to the default configuration.

Of course, nacos, eureka, redis, zk, consul, etcd3, sofa and other configuration methods are also supported. The default file mode is used in this document. After deleting other useless configuration methods, the structure of registry.conf is simplified as follows:

Registry {# file, nacos, eureka, redis, zk, consul, etcd3, sofa type = "file" file {name = "file.conf"} config {# file, nacos, apollo, zk, consul, etcd3 type = "file" file {name = "file.conf"}}

(2) file.conf file

The file file mainly configures various properties of seata-server, or it can not be modified at all and go to the default configuration. This article focuses on the store module.

Seata-server has two storage modes: file and db, which can be configured through the store.mode attribute. The default storage mode is file.

In file mode, the transaction-related information of seata is stored in memory and persisted into root.data files, which has higher performance.

Db schema is a highly available schema. Global transactions, branch transactions and locks of seata are all stored in the database, and related tables are all in the all_in_one.sql file.

If it is db mode, find the db module to modify the database configuration information, and modify the database IP, port number, user name and password according to your own database, as shown below:

# # transaction log storestore {# # store mode: file, db mode = "file" # # file store file {dir = "sessionStore" # branch session size, if exceeded first try compress lockkey, still exceeded throws exceptions max-branch-session-size = 16384 # globe session size, if exceeded throws exceptions max-global-session-size = 512 # file buffer size, if exceeded allocate new buffer file-write-buffer-cache-size = 16384 # when recover batch read size session.reload.read_size = 100 # async Sync flush-disk-mode = async} # # database store db {# # the implement of javax.sql.DataSource Such as DruidDataSource (druid) / BasicDataSource (dbcp) etc. Datasource = "dbcp" # # mysql/oracle/h3/oceanbase etc. Db-type = "mysql" driver-class-name = "com.mysql.jdbc.Driver" url = "jdbc:mysql://***:3306/seata" user = "*" password = "* *" min-conn = 1 max-conn = 3 global.table = "global_table" Branch.table = "branch_table" lock-table = "lock_table" query-limit = 100}}

Step 3 modify the configuration file of the spingboot-mybatis project

Account: sbm-account-service

Business: sbm-business-service

Order: sbm-order-service

Inventory: sbm-storage-service

You need to modify the relevant configuration files of the above projects respectively, taking the sbm-account-service project as an example:

Modify the application.properties file

Mainly modify the database connection information of the configuration file, according to your own database, modify the database IP, port number, user name and password

Spring.application.name=account-serviceserver.port=8083spring.datasource.url=jdbc:mysql://****:3306/seata?useSSL=false&serverTimezone=UTCspring.datasource.username=***spring.datasource.password=***spring.cloud.alibaba.seata.tx-service-group=my_test_tx_grouplogging.level.io.seata=infologging.level.io.seata.samples.account.persistence.AccountMapper=debug

Note that the db configuration in seata-server is configured to store information related to seata transactions. The database configuration here is the business database of the business system. In the official example, the seata transaction library and the business database are merged into one, and separation is recommended in the actual business.

Other items are analogous in turn

Step 4: execute the sql file:

Execute SQL statements in the SQL file to create databases and tables

Step 4: start the project:

(1) start seata-server:

Open the Server class of the seata-server project, run the main method of the class, and start the project:

After the startup is successful, the following log will be typed on the console:

2019-09-26 15 io.seata.common.loader.EnhancedServiceLoader.loadFile:237 37 FILE 27.711 INFO [main] io.seata.common.loader.EnhancedServiceLoader.loadFile:237-load TransactionStoreManager [FILE] extension by class [io.seata.server.store.file.FileTransactionStoreManager] 2019-09-26 15 15 INFO 27.713 INFO [main] io.seata.common.loader.EnhancedServiceLoader.loadFile:237-load SessionManager [FILE] extension by class [io.seata.server.session.file.FileBasedSessionManager] 2019-09-26 1515 INFO 37 INFO [main] io. Seata.core.rpc.netty.AbstractRpcRemotingServer.start:156-Server started...

(2) start each business sub-project in the springboot-mybayis project, and take the sbm-account-service project as an example:

Open the SpringbootMybatisAccountApplication class, run the class's main method, and start the project

After the project starts successfully, print the following log:

2019-09-26 15 INFO 48 o.s.b.w.embedded.tomcat.TomcatWebServer 14.466 INFO 16220-main] o.s.b.w.embedded.tomcat.TomcatWebServer: Tomcat started on port (s): 8083 (http) with context path '2019-09-26 15 15 14. 469 INFO 16220-- [main] .s.a.SpringbootMybatisAccountApplication: Started SpringbootMybatisAccountApplication in 2.961 seconds (JVM running for 3.605) 2019-09-26 1515 48 INFO 16220-- [imeoutChecker_1] I .s.c.r.netty.NettyClientChannelManager: will connect to 127.0.0.1 imeoutChecker_1 80912019-09-26 1515 i.s.core.rpc.netty.NettyPoolableFactory 48purl 17.823 INFO 16220-[NettyClientChannelManager] Address:127.0.0.1:8091,msg:

< RegisterTMRequest{applicationId='account-service', transactionServiceGroup='my_test_tx_group'} >

2019-09-26 15 INFO 48 INFO 17.846 16220-[imeoutChecker_1] i.s.core.rpc.netty.NettyPoolableFactory: register success, cost 17 ms, version:0.8.1,role:TMROLE,channel: [id: 0x02230a52

After sbm-account-service starts successfully, it registers in seata-server. After successful registration, the following log is printed under the seata-server service:

/ / todo

2019-09-26 15 load Codec 51R 32.050 INFO [NettyServerNIOWorker_1_8] io.seata.common.loader.EnhancedServiceLoader.loadFile:237-load Codec [SEATA] extension by class [io.seata.codec.seata.SeataCodec] 2019-09-261515V 51R 32.068 INFO [ServerHandlerThread_1_500] io.seata.core.rpc.DefaultServerMessageListenerImpl.onRegRmMessage:114-rm register success,message:RegisterRMRequest {resourceIds='jdbc:mysql://***:3306/seata', applicationId='account-service', transactionServiceGroup='my_test_tx_group'} Channel: [id: 0x5efef77e, Lorex 127.0.0.1 0x5efef77e INFO [NettyServerNIOWorker_2_8] io.seata.core.rpc.DefaultServerMessageListenerImpl.onRegTmMessage:131-checkAuth for client:127.0.0.1:60698 vgroup:my_test_tx_group ok

So far, the sbm-account-service project has been launched successfully.

After that, start the remaining projects in turn: each project startup class is as follows:

Sbm-business-service: SpringbootMybatisBusinessApplication

Sbm-order-service: SpringbootMybatisOrderApplication

Sbm-storage-service:SpringbootMybatisStorageApplication

The above is how to quickly deploy a seata project, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report