docker安装seata
1、下载镜像
docker pull seata:1.3.0
2、配置文件
registry.conf
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
# 默认为file 这里我是使用nacos为注册中心
type = "nacos"
nacos {
application = "seata-server"
# nacos的地址
serverAddr = "127.0.0.1:8848"
group = "SEATA_GROUP"
namespace = ""
cluster = "default"
# 登入nacos的用户名
username = ""
# 登入nacos的密码
password = ""
}
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 = "file"
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 = "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 {
# 配置file.conf的文件路径
name = "file:/root/seata-config/file.conf"
}
}
file.conf
## 事务日志存储,仅在seata服务器中使用
store {
## store mode: file、db、redis
mode = "db"
## file store property
file {
## store location dir
dir = "sessionStore"
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
maxBranchSessionSize = 16384
# globe session size , if exceeded throws exceptions
maxGlobalSessionSize = 512
# file buffer size , if exceeded allocate new buffer
fileWriteBufferCacheSize = 16384
# when recover batch read size
sessionReloadReadSize = 100
# async, sync
flushDiskMode = async
}
## database store property
db {
## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
datasource = "druid"
## mysql/oracle/postgresql/h2/oceanbase etc.
dbType = "mysql"
driverClassName = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://127.0.0.1:3306/seata"
user = "mysql"
password = "mysql"
minConn = 5
maxConn = 30
globalTable = "global_table"
branchTable = "branch_table"
lockTable = "lock_table"
queryLimit = 100
maxWait = 5000
}
## redis store property
redis {
host = "127.0.0.1"
port = "6379"
password = ""
database = "0"
minConn = 1
maxConn = 10
queryLimit = 100
}
}
3、添加配置文件
#创建文件夹,将上面的两个配置文件放在 /mydata/seata/conf 下面
mkdir -p /mydata/seata/conf
mkdir -p /mydata/seata/logs
4、创建容器
docker run -d -p 8091:8091 \
-v /mydata/seata/conf/registry.conf:/seata-server/resources/registry.conf \
-v /mydata/seata/conf/file.conf:/seata-server/resources/file.conf \
-v /mydata/seata/logs:/root/logs \
-e SEATA_IP=27.150.***.** \
-e SEATA_PORT=8091 \
--restart=always \
--name seata seataio/seata-server:1.3.0
5、参数说明
名称 | 描述 | 选项 |
---|---|---|
SEATA_IP | 指定seata-server启动的IP, 该IP用于向注册中心注册时使用, 如eureka等 | |
SEATA_PORT | 指定seata-server启动的端口 | 可选, 默认为 8091 |
STORE_MODE | 指定seata-server的事务日志存储方式 | 可选, 支持db ,file,redis(Seata-Server 1.3及以上版本支持), 默认是 file |
SERVER_NODE | 用于指定seata-server节点ID | 可选, 如 1,2,3…, 默认为 根据ip生成 |
SEATA_ENV | 指定 seata-server 运行环境, | 可选,如 dev, test 等, 服务启动时会使用 registry-dev.conf 这样的配置 |
SEATA_CONFIG_NAME | 指定配置文件位置, | 可选,如 file:/root/registry, 将会加载 /root/registry.conf 作为配置文件,如果需要同时指定 file.conf文件,需要将registry.conf的config.file.name的值改为类似file:/root/file.conf: |