apollo配置中心的学习笔记

公司现在配置文件太多了,导致配置文件修改起来还是非常麻烦的。在boss(业务运营支撑系统)中,配置文件是存放在jar包的,通过应用jar包来引用配置文件(区分不同环境)。这种方式虽然能够满足初期需求,但是随着越来越多的项目,配置文件模块也变得臃肿起来。 用了spring-cloud-config虽然还可以,但是没有web界面的方式。这种适合开发人员(特别喜欢这种上传到git的方式来修改配置文件)。但是局限也很明显,只适合这种用spring cloud架构的,对于xml配置的无能为力。

在经过一定的技术调研,还有一个博主网上文章的推荐,发现这个还是比较适合目前公示的需要的。今天折腾了一番,服务终于能够启动起来了。虽然文档还是挺丰富的,但是有一些有一些坑没有标识出来。 对于这么解决这些坑,我将在后续的时间慢慢完善起来。

昨天搭建遇到的问题主要是因为,一个是jvm参数。还有就是yml的配置。这边一些数据库的配置也是用jvm参数的形式来实现的。虽然挺好的,但是不够直观。我把一些配置修改为在yml中实现。 在对应的配置文件中 举一个例子用来借鉴

---
spring:
  application:
    name: apollo-portal
  profiles:
    active: development
  resources:
    cache-period: 3600


logging:
  file: /opt/logs/100003173/apollo-portal.log

endpoints:
  health:
    sensitive: false
management:
  security:
    enabled: false
  health:
    status:
      order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP
---
server:
  port: 18070

spring:
  profiles: development
  datasource:
    url: jdbc:mysql://1.1.1.1:3306/ApolloPortalDB?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&useSSL=false
    username: name
    password: pwd
    driver-class-name: com.mysql.jdbc.Driver
    max-active: 50
    min-idle: 10
    max-idle: 10
    initial-size: 15
    max-wait: 5
    test-on-borrow: true
    validation-query: select 1
  jpa:
    hibernate:
      show_sql: true
#      ddl-auto: validate
    properties:
      hibernate:
        show_sql: false
        format_sql: false
        use_sql_comments: false
    database: mysql

---
server:
  port: 8070

spring:
  profiles: production
  datasource:
    url: jdbc:mysql://2.2.2.2:3306/ApolloPortalDB?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&useSSL=false
    username: name
    password: pwd
    driver-class-name: com.mysql.jdbc.Driver
    max-active: 50
    min-idle: 10
    max-idle: 10
    initial-size: 15
    max-wait: 5
    test-on-borrow: true
    validation-query: select 1
  jpa:
    hibernate:
      show_sql: true
#      ddl-auto: validate
    properties:
      hibernate:
        show_sql: false
        format_sql: false
        use_sql_comments: false
    database: mysql

同时把application-github.properties 中的配置给注释掉

# DataSource
#spring.datasource.url = ${spring_datasource_url}
#spring.datasource.username = ${spring_datasource_username}
#spring.datasource.password = ${spring_datasource_password}

然后就是配置jvm参数了。

PortalApplication

-Denv=dev -Ddev_meta=http://localhost:8080 -Dfat_meta=http://localhost:8080 -Duat_meta=http://localhost:8080 -Dpro_meta=http://localhost:8080

ConfigServiceApplication

-Denv=dev -Ddev_meta=http://localhost:8080 -Deureka.service.url=http://localhost:8080/eureka/

AdminServiceApplication

-Denv=dev -Ddev_meta=http://localhost:8080 -Deureka.service.url=http://localhost:8080/eureka/


分别启动 ConfigServiceApplication,AdminServiceApplication,PortalApplication 这三个模块,就可以启动了,正常使用了。

访问 http://localhost:8070/ 账号是apollo,密码是admin

mysql的服务降级

mysql 依赖降级 #481

转载于:https://my.oschina.net/miaojiangmin/blog/1832998

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值