标签:cluster form window com sea ranch des 下载 org
下载Seata服务端包:https://github.com/seata/seata/releases;本例使用seata-1.4.0。
下载nacos服务端包:https://github.com/alibaba/nacos/releases;本例使用nacos-1.4.0。
(Window环境需要python环境,下载安装配置Python环境:https://www.python.org)。
Seata解压,找到对应的conf文件夹
本例使用db模式,因此可以删除file.conf文件;
打开文件README-zh.md,可以找到 server所需SQL和部署脚本地址 (https://github.com/seata/seata/tree/develop/script/server);
将 config.txt 和 nacos-config.py 拷贝到conf 文件夹下;
新建数据库 seata , 将 SQL脚本导入执行,会生成三张表:global_table、branch_table、lock_table;
修改 registry.conf 配置文件:本例使用nacos,所以只保留 nacos 配置即可,需注意 namespace。
registry { # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa type = "nacos" loadBalance = "RandomLoadBalance" loadBalanceVirtualNodes = 10 nacos { application = "seata-server" serverAddr = "127.0.0.1:8848" group = "DEFAULT_GROUP" namespace = "1344cd38-7919-4482-9c6f-11d73ab865b2" cluster = "default" username = "" password = "" } } config { # file、nacos 、apollo、zk、consul、etcd3 type = "nacos" nacos { serverAddr = "127.0.0.1:8848" namespace = "1344cd38-7919-4482-9c6f-11d73ab865b2" group = "DEFAULT_GROUP" username = "" password = "" } }
修改 config.txt 配置文件:
...忽略 service.vgroupMapping.my_test_tx_group=default #seata客户端事务组名称 service.default.grouplist=127.0.0.1:8099 ...忽略 store.mode=db #修改成db模式 store.db.datasource=druid store.db.dbType=mysql store.db.driverClassName=com.mysql.jdbc.Driver store.db.url=jdbc:mysql://localhost:3306/seata?useUnicode=true&rewriteBatchedStatements=true store.db.user=root store.db.password=root ...忽略
修改 nacos-config.py 配置文件:
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- import http.client import sys if len(sys.argv) <= 2: print (‘python nacos-config.py nacosAddr‘) exit() headers = { ‘content-type‘: "application/x-www-form-urlencoded" }
# 将“../config.txt”需要改为“./config.txt”,因为 nacos-config.py和 config.txt在同目录 hasError = False for line in open(‘./config.txt‘): pair = line.split(‘=‘) if len(pair) < 2: continue print (line), url_prefix = sys.argv[1] conn = http.client.HTTPConnection(url_prefix) if len(sys.argv) == 3: namespace=sys.argv[2] url_postfix = ‘/nacos/v1/cs/configs?dataId={0}&group=SEATA_GROUP&content={1}&tenant={2}‘.format(str(pair[0]),str(line[line.index(‘=‘)+1:]).strip(),namespace) else: url_postfix = ‘/nacos/v1/cs/configs?dataId={}&group=SEATA_GROUP&content={}‘.format(str(pair[0]),str(line[line.index(‘=‘)+1:])).strip() conn.request("POST", url_postfix, headers=headers) res = conn.getresponse() data = res.read() if data.decode("utf-8") != "true": hasError = True if hasError: print ("init nacos config fail.") else: print ("init nacos config finished, please start seata-server.")
将seata配置推送到nacos:
切换到 Seata 的conf目录,执行命令: python nacos-config.py nacos服务地址 命名空间
例:python nacos-config.py 127.0.0.1:8848 1344cd38-7919-4482-9c6f-11d73ab865b2
切换到 Seata 的 bin 目录,执行命令:sh seata-server.sh
完成。
标签:cluster form window com sea ranch des 下载 org
原文地址:https://www.cnblogs.com/lucky-yqy/p/14190205.html