其他分享
首页 > 其他分享> > Apollo新增环境

Apollo新增环境

作者:互联网


  1. git分支check,如下

    <root@SYS-OPS-JKS02 ~/apollo># git branch -a
      master
    * v1.5.1
      remotes/origin/0.x
      remotes/origin/1.1.2
      remotes/origin/1.5.1
      remotes/origin/HEAD -> origin/master
      remotes/origin/gh-pages
      remotes/origin/master
      remotes/origin/mvn-repo
  2. 修改代码文件,如下

    apollo-core/src/main/java/com/ctrip/framework/apollo/core/enums/EnvUtils.java
          case "DEV01":
            return Env.DEV01;
          case "DEV02":
            return Env.DEV02;
          case "DEV03":
            return Env.DEV03;
          case "SIT01":
            return Env.SIT01;
          case "SIT02":
            return Env.SIT02;
          case "SIT03":
            return Env.SIT03;
          case "PRE":
            return Env.PRE;
    apollo-core/src/main/java/com/ctrip/framework/apollo/core/internals/LegacyMetaServerProvider.java
        domains.put(Env.DEV01, getMetaServerAddress(prop, "dev01_meta", "dev01.meta"));
        domains.put(Env.DEV02, getMetaServerAddress(prop, "dev02_meta", "dev02.meta"));
        domains.put(Env.DEV03, getMetaServerAddress(prop, "dev03_meta", "dev03.meta"));
        domains.put(Env.SIT01, getMetaServerAddress(prop, "sit01_meta", "sit01.meta"));
        domains.put(Env.SIT02, getMetaServerAddress(prop, "sit02_meta", "sit02.meta"));
        domains.put(Env.SIT03, getMetaServerAddress(prop, "sit03_meta", "sit03.meta"));
        domains.put(Env.PRE, getMetaServerAddress(prop, "pre_meta", "pre.meta"));
     
     
    apollo-portal/src/main/resources/apollo-env.properties
    dev01.meta=${dev01_meta}
    dev02.meta=${dev02_meta}
    dev03.meta=${dev03_meta}
    sit01.meta=${sit01_meta}
    sit02.meta=${sit02_meta}
    sit03.meta=${sit03_meta}
     
     
    apollo-core/src/main/java/com/ctrip/framework/apollo/core/enums/Env.java
     
    public enum Env{
      LOCAL, DEV, FWS, FAT, UAT, LPT, DEV01, DEV02, DEV03, SIT01, SIT02, SIT03, PRO, PRE, TOOLS, UNKNOWN;
     
      public static Env fromString(String env) {
        Env environment = EnvUtils.transformEnv(env);
        Preconditions.checkArgument(environment != UNKNOWN, String.format("Env %s is invalid", env));
        return environment;
      }
    }
     
     
    scripts/build.sh
    dev01_meta=http://apollo.dev01.nflow.internal:8080
    dev02_meta=http://apollo.dev02.nflow.internal:8080
    dev03_meta=http://apollo.dev03.nflow.internal:8080
    sit01_meta=http://apollo.sit01.nflow.internal:8080
    sit02_meta=http://apollo.sit02.nflow.internal:8080
    sit03_meta=http://apollo.sit03.nflow.internal:8080
     
    META_SERVERS_OPTS="-Ddev_meta=$dev_meta -Dfat_meta=$fat_meta -Duat_meta=$uat_meta -Dpro_meta=$pro_meta -Ddev01_meta=$dev01_meta -Ddev02_meta=$dev02_meta -Ddev03_meta=$dev03_meta -Dsit01_meta=$sit01_meta -Dsit02_meta=$sit02_meta -Dsit03_meta=$sit03_meta"
  3. 切换到/root/apollo/scripts

    sh build.sh

  4. 注意ApolloPortal的配置,如下

    ## 修改meata_server地址
    <root@SYS-APL-ADM01 /usr/local/apollo-portal/config># cat apollo-env.properties
    #local.meta=http://localhost:8080
    dev01.meta=http://apollo.dev01.nflow.internal:8080
    dev02.meta=http://apollo.dev02.nflow.internal:8080
    dev03.meta=http://apollo.dev03.nflow.internal:8080
    #fat.meta=http://fill-in-fat-meta-server:8080
    sit01.meta=http://apollo.sit01.nflow.internal:8080
    sit02.meta=http://apollo.sit02.nflow.internal:8080
    sit03.meta=http://apollo.sit03.nflow.internal:8080
    #lpt.meta=${lpt_meta}
    pro.meta=http://apollo.nflow.internal:8080
    #stable
    pre.meta=http://apollo.pre.nflow.internal:8080
     
     
    ## 修改数据库地址
    <root@SYS-APL-ADM01 /usr/local/apollo-portal/config># cat application-github.properties
    # DataSource
    #spring.datasource.url = jdbc:mysql://10.1.1.135:3306/ApolloPortalDB?characterEncoding=utf8
    spring.datasource.url = jdbc:mysql://rm-bp16vh718ptga7fpy.mysql.rds.aliyuncs.com:3306/ApolloPortalDB?characterEncoding=utf8
    spring.datasource.username = apollo
    spring.datasource.password = %TGB6yhn
  5. 注意修改数据库,表serverconfig中的apollo.portal.envs值“环境”

标签:Apollo,http,新增,环境,meta,Env,8080,apollo,internal
来源: https://www.cnblogs.com/apink/p/16294967.html