apollo部署心得


1.github下載apollo源碼 : https://github.com/ctripcorp/apollo.git

2.具體的使用方法詳見wiki : https://github.com/ctripcorp/apollo/wiki/Apollo%E5%BC%80%E5%8F%91%E6%8C%87%E5%8D%97

3.本地打包apollo源碼:為了避免打包出錯,最好是刪除test里面的方法,其他的未嘗試過, apollo源碼里面包含主要的三個部分

  • apolloconfig-service,作為eureka注冊服務中心meta-service,apolloadmin-service和apolloconfig-service都要注冊到該服務,
  • apolloconfig-service和apolloadmin-service 共用數據庫
  • apolloconfig-service修改如下配置文件: 
    • (bootstrap.yml)
      •   包含eureka注冊服務信息
        eureka:
          instance:
            hostname: ${hostname:localhost}
            preferIpAddress: true
            status-page-url-path: /info
            health-check-url-path: /health
          server:
            peerEurekaNodesUpdateIntervalMs: 60000
            enableSelfPreservation: false
          client:
            serviceUrl:#(meta-service地址,和configservice一起部署)
              defaultZone: http://10.108.135.88:8080/eureka/        
            healthcheck:
              enabled: true
            eurekaServiceUrlPollIntervalSeconds: 60
        
        
        management:
          health:
            status:
              order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP
    • (application.yml) 
      •  包含應用的一些端口信息,名字信息
        spring:
          application:
            name: apollo-configservice
          profiles:
            active: ${apollo_profile}
        ctrip:
          appid: 100003171
        server:
          port: 8080
        logging:
          file: /opt/logs/100003171/apollo-configservice.log
  • apolloadmin-service修改如下文件(bootstrap.yml ):
    • (bootstrap.yml)
      •  包含eureka注冊信息 
        eureka:
          instance:
            hostname: ${hostname:localhost}
            preferIpAddress: true
            status-page-url-path: /info
            health-check-url-path: /health
          client:
            serviceUrl:
              defaultZone: http://10.108.135.88:8080/eureka/
            healthcheck:
              enabled: true
            eurekaServiceUrlPollIntervalSeconds: 60
        management:
          health:
            status:
              order: DOWN, OUT_OF_SERVICE, UNKNOWN, UP 
    • (application.yml)
      •  包含應用本身的一些信息
        spring:
          application:
            name: apollo-adminservice
          profiles:
            active: ${apollo_profile}
        
        ctrip:
          appid: 100003172
          
        server:
          port: 8090
          
        logging:
          file: /opt/logs/100003172/apollo-adminservice.log
  •  apolloportal-service修改如下信息
    • apollo-env.properties  (填寫各環境下的meta-service地址) 
      dev.meta=http://10.108.135.88:8080  (填寫dev環境下的meta-service地址)
      fat.meta=http://fat-url
      uat.meta=${uat_meta}
      lpt.meta=${lpt_meta}
      pro.meta=${pro_meta}
    •  portal不需要注冊eureka信息

  •  准備好數據庫環境,源碼里面自帶數據庫腳本,跑入數據庫即可
  •  修改build.bat文件
    • @echo off
      
      rem apollo config db info
      set apollo_config_db_url="jdbc:mysql://10.xx.xx.xx:3306/ApolloConfigDB?characterEncoding=utf8" (數據庫地址)
      set apollo_config_db_username="username"
      set apollo_config_db_password="password"
      
      rem apollo portal db info
      set apollo_portal_db_url="jdbc:mysql://10.xx.xx.xx:3306/ApolloPortalDB?characterEncoding=utf8"
      set apollo_portal_db_username="username"
      set apollo_portal_db_password="password"
      
      rem meta server url, different environments should have different meta server addresses
      set dev_meta="http://10.108.135.xx:8080"
      set fat_meta="http://10.108.135.xx:8080"
      set uat_meta="http://10.108.135.xx:8080"
      set pro_meta="http://10.108.135.xx:8080"
      
      set META_SERVERS_OPTS=-Ddev_meta=%dev_meta% -Dfat_meta=%fat_meta% -Duat_meta=%uat_meta% -Dpro_meta=%pro_meta%
      
      rem =============== Please do not modify the following content =============== 
      rem go to script directory
      cd "%~dp0"
      
      cd ..
      
      rem package config-service and admin-service
      echo "==== starting to build config-service and admin-service ===="
      
      call mvn clean package -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github -Dspring_datasource_url=%apollo_config_db_url% -Dspring_datasource_username=%apollo_config_db_username% -Dspring_datasource_password=%apollo_config_db_password%
      
      echo "==== building config-service and admin-service finished ===="
      
      echo "==== starting to build portal ===="
      
      call mvn clean package -DskipTests -pl apollo-portal -am -Dapollo_profile=github,auth -Dspring_datasource_url=%apollo_portal_db_url% -Dspring_datasource_username=%apollo_portal_db_username% -Dspring_datasource_password=%apollo_portal_db_password% %META_SERVERS_OPTS%
      
      echo "==== building portal finished ===="
      
      pause

       配置好上述信息后,即可執行腳本,apolloconfig-service和apolloadmin-service每個環境都要部署一套,且需要注意的是ApolloPortalDB只需要在生產環境部署一個即可,而ApolloConfigDB需要在每個環境部署一套,如fat、uat和pro分別部署3套ApolloConfigDB。

    • 打包完成后獲取config,admin,portal下面的github.zip包,上傳置相應的環境,解壓以后按照config-admin-portal的順序依次執行config目錄下的腳本即可。

以上,后續有時間繼續更新


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM