quantyu-geological-big-data-cloud-platform

服务模块部署过程说明

(以quanty-cloud-service-geohazard服务模块为例)
1.在项目resources文件夹下新建bootstrap.yaml文件

在配置文件中写入

spring:
  profiles:
    active: dev
  application:
    name: quanty-cloud-service-geohazard  #需要修改为本服务的服务名
  cloud:
    nacos:
      config:
        server-addr: 192.168.7.16:8848  #nacos的地址
        file-extension: yaml

这一步的目的是让这个微服务模块优先从nacos配置中心去加载配置文件

2.在nacos配置中心新建该服务的配置,Data id的命名规则为服务名-${spring.profiles.active}.yaml,yaml不可简写为yml,选择默认分组。
在这里插入图片描述
在配置类容中加入配置,项目运行时会加载此配置:

spring:
  servlet:
    multipart:
      enabled: true
      file-size-threshold: 0
      max-file-size: 1000000000000000
      max-request-size: 100000000000000
  application:
    # 名字修改为你的moudle名
    name: quanty-cloud-service-geohazard
    #这里修改数据库连接信息,修改url username password 数据库是5.x版本 driver-class-name 去掉中间的cj
  zipkin:
    base-url: http://192.168.7.16:9411
    enabled: true
  datasource:
    druid:
      url: jdbc:mysql://192.168.7.16:3306/jcsjk?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
      username: root
      password: aBc123456_
      initial-size: 1
      min-idle: 1
      max-active: 20
      test-on-borrow: true
      # MySQL 8.x: com.mysql.cj.jdbc.Driver
      driver-class-name: com.mysql.cj.jdbc.Driver
  cloud:
    nacos:
      discovery:
        server-addr: 192.168.7.16:8848
    sentinel:
      transport:
        dashboard: 192.168.7.16:8858
        #默认8719,假如被占用从之后一直找
        port:
          8719
# 服务器端口修改,因为会有冲突,每个人可以选定一个区间,比如8200,8201 ,8300,8301这种,不要使用80,这种系统常用的端口
server:
  port: 8801
# 修改成你的包名
mybatis:
  type-aliases-package: com.quanty.cloud.service.demo
  mapper-locations: classpath:mapper/*.xml

management:
  endpoints:
    web:
      exposure:
        include: '*'
  health:
    redis:
      enabled: false
  endpoint:
    health:
      show-details: always

#设置控制台打印sql执行语句,改成你的mapper文件路径
logging:
  level:
    com:
      quanty:
        cloud:
          service:
            demo:
              mapper:
                debug

3.项目打包
在在整个项目的父工程quantyu-geological-big-data-cloud-platform的文件夹下,执行命令:mvn clean package -Dmaven.test.skip=true
在这里插入图片描述
项目打包成功:
在这里插入图片描述
4.构建docker镜像
将生成的jar包复制到Linux服务器中
在这里插入图片描述
在/root/quanty-cloud-code/zengbin-quanty-cloud-jarToImages路径下新建一个quanty-cloud-service-geohazard文件夹,用于存放jar文件
在这里插入图片描述
将jar文件复制到给文件夹中
在这里插入图片描述
在该文件夹中新建一个DockerFile文件,要保证Dockerfile文件与jar包在同一文件夹下
在这里插入图片描述
在这里插入图片描述
在Dockerfile文件中写入

FROM openjdk:8-jre 
MAINTAINER zengbin<1252324263@qq.com> 
RUN mkdir /app  
COPY quanty-cloud-service-geohazard-1.0.0-SNAPSHOT.jar /app/app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/app.jar"]
EXPOSE 8001

构建镜像

docker build -t zengbin/quanty-cloud-service-geohazard .

别忘了最后有一个点

构建镜像成功
在这里插入图片描述提交镜像到仓库

docker push zengbin/quanty-cloud-service-geohazard

4.由于docekr直接run的命令不适合服务太多的情况。所以使用docker-compose
工具进行容器编排
打开/root/quanty-cloud-code/quanty-cloud-docker-compose-file文件夹,修改quanty-cloud-service-all.yaml文件
在这里插入图片描述
在文件中加入

  quanty-cloud-service-geohazard:
    restart: always
    image: zengbin/quanty-cloud-service-geohazard
    container_name: quanty-cloud-service-geohazard
    deploy:
      resources:
        limits:
          memory: 512M
    ports:
      - 8801:8801

5.启动顺序

->quanty‐cloud‐infrastructure
‐>quanty‐cloud‐service‐all
‐>quanty‐cloud‐gateway

启动命令

docker‐compose ‐f quanty‐cloud‐infrastructure.yaml up ‐d
docker‐compose ‐f quanty‐cloud‐service‐all.yaml up ‐d
docker‐compose ‐f quanty‐cloud‐gateway.yaml up ‐d

停止容器并销毁命令

docker‐compose ‐f quanty‐cloud‐infrastructure.yaml down
docker‐compose ‐f quanty‐cloud‐service‐all.yaml down
docker‐compose ‐f quanty‐cloud‐gateway.yaml down

6.常用docker命令

https://www.runoob.com/docker/docker-command-manual.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值