In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to use nacos to achieve distributed transactions in seata. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
1. Documents that need to be prepared
1) nacos1.3.2
Download address:
Https://github.com/alibaba/nacos/releases
2) seata1.3.0:
Download address:
Https://github.com/seata/seata/releases
3) seata database initialization script (seata needs to be downloaded separately after version 0.9)
Download address:
Https://github.com/seata/seata/tree/develop/script/server/db, I use the mysql database here. Download mysql.sql here.
4) seata configuration file 1:config.txt (seata needs to be downloaded separately after version 0.9)
Download address:
Https://github.com/seata/seata/tree/develop/script/config-center
5) seata configuration file 2:nacos-config.sh (seata needs to be downloaded separately after version 0.9)
Download address:
Https://github.com/seata/seata/tree/develop/script/config-center/nacos
6) seata transaction table undo_log, the database corresponding to each microservice of the distributed transaction, there must be a undo_log table, which
I can't use it for the time being. I'll use it in the next article.
Download address: (select mysql.sql)
Https://github.com/seata/seata/tree/develop/script/client/at/db
2.nacos1.3.2 installation (win10 environment)
1) decompress the nacos-server-1.3.2.zip download. After decompression, the directory structure is as follows:
2) by default, nacos has a built-in deby database, which is changed to mysql. The data is persisted to the mysql database, and the application.properties file under conf is modified, as shown below:
3) the name of the database here is nacos_config. Execute the schema.sql file under conf to initialize the nacos database. After execution, there are several tables, as shown below:
4) default cluster mode when nacos starts. Here, I modify the startup.cmd file in the bin directory to make it standalone mode by default, as shown in the following figure:
5) execute startup.cmd to start nacos. The default port is 8848, and the default login user: nacos, password: nacos. You can see the following interface, which indicates that nacos is installed successfully:
3.seata1.3.0 installation (win10 environment)
1) decompress the seata-server-1.3.0.zip download. After decompression, the directory structure is as follows:
2) here, we persist the seata data to mysql, and execute the mysql.sql script downloaded above to create a new seata database to produce three tables, as shown below:
3) modify the registry.conf file in the conf directory, and change the backend storage to mysql database:
4) modify the file.conf file in the conf directory and register the seata in nacos:
Here I have sorted out a template that details the meaning of each configuration item:
# registry registry {# file, nacos, eureka, redis, zk, consul, etcd3, sofa # if it is file, you need to configure file.conf # because this example uses nacos, here fill in nacos type = "nacos" # [important] here is the service registration configuration in nacos nacos {# [important] the microservice name of this server in nacos Later, the application.yml of the seata client will use the application = "serverAddr" # nacos address (default is 8848, and the port has been changed by the load balancer here) serverAddr = "127.0.0.1 nacos 8848" # seata- server microservice packet group = "SEATA_GROUP" # seata- server microservice namespace, omitted here Use the default value public namespace = "" # [important] seata-server as the cluster name, which is consistent with the transaction grouping attribute (service.vgroupMapping.my_test_tx_group) set in the previous nacos. Cluster = "default" # nacos1.2 adds authentication. Account password cannot be omitted username = "nacos" password = "nacos"}} # configuration Center config {# file, nacos, apollo, zk, consul, etcd3 # because nacos is used in this example, fill in nacos type = "nacos" nacos {serverAddr = "127.0.0.1config 8848" namespace = "" # [important] which group is the configuration of this server under nacos configuration list? To be consistent with the list of groups pushed to nacos above, the default is SEATA_GROUP. Group = "SEATA_GROUP" username = "nacos" password = "nacos"}}
5) next, import the configuration into nacos through script, place config.txt in the root directory and nacos-config.sh in the conf directory, as shown in the following figure:
Perform a nacos-config.sh through git bash to import the configuration into nacos:
After successful execution, you can see the seata configuration information in nacos, and some errors such as redis may be reported during execution. Since we only use nacos, we can simply ignore it, as shown in the following figure:
6) enter the bin directory and execute seata-server.bat to start seata-server. After starting successfully, you can see the following service information in nacos:
After reading the above, do you have any further understanding of how to use nacos to implement distributed transactions in seata? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.