当前位置:网站首页>Establishment and operation of cloud platform open source project environment

Establishment and operation of cloud platform open source project environment

2022-07-06 06:57:00 chengqiuming

One   Project location

Cloud-Platform: The first one in China Spring Cloud Micro service RBAC Management platform , Core adoption Spring Boot 2.4、Spring Cloud 2020.0.0 & Alibaba, The front end uses d2-admin Middle stage frame . Remember to order one above star Follow updates icon-default.png?t=M0H8https://gitee.com/geek_qi/cloud-platform

edition :v2.7

Two   Project information

dev-doc.md · Jiang Li /Cloud-Platform - Gitee.comicon-default.png?t=M0H8https://gitee.com/geek_qi/cloud-platform/blob/master/dev-doc.md

3、 ... and   Correspondence between front and back ends

Source location

https://gitee.com/geek_qiicon-default.png?t=M0H8https://gitee.com/geek_qi/cloud-platform

Because it involves the first and second generation projects , It's easy to get the version relationship wrong , Here, let's sort out the version correspondence .

Version Description

front end

Back end

stability

first generation

project :Cloud-Platform-UI

Branch :master

project :Cloud-Platform

Branch :v2.7

The final version of the first generation

Second generation

project :Cloud-Platform-UI-v2

Branch :dev

project :Cloud-Platform

Branch :master

The latest version under development

This article introduces the first generation .

Four   Project introduction

1  Project brief introduction

Cloud-Platform It is the first one in China based on Spring Cloud Microservice service development platform , With unified authorization 、 Authentication background management system , Including user management 、 Resource rights management 、 gateway API Management and other modules , Support parallel development of multi service system , Development scaffolding that can be used as back-end services .

The code is concise , Clear architecture , Suitable for use in learning and direct projects . 

Core technology adoption Spring Boot 2.1.2 as well as Spring Cloud (Greenwich.RELEASE)  Related core components , use Nacos Registration and configuration center , Integrated traffic guard Sentinel, The front end uses vue-element-admin Components ,Elastic Search Self Integration .

2  Technology selection

  • front end :vue-element-admin
  • Back end :springcloud(gateway、admin、sidecar、Hystrix、feign、ribbon、zipkin)、tk+mybatis、lucene、jwt、rest、Nacos

3  Project structure

ace-security

  ace-modules-------------- Public service module ( Based system 、 Search for 、OSS、 Business module )

  ace-auth----------------- Service Authentication Center

  ace-gate----------------- Gateway load center

  ace-common--------------- General purpose scaffolding ( All kinds of tools )

  ace-control-------------- Operation and maintenance center ( monitor 、 link 、 Registry Center )

  ace-sidebar-------------- Call a third-party language service   

4  front end

4.1 Download location

Cloud-Platform-UI: Cloud-Platform It is the first one in China based on Spring Cloud Microservice service development platform , With unified authorization 、 Authentication background management system , Including user management 、 Resource rights management 、 gateway API Management and other modules , Support parallel development of multi service system , Development scaffolding that can be used as back-end services . The code is concise , Clear architecture , Suitable for use in learning and direct projects . Core technology adoption Eureka、Fegin、Ribbon、Zuul、Hystrix、JWT Token、Mybatis Such as the main framework and middleware , The front end uses vue-element-admin Components .icon-default.png?t=M0H8https://gitee.com/geek_qi/cloud-platform-ui

4.2  Start and run

# 1 Installation of Taobao image depends on

npm install -g cnpm --registry=https://registry.npm.taobao.org

# 2 Installation project dependency

cnpm install

# 3 Start the service

npm run dev

After successful startup, the link will be opened automatically :http://localhost:9527/

5、 ... and   Construction and operation of development environment

1  use Idea  Open the project

The relationship between the primary module and the secondary module is as follows

2  Import data into database

Import 3 A database

3  Start in turn  nacos  and  redis

4 AuthBootstrap  Start of

4.1 To configure  AuthBootstrap  Configuration file for

Start with simplicity , Configure more complex functions later

