seata1.4安装与配置
1. 下载:
解压,注意看下⾥⾯有个README-zh.md,相关的⼀些脚本可以在这个⽂件的链接到,因为不同的seata版本,脚本可能有差异,需要注意下。我这⾥把1.4.0的这个⽂件内容补充在下⾯:
脚本说明
存放⽤于客户端的配置和SQL
at: AT模式下的 undo_log 建表语句
conf: 客户端的配置⽂件
saga: SAGA 模式下所需表的建表语句
spring: SpringBoot 应⽤⽀持的配置⽂件
存放server侧所需SQL和部署脚本
db: server 侧的保存模式为 db 时所需表的建表语句
docker-compose: server 侧通过 docker-compose 部署的脚本
helm: server 侧通过 Helm 部署的脚本
kubernetes: server 侧通过 Kubernetes 部署的脚本
⽤于存放各种配置中⼼的初始化脚本,执⾏时都会读取 配置⽂件,并写⼊配置中⼼
nacos: ⽤于向 Nacos 中添加配置
zk: ⽤于向 Zookeeper 中添加配置,脚本依赖 Zookeeper 的相关脚本,需要⼿动下载;ZooKeeper相关的配置可以写在 中,也可以在执⾏的时候输⼊
apollo: 向 Apollo 中添加配置,Apollo 的地址端⼝等可以写在 ,也可以在执⾏的时候输⼊
etcd3: ⽤于向 Etcd3 中添加配置
consul: ⽤于向 consul 中添加配置
这⾥我把undo_log的脚本贴在下⾯:
-- for AT mode you must to init this sql for you business database. the seata server not need it.
CREATE TABLE IF NOT EXISTS `undo_log`
(
`branch_id`    BIGINT(20)  NOT NULL COMMENT 'branch transaction id',
`xid`          VARCHAR(100) NOT NULL COMMENT 'global transaction id',
`context`      VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
`rollback_info` LONGBLOB    NOT NULL COMMENT 'rollback info',
`log_status`    INT(11)      NOT NULL COMMENT '0:normal status,1:defense status',
`log_created`  DATETIME(6)  NOT NULL COMMENT 'create datetime',
`log_modified`  DATETIME(6)  NOT NULL COMMENT 'modify datetime',
UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
)
ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8 COMMENT ='AT transaction mode undo table';
2. 修改f的注册中⼼和配置中⼼为nacos
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 = "SEATA_GROUP"
namespace = ""
cluster = "default"
username = ""
password = ""
}
eureka {
serviceUrl = "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 = "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 = "f"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "nacos"
nacos {
serverAddr = "127.0.0.1:8848"
namespace = ""
group = "SEATA_GROUP"
username = ""
password = ""
}
consul {
serverAddr = "127.0.0.1:8500"
}
apollo {
appId = "seata-server"
apolloMeta = "192.168.1.204:8801"
namespace = "application"
apolloAccesskeySecret = ""
}
zk {
serverAddr = "127.0.0.1:2181"
sessionTimeout = 6000
connectTimeout = 2000
username = ""
password = ""
}
etcd3 {
serverAddr = "localhost:2379"
}
file {
name = "f"
}
}
3. 配置好之后,启动seata
# nohup sh seata-server.sh -p 8091 -h 127.0.0.1 -m file > seata.log &
-p 指定启动seata server的端⼝号。
-h 指定seata server所绑定的主机。
-m 事务⽇志、事务执⾏信息存储的⽅式,⽬前⽀持file(⽂件⽅式)、db(数据库⽅式,建表语句请查看config/db_store.sql、config/db_undo_log.sql)
这⾥如果是公⽹连接seata的话,需要将127.0.0.1换成公⽹IP。
启动之后可以在nacos的控制台上看到注册的服务:
补充⼏点:
mysql下载完如何使用
1. 如果你的seata使⽤的模式是db模式,
请注意,像使⽤云主机的话,数据库的连接名类似如下:
jdbc:mysql://sql.zhangbei.rds.aliyuncs:3306/ry-cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior =convertToNull&useSSL=true&serverTimezone=GMT%2B8
否则的话,启动会报错。
启动⽅式改为-m db,具体如下:
# nohup sh seata-server.sh -p 8091 -h 106.13.210.114 -m db > seata.log &
当然这样会报错,在这之前咱们需要将seata的配置导⼊到nacos中:
进⼊seata/conf⽬录下,创建⼀个nacos-config.sh⽂件:
# touch nacos-config.sh
然后到seata⽬录创建,注意跟nacos-config.sh不在同⼀个⽬录
#
将如下内容写⼊:
_test_tx_group=default
uplist=127.0.0.1:8091
service.disableGlobalTransaction=false
store.db.datasource=druid
store.db.dbType=mysql
store.db.sql.jdbc.Driver
store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true
store.db.user=username
store.db.password=password
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
最后再执⾏导⼊:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。