Loading

Apollo多环境部署

Apollo多环境部署

Apollo的快速启动项目中,只有一个环境,但是本身的一个apollo-portal管控端可以管理不同环境下的配置;所以apollo配置中心多环境配置下的主要思路为(这里以PRO和UAT两个环境举例说明):

  • 修改【apolloportaldb数据库】【serverconfig表】字段:apollo.portal.envs、configView.memberOnly.envs、apollo.portal.meta.servers

修改字段apollo.portal.meta.servers, 例如:
{
    "DEV":"http://1.1.1.1:8080",
    "FAT":"http://apollo.fat.xxx.com",
    "UAT":"http://apollo.uat.xxx.com",
    "PRO":"http://apollo.xxx.com"
}
  • 将下载好的release解压,并将apollo-adminservice,apollo-configservice和apollo-portal分别上传到两台虚拟机上并解压

  • 两台虚拟机分别进入apollo-configservice和apollo-adminservice文件中config目录,用vim命令行编辑application-github.properties文件

    注意: 这里有个坑,当我们使用比较新的版本,apollo_portal_db_url 默认是走ssl,需要添加此参数:apollo_portal_db_url="jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false

    [root@deploy-150-64 opt]# vim apollo-portal/config/application-github.properties
    # DataSource
    
    spring.datasource.url = jdbc:mysql://10.0.150.64:3306/ApolloPortalDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false
    spring.datasource.username = user
    spring.datasource.password = passwd
    

    值得注意的是不同环境下,可以是同一个MySQL地址,但是数据库必须不一样,这里UAT环境数据库后面加了UAT的后缀,FAT环境数据库后面加了FAT的后缀

  • 进入UAT虚拟机中,apollo-portal下config目录,用vim命令行编辑application-github.properties文件,同样的配置MySQL地址

  • 进入UAT环境的虚拟机中,apollo-portal下config目录,用vim命令行编辑apollo-env.properties文件,配置apollo的meta-server环境地址

    [root@deploy-150-64 opt]# cat apollo-portal/config/apollo-env.properties
    #local.meta=http://localhost:8080
    #dev.meta=http://fill-in-dev-meta-server:8080
    #fat.meta=http://fill-in-fat-meta-server:8080
    uat.meta=http://10.0.150.187:8080
    pro.meta=http://10.0.150.64:8080
    
    
  • 两台虚拟机分别按顺序启动apollo-configservice,apollo-adminservice,在apollo-configservcie和apollo-adminservice目录下的scripts,使用命令行sh startup.sh启动

  • UAT虚拟机中,启动apollo-portal,在apollo-portal目录下的scripts,使用命令行sh startup.sh启动

  • 在UAT虚拟机中输入localhost:8070,然后进入一个项目即可看到多环境了,我这里后续修改成了DEV和PRO环境

posted @ 2022-03-17 16:55  知无不言~  阅读(1900)  评论(0编辑  收藏  举报