spring:
    application:
        name: ace-auth
    jackson:
        date-format: yyyy-MM-dd HH:mm:ss
        time-zone: GMT+8
        default-property-inclusion: non_null
    redis:
        database: 2
        host: ${REDIS_HOST:localhost}
        port: ${REDIS_PORT:6379}
        pool:
        max-active: 20
    datasource:
      name: test
      url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/ag_auth_v1?useUnicode=true&characterEncoding=UTF8&useSSL=false&serverTimezone=UTC
      username: root
      password: Mima123456
      #  Use druid data source 
      type: com.alibaba.druid.pool.DruidDataSource
      driver-class-name: com.mysql.jdbc.Driver
      filters: stat
      maxActive: 20
      initialSize: 1
      maxWait: 60000
      minIdle: 1
      timeBetweenEvictionRunsMillis: 60000
      minEvictableIdleTimeMillis: 300000
      validationQuery: select 'x'
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      poolPreparedStatements: true
      maxOpenPreparedStatements: 20
    cloud:
      nacos:
        discovery:
            server-addr: 127.0.0.1:8848
mybatis:
    basepackage: com.github.wxiaoqi.security.auth.mapper
    xmlLocation: classpath:mapper/**/*.xml
    mapper-locations: "classpath*:mapper/*.xml"

server:
    port: 9777 # Start port 

feign:
  httpclient:
    enabled: false
  okhttp:
    enabled: true

ribbon:
  eureka:
    enabled: true
  ReadTimeout: 60000
  ConnectTimeout: 60000
  MaxAutoRetries: 0
  MaxAutoRetriesNextServer: 1
  OkToRetryOnAllOperations: false

hystrix:
  threadpool:
    default:
      coreSize: 1000 ## The maximum number of concurrent threads , Default 10
      maxQueueSize: 1000 ##BlockingQueue The maximum number of queues 
      queueSizeRejectionThreshold: 500 ## Even if maxQueueSize Don't reach , achieve queueSizeRejectionThreshold After this value , Requests will also be rejected 
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 10000

