docker 运行 seata-server 配置nacos

1、拉取镜像

docker pull seataio/seata-server

2、运行镜像

docker run --name seata-server -p 8091:8091 -d  seataio/seata-server

3、复制配置文件到主机

docker cp seata-server:/seata-server  /home/docker/seata

4、停止服务

docker stop seata-server

5、删除服务

docker rm seata-server

6、重新运行服务,至此服务已经启动完成,接下来就是在/home/docker/seata/seata-server目录中修改对应的配置(设置开机自启和关键配置挂载到本地目录方便修改配置)

docker run -d --restart always  --name  seata-server -p 8091:8091  -v /home/docker/seata/seata-server:/seata-server -e SEATA_IP=172.168.1.35 -e SEATA_PORT=8091 seataio/seata-server

7、切换到seata配置目录

cd /home/docker/seata/resources

8、修改registry.conf文件,修为nacos启用方式,绿色字体为修改的关键地方

registry {
  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
 type = "nacos" 
  nacos {
    application = "seata-server" serverAddr = "172.168.1.35:8848"
    namespace = "" cluster = "default" username = "" 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 = "172.168.1.35:8848"
    namespace = "89f54c6f-3b21-46a4-bd1b-242ae159c12e"
    group = "DEFAULT_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 {
    name = "file.conf" }
}

seata客户端需要执行,sql文件路径:https://github.com/seata/seata/tree/develop/script/client
seata服务端需要执行,sql文件路径:https://github.com/seata/seata/tree/develop/script/server
不用的模式执行不同的脚本,具体的注意点查看/home/docker/seata/README-zh.md

9、修改file.conf配置文件存储方式为mysql

store {
  ## store mode: file、db
 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) 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?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai"
    user = "root"
    password = "root" minConn = 5 maxConn = 30 globalTable = "global_table" branchTable = "branch_table" lockTable = "lock_table" queryLimit = 100 maxWait = 5000 }
}

10、重启服务

docker restart seata-server
#查看启动日志
docker logs seata-server

11、可以登录nacos查看服务列表,就会发现seata-server已经注册上来了

你可能感兴趣的:(docker 运行 seata-server 配置nacos)