DOCKER安装SEATA注册到NACOS
因为总是多多少少的会出现问题,所以我自行搭建成功,跳过所有坑之后写了个博客,此处没有使用集群
说明:请创建对应seata所需的数据库,将seata源码中的sql执行进去
1、使用最新的seata和nacos以及mysql5.7版本,基于centos7.4
1
|
docker pull seataio/seata-server |
2、增加配置文件file.conf和registry.conf,内容如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
## transaction log store, only used in seata-server store { ## store mode: file、db、redis mode = "db" ## database store property db { ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc. datasource = "druid" dbType = "mysql" driverClassName = "com.mysql.cj.jdbc.Driver" url = "jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai" user = "root" password = "123456" minConn = 5 maxConn = 100 globalTable = "global_table" branchTable = "branch_table" lockTable = "lock_table" queryLimit = 100 maxWait = 5000 } } |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
registry { # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa type = "nacos" nacos { application = "seata-server" serverAddr = "192.168.0.1:8848" namespace = "" cluster = "luim-tx-group" username = "nacos" password = "nacos" } eureka { serviceUrl = "http://localhost:8761/eureka" application = "default" weight = "1" } redis { serverAddr = "localhost:6379" db = 0 password = "" cluster = "default" timeout = 0 } zk { cluster = "default" serverAddr = "127.0.0.1:2181" sessionTimeout = 6000 connectTimeout = 2000 username = "" password = "" } consul { cluster = "default" serverAddr = "127.0.0.1:8500" } etcd3 { cluster = "default" serverAddr = "http://localhost:2379" } sofa { serverAddr = "127.0.0.1:9603" application = "default" region = "DEFAULT_ZONE" datacenter = "DefaultDataCenter" cluster = "default" group = "SEATA_GROUP" addressWaitTime = "3000" } file { name = "file.conf" } } config { # file、nacos 、apollo、zk、consul、etcd3 type = "nacos" nacos { serverAddr = "192.168.0.1:8848" namespace = "" group = "SEATA_GROUP" username = "nacos" password = "nacos" } consul { serverAddr = "127.0.0.1:8500" } apollo { appId = "seata-server" apolloMeta = "http://192.168.1.204:8801" namespace = "application" } zk { serverAddr = "127.0.0.1:2181" sessionTimeout = 6000 connectTimeout = 2000 username = "" password = "" } etcd3 { serverAddr = "http://localhost:2379" } file { name = "file.conf" } } |
3、启动seata
1
2
3
4
5
6
7
|
docker run --name seata -d \ -e SEATA_PORT=8091 \ -v /opt/seata/conf/registry.conf:/seata-server/resources/registry.conf \ -v /opt/seata/logs:/root/logs \ --privileged= true \ -p 8091:8091 \ seataio/seata-server |
目前已经可以在nacos中查看到了
如果你想要将配置文件配置到nacos上的话那就继续看
1、首先去github上下载seata的源码放服务器上
2、进入script/conf-center,修改conf.txt的配置,我把我的粘贴出来,期中遇到了nacos初始化错误的问题,不能有空的,要不不传要不不能为空,屏蔽也不可以
注意这个参数service.vgroupMapping.my_test_tx_group=default,需要和yml文件中的格式一样,尤其是vgroupMapping
yml配置文件中不要配置seata.config和seata.register
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
transport.type=TCP transport.server=NIO transport.heartbeat= true transport.enableClientBatchSendRequest= false transport.threadFactory.bossThreadPrefix=NettyBoss transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler transport.threadFactory.shareBossWorker= false transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector transport.threadFactory.clientSelectorThreadSize=1 transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread transport.threadFactory.bossThreadSize=1 transport.threadFactory.workerThreadSize= default transport.shutdown.wait=3 service.vgroupMapping.my_test_tx_group= default service. default .grouplist=127.0.0.1:8091 service.enableDegrade= false service.disableGlobalTransaction= false client.rm.asyncCommitBufferLimit=10000 client.rm. lock .retryInterval=10 client.rm. lock .retryTimes=30 client.rm. lock .retryPolicyBranchRollbackOnConflict= true client.rm.reportRetryCount=5 client.rm.tableMetaCheckEnable= false client.rm.tableMetaCheckerInterval=60000 client.rm.sqlParserType=druid client.rm.reportSuccessEnable= false client.rm.sagaBranchRegisterEnable= false client.tm.commitRetryCount=5 client.tm.rollbackRetryCount=5 client.tm.defaultGlobalTransactionTimeout=60000 client.tm.degradeCheck= false client.tm.degradeCheckAllowTimes=10 client.tm.degradeCheckPeriod=2000 store. lock .mode=file store.session.mode=file store.publicKey=1 store.file.dir=file_store/data store.file.maxBranchSessionSize=16384 store.file.maxGlobalSessionSize=512 store.file.fileWriteBufferCacheSize=16384 store.file.flushDiskMode=async store.file.sessionReloadReadSize=100 store.db.datasource=druid store.db.dbType=mysql store.db.driverClassName=com.mysql.jdbc.Driver store.db.url=jdbc:mysql: //ip:3306/seata?useUnicode=true&rewriteBatchedStatements=true store.db.user=root store.db.password=123456 store.db.minConn=5 store.db.maxConn=30 store.db.globalTable=global_table store.db.branchTable=branch_table store.db.queryLimit=100 store.db.lockTable=lock_table store.db.maxWait=5000 store.redis.mode=single store.redis.single.host=127.0.0.1 store.redis.single.port=6379 store.redis.sentinel.masterName=master store.redis.sentinel.sentinelHosts=127.0.0.1 store.redis.maxConn=10 store.redis.minConn=1 store.redis.maxTotal=100 store.redis.database=0 store.redis.password=redis store.redis.queryLimit=100 server.recovery.committingRetryPeriod=1000 server.recovery.asynCommittingRetryPeriod=1000 server.recovery.rollbackingRetryPeriod=1000 server.recovery.timeoutRetryPeriod=1000 server.maxCommitRetryTimeout=-1 server.maxRollbackRetryTimeout=-1 server.rollbackRetryTimeoutUnlockEnable= false client.undo.dataValidation= true client.undo.logSerialization=jackson client.undo.onlyCareUpdateColumns= true server.undo.logSaveDays=7 server.undo.logDeletePeriod=86400000 client.undo.logTable=undo_log client.undo.compress.enable= true client.undo.compress.type=zip client.undo.compress.threshold=64k log.exceptionRate=100 transport.serialization=seata transport.compressor=none metrics.enabled= false metrics.registryType=compact metrics.exporterList=prometheus metrics.exporterPrometheusPort=9898 |
2、在nacos网站上创建命名空间
将命名空间id记录下来,下面需要使用
2、然后进入nacos路径执行以下命令
1
|
sh nacos-config.sh -h ip -p 8848 -g SEATA_GROUP -t 命名空间id |
sh nacos-config.sh
-h 172.16.9.48 配置中心的ip
-p 8848 配置中心的端口
-g SEATA_GROUP group名字
-t 55730921-9411-4004-973c-156f01c31c1b 命名空间的id,就是前面创建之后的id
3、执行成功之后就可以在nacos上看到配置信息了
4、重启seata
1
|
docker restart seata |