jwt:
  token-header: Authorization
  expire: 14400
  rsa-secret: xx1WET12^%3^(WE45

client:
  id: ace-auth
  secret: 123456
  token-header: x-client-token
  expire: 14400
  rsa-secret: x2318^^(*WRYQWR(QW&T


logging:
    level:
#        tk.mybatis: DEBUG
        com.github.wxiaoqi.security.auth: DEBUG


management:
  endpoints:
    web:
      exposure:
        include: '*'
  security:
    enabled: false

4.2  start-up  AuthBootstrap

4.3 nacos  Observe service status

5 AdminBootstrap  Start of

5.1  Modify the configuration file

Start with simplicity , Configure more complex functions later

logging:
    level:
#        tk.mybatis: DEBUG
        com.github.wxiaoqi.security.admin: DEBUG
spring:
    application:
        name: ace-admin
    jackson:
        date-format: yyyy-MM-dd HH:mm:ss
        time-zone: GMT+8
        default-property-inclusion: non_null
    datasource:
        name: test
        url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/ag_admin_v1?useUnicode=true&characterEncoding=UTF8&useSSL=false&serverTimezone=UTC
        username: root
        password: Mima123456
        #  Use druid data source 
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        filters: stat
        maxActive: 20
        initialSize: 1
        maxWait: 60000
        minIdle: 1
        timeBetweenEvictionRunsMillis: 60000
        minEvictableIdleTimeMillis: 300000
        validationQuery: select 'x'
        testWhileIdle: true
        testOnBorrow: false
        testOnReturn: false
        poolPreparedStatements: true
        maxOpenPreparedStatements: 20
    cloud:
      nacos:
        discovery:
          server-addr: 127.0.0.1:8848
      sentinel:
        transport:
          dashboard: localhost:8080
mybatis:
    basepackage: com.github.wxiaoqi.security.admin.mapper
    xmlLocation: classpath:mapper/**/*.xml
    mapper-locations: "classpath*:mapper/*.xml"

server:
    port: 8762

#  You have to configure 
feign:
  httpclient:
    enabled: false
  okhttp:
    enabled: true

ribbon:
  eureka:
    enabled: true
  ReadTimeout: 100000
  ConnectTimeout: 100000
  MaxAutoRetries: 0
  MaxAutoRetriesNextServer: 1
  OkToRetryOnAllOperations: false

hystrix:
  threadpool:
    default:
      coreSize: 1000 ## The maximum number of concurrent threads , Default 10
      maxQueueSize: 1000 ##BlockingQueue The maximum number of queues 
      queueSizeRejectionThreshold: 500 ## Even if maxQueueSize Don't reach , achieve queueSizeRejectionThreshold After this value , Requests will also be rejected 
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 110000

#  To configure swagger
swagger:
    enabled: true
    base-package: com.github.wxiaoqi.security.admin
    title: ace-admin
    version: 1.0.0.SNAPSHOT
    description:  Manage back-end services 
    contact:
        name: admin

auth:
  serviceId: ace-auth
  user:
    token-header: Authorization
  client:
    id: ace-admin
    secret: 123456
    token-header: x-client-token

# redis-cache  relevant 
redis:
    pool:
         maxActive: 300
         maxIdle: 100
         maxWait: 1000
    host: ${REDIS_HOST:localhost}
    port:  ${REDIS_PORT:6379}
    password:
    timeout: 2000
    #  Service or application name 
    sysName: ace-admin
    enable: true
    database: 0

management:
  endpoints:
    web:
      exposure:
        include: '*'
  security:
    enabled: false

5.2 nacos  Observe service status

6 GatewayServerBootstrap  Start of

6.1  Modify the configuration file

Start with simplicity , Configure more complex functions later

server:
  port: 8765

#  Requests and responses  GZIP  Compression support 
feign:
  httpclient:
    enabled: false
  okhttp:
    enabled: true
  compression:
    request:
      enabled: true
      mime-types: text/xml,application/xml,application/json
      min-request-size: 2048
    response:
      enabled: true

spring:
  application:
      name: ace-gateway
  redis:
      database: 2
      host: 127.0.0.1
      jedis:
        pool:
            max-active: 20
  rabbitmq:
      host: ${RABBIT_MQ_HOST:localhost}
      port:  ${RABBIT_MQ_PORT:5672}
      username: guest
      password: guest
  sleuth:
    enabled: true
    http:
      legacy:
        enabled: true
  cloud:
     gateway:
       discovery:
         locator:
           lowerCaseServiceId: true
           enabled: true
       routes:
        # =====================================
        - id: ace-auth
          uri: lb://ace-auth
          order: 8000
          predicates:
          - Path=/api/auth/**
          filters:
          - StripPrefix=2
        - id: ace-admin
          uri: lb://ace-admin
          order: 8001
          predicates:
          - Path=/api/admin/**
          filters:
          - StripPrefix=2
     nacos:
        discovery:
          server-addr: 127.0.0.1:8848
  sentinel:
    transport:
      dashboard: localhost:8080
logging:
  level:
    com.github.wxiaoqi.security.gate.v2: info

management:
  endpoints:
    web:
      exposure:
        include: '*'
  security:
    enabled: false

gate:
  ignore:
    startWith: /auth/jwt

auth:
  serviceId: ace-auth
  user:
    token-header: Authorization
  client:
    token-header: x-client-token
    id: ace-gate  # If it is not filled in, it will read by default spring.application.name
    secret: 123456

ribbon:
  eureka:
    enabled: true
  ReadTimeout: 60000
  ConnectTimeout: 60000
  MaxAutoRetries: 0
  MaxAutoRetriesNextServer: 1
  OkToRetryOnAllOperations: false

hystrix:
  threadpool:
    default:
      coreSize: 1000 ## The maximum number of concurrent threads , Default 10
      maxQueueSize: 1000 ##BlockingQueue The maximum number of queues 
      queueSizeRejectionThreshold: 500 ## Even if maxQueueSize Don't reach , achieve queueSizeRejectionThreshold After this value , Requests will also be rejected 
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 10000

6.2 nacos  Observe service status

6、 ... and   Front end login

After the backend service is started , You can start debugging the front end .

1  Browser input  http://localhost:9527/

2 The username and password are both  admin

3 How it looks after login

7、 ... and Problem records and solutions

1  start-up  AuthBootstrap  newspaper  Failure to find org.eclipse.m2e:lifecycle-mapping:pom:1.0.0

Record an error Failure to find org.eclipse.m2e:lifecycle-mapping:pom:1.0.0 The solution of _ Ambitious people should not ignore the work in front of them -CSDN Blog icon-default.png?t=M0H8https://blog.csdn.net/weixin_46544994/article/details/106940070

2  start-up AuthBootstrap newspaper  java.sql.SQLException: is unrecognized or represents more than one time zone. You must configure

java.sql.SQLException: is unrecognized or represents more than one time zone. You must configure_dream21st The blog of -CSDN Blog icon-default.png?t=M0H8https://blog.csdn.net/qq_36305027/article/details/101678037

原网站

版权声明
本文为[chengqiuming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131946558309.html