1. 程式人生 > >ctrip-apollo多環境部署-史上最簡單

ctrip-apollo多環境部署-史上最簡單

一套Portal可以管理多個環境,但是每個環境都需要獨立部署一套Config Service、Admin Service和ApolloConfigDB,apollo 0.10.2版本預設支援的環境為:LOCAL, DEV, FWS, FAT, UAT, LPT, PRO, TOOLS下面我們以部署一套Portal管理DEV, FAT, UAT三個環境為例具體說明apollo多環境部署由於伺服器有限,我在一臺伺服器三個目錄存放三套apollo,每套使用不同埠來模擬三個伺服器,並在一個dbserver上使用三個不同名字的資料庫, portal只部署在UAT中,服務存放目錄及資料庫對應關係如下表:
環境目錄
configserviceadminserviceportal資料庫名稱
DEV~/apollo/devYYNApolloConfigDB
FAT~/apollo/fatYYNApolloConfigDB2
UAT~/apollo/uatYYYApolloConfigDB3ApolloPortalDB
apollo官方文件中提到的各環境meta地址是在build.sh(或build.bat)中定義的,我們不這樣做,我們使用執行時通過設定相應引數來實現部署前準備:1.下載apollo原始碼2.編譯打包apollo (需要maven3.5.2+) 進到 apollo\scripts目錄下, 執行 build.bat (linux環境使用build.sh) 編譯完成我們要使用的adminservice、configserivce及portal包分別位於: apollo\apollo-adminservice\target\apollo-adminservice-0.10.2-github.zip apollo\apollo-configservice\target\apollo-configservice-0.10.2-github.zip apollo\apollo-portal\target\apollo-portal-0.10.2-github.zip3. 部署服務端伺服器 3.1 安裝mysql5.7 , 根據實際情況選擇新安裝還是升級 3.2 安裝jdk1.8 如果伺服器上執行有其它java應用不能直接升級java版本,可以在伺服器上新安裝jdk1.8, apollo應用通過設定環境變數來指定使用1.8 1)單獨一個linux使用者跑apollo, bashrc中設定java_home及path 2)修改apollo啟動指令碼,指定java_home (此文用到的就是這種方式)一、apollo服務端
1.1 DEV環境1.1.1 建立資料庫dev環境沒有portal, 所以只需要使用 apollo\scripts\sql\apolloconfigdb.sql,在mysql中建立資料庫即可(如果要修改資料庫名稱,注意到sql檔案中修改)1.1.2 configservice部署 將apollo-configservice-0.10.2-github.zip解壓到~/apollo/dev/configservice下修改~/apollo/dev/configservice/script/startup.sh, 配置資料庫、幾個meta地址JAVA_HOME=/usr/local/java/jdk1.8.0_161apollo_config_db_url=jdbc:mysql://localhost:1504/ApolloConfigDB?characterEncoding=utf8
apollo_config_db_username=rootapollo_config_db_password=16VHKlYTv7Wg# meta server urlconfig_server_url=http://127.0.0.1:8280admin_server_url=http://127.0.0.1:8290eureka_service_url=$config_server_url/eureka/## Adjust server port if necessarySERVER_PORT=8280## Adjust log dir if necessaryLOG_DIR=$APOLLO_HOME/logsSERVICE_NAME=apollo-configservicePATH_TO_JAR=$SERVICE_NAME".jar"SERVER_URL="http://localhost:$SERVER_PORT"# JAVA OPTSBASE_JAVA_OPTS="-Denv=dev -Ddev_meta=$config_server_url"CONFIG_JAVA_OPTS="$BASE_JAVA_OPTS -Dspring.profiles.active=github -Deureka.service.url=$eureka_service_url -Deureka.instance.homePageUrl=$config_server_url"JAVA_OPTS="$CONFIG_JAVA_OPTS -Dspring.datasource.url=$apollo_config_db_url -Dspring.datasource.username=$apollo_config_db_username -Dspring.datasource.password=$apollo_config_db_password"export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -Xloggc:$LOG_DIR/heap_trace.txt -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"1.1.3 adminservice部署 將apollo-adminservice-0.10.2-github.zip解壓到~/apollo/dev/adminservice下 修改~/apollo/dev/adminservice/script/startup.sh, 配置資料庫、幾個meta地址JAVA_HOME=/usr/local/java/jdk1.8.0_161apollo_config_db_url=jdbc:mysql://localhost:1504/ApolloConfigDB?characterEncoding=utf8apollo_config_db_username=rootapollo_config_db_password=16VHKlYTv7Wg# meta server urlconfig_server_url=http://127.0.0.1:8280admin_server_url=http://127.0.0.1:8290eureka_service_url=$config_server_url/eureka/## Adjust server port if necessarySERVER_PORT=8290## Adjust log dir if necessaryLOG_DIR=$APOLLO_HOME/logsSERVICE_NAME=apollo-adminservicePATH_TO_JAR=$SERVICE_NAME".jar"SERVER_URL="http://localhost:$SERVER_PORT"#JAVA OPTSBASE_JAVA_OPTS="-Denv=dev -Ddev_meta=$config_server_url"ADMIN_JAVA_OPTS="$BASE_JAVA_OPTS -Dspring.profiles.active=github -Deureka.service.url=$eureka_service_url -Deureka.instance.homePageUrl=$admin_server_url"JAVA_OPTS="$ADMIN_JAVA_OPTS -Dspring.datasource.url=$apollo_config_db_url -Dspring.datasource.username=$apollo_config_db_username -Dspring.datasource.password=$apollo_config_db_password"export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -Xloggc:$LOG_DIR/heap_trace.txt -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"1.2 FAT環境1.2.1 建立資料庫fat環境也沒有portal, 同樣只需要使用 apollo\scripts\sql\apolloconfigdb.sql,在mysql中建立資料庫即可(如果要修改資料庫名稱,注意到sql檔案中修改)1.2.2 configservice部署 將apollo-configservice-0.10.2-github.zip解壓到~/apollo/dev/configservice下修改~/apollo/dev/configservice/script/startup.sh, 配置資料庫、幾個meta地址JAVA_HOME=/usr/local/java/jdk1.8.0_161apollo_config_db_url=jdbc:mysql://localhost:1504/ApolloConfigDB2?characterEncoding=utf8apollo_config_db_username=rootapollo_config_db_password=16VHKlYTv7Wg# meta server urlconfig_server_url=http://127.0.0.1:8180admin_server_url=http://127.0.0.1:8190eureka_service_url=$config_server_url/eureka/## Adjust server port if necessarySERVER_PORT=8180## Adjust log dir if necessaryLOG_DIR=$APOLLO_HOME/logsSERVICE_NAME=apollo-configservicePATH_TO_JAR=$SERVICE_NAME".jar"SERVER_URL="http://localhost:$SERVER_PORT"# JAVA OPTSBASE_JAVA_OPTS="-Denv=dev -Ddev_meta=$config_server_url"CONFIG_JAVA_OPTS="$BASE_JAVA_OPTS -Dspring.profiles.active=github -Deureka.service.url=$eureka_service_url -Deureka.instance.homePageUrl=$config_server_url"JAVA_OPTS="$CONFIG_JAVA_OPTS -Dspring.datasource.url=$apollo_config_db_url -Dspring.datasource.username=$apollo_config_db_username -Dspring.datasource.password=$apollo_config_db_password"export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -Xloggc:$LOG_DIR/heap_trace.txt -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"1.2.3 adminservice部署 將apollo-adminservice-0.10.2-github.zip解壓到~/apollo/dev/adminservice下 修改~/apollo/dev/adminservice/script/startup.sh, 配置資料庫、幾個meta地址JAVA_HOME=/usr/local/java/jdk1.8.0_161apollo_config_db_url=jdbc:mysql://localhost:1504/ApolloConfigDB2?characterEncoding=utf8apollo_config_db_username=rootapollo_config_db_password=16VHKlYTv7Wg# meta server urlconfig_server_url=http://127.0.0.1:8180admin_server_url=http://127.0.0.1:8190eureka_service_url=$config_server_url/eureka/## Adjust server port if necessarySERVER_PORT=8190## Adjust log dir if necessaryLOG_DIR=$APOLLO_HOME/logsSERVICE_NAME=apollo-adminservicePATH_TO_JAR=$SERVICE_NAME".jar"SERVER_URL="http://localhost:$SERVER_PORT"#JAVA OPTSBASE_JAVA_OPTS="-Denv=dev -Ddev_meta=$config_server_url"ADMIN_JAVA_OPTS="$BASE_JAVA_OPTS -Dspring.profiles.active=github -Deureka.service.url=$eureka_service_url -Deureka.instance.homePageUrl=$admin_server_url"JAVA_OPTS="$ADMIN_JAVA_OPTS -Dspring.datasource.url=$apollo_config_db_url -Dspring.datasource.username=$apollo_config_db_username -Dspring.datasource.password=$apollo_config_db_password"export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -Xloggc:$LOG_DIR/heap_trace.txt -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"1.3 UAT環境1.3.1 建立資料庫uat環境有portal, 需要分別使用 apollo\scripts\sql\apolloconfigdb.sql和apollo\scripts\sql\apolloportaldb.sql,在mysql中建立配置資料庫和portal資料庫 (如果要修改資料庫名稱,注意到sql檔案中修改)portal資料庫ServerConfig表中apollo.portal.envs配置的環境為DEV, FAT, UAT1.3.2 configservice部署 將apollo-configservice-0.10.2-github.zip解壓到~/apollo/dev/configservice下修改~/apollo/dev/configservice/script/startup.sh, 配置資料庫、幾個meta地址JAVA_HOME=/usr/local/java/jdk1.8.0_161apollo_config_db_url=jdbc:mysql://localhost:1504/ApolloConfigDB3?characterEncoding=utf8apollo_config_db_username=rootapollo_config_db_password=16VHKlYTv7Wg# meta server urlconfig_server_url=http://127.0.0.1:8080admin_server_url=http://127.0.0.1:8090eureka_service_url=$config_server_url/eureka/## Adjust server port if necessarySERVER_PORT=8080## Adjust log dir if necessaryLOG_DIR=$APOLLO_HOME/logsSERVICE_NAME=apollo-configservicePATH_TO_JAR=$SERVICE_NAME".jar"SERVER_URL="http://localhost:$SERVER_PORT"# JAVA OPTSBASE_JAVA_OPTS="-Denv=dev -Ddev_meta=$config_server_url"CONFIG_JAVA_OPTS="$BASE_JAVA_OPTS -Dspring.profiles.active=github -Deureka.service.url=$eureka_service_url -Deureka.instance.homePageUrl=$config_server_url"JAVA_OPTS="$CONFIG_JAVA_OPTS -Dspring.datasource.url=$apollo_config_db_url -Dspring.datasource.username=$apollo_config_db_username -Dspring.datasource.password=$apollo_config_db_password"export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -Xloggc:$LOG_DIR/heap_trace.txt -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"1.2.3 adminservice部署 將apollo-adminservice-0.10.2-github.zip解壓到~/apollo/dev/adminservice下 修改~/apollo/dev/adminservice/script/startup.sh, 配置資料庫、幾個meta地址JAVA_HOME=/usr/local/java/jdk1.8.0_161apollo_config_db_url=jdbc:mysql://localhost:1504/ApolloConfigDB3?characterEncoding=utf8apollo_config_db_username=rootapollo_config_db_password=16VHKlYTv7Wg# meta server urlconfig_server_url=http://127.0.0.1:8180admin_server_url=http://127.0.0.1:8190eureka_service_url=$config_server_url/eureka/## Adjust server port if necessarySERVER_PORT=8190## Adjust log dir if necessaryLOG_DIR=$APOLLO_HOME/logsSERVICE_NAME=apollo-adminservicePATH_TO_JAR=$SERVICE_NAME".jar"SERVER_URL="http://localhost:$SERVER_PORT"#JAVA OPTSBASE_JAVA_OPTS="-Denv=dev -Ddev_meta=$config_server_url"ADMIN_JAVA_OPTS="$BASE_JAVA_OPTS -Dspring.profiles.active=github -Deureka.service.url=$eureka_service_url -Deureka.instance.homePageUrl=$admin_server_url"JAVA_OPTS="$ADMIN_JAVA_OPTS -Dspring.datasource.url=$apollo_config_db_url -Dspring.datasource.username=$apollo_config_db_username -Dspring.datasource.password=$apollo_config_db_password"export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -Xloggc:$LOG_DIR/heap_trace.txt -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"1.3.4 portal部署 將apollo-portal-0.10.2-github.zip解壓到~/apollo/uat/portal 修改~/apollo/uat/portal/script/startup.sh, 配置資料庫、幾個meta地址JAVA_HOME=/usr/local/java/jdk1.8.0_161# apollo portal db infoapollo_portal_db_url=jdbc:mysql://localhost:1504/ApolloPortalDB?characterEncoding=utf8apollo_portal_db_username=rootapollo_portal_db_password=16VHKlTv7Wg# meta server urldev_config_server_url=http://127.0.0.1:8280fat_config_server_url=http://127.0.0.1:8180uat_config_server_url=http://127.0.0.1:8080## Adjust server port if necessarySERVER_PORT=8070## Adjust log dir if necessaryLOG_DIR=$APOLLO_HOME/logsSERVICE_NAME=apollo-portalPATH_TO_JAR=$SERVICE_NAME".jar"SERVER_URL="http://localhost:$SERVER_PORT"BASE_JAVA_OPTS="-Ddev_meta=$dev_config_server_url -Dfat_meta=$fat_config_server_url -Duat_meta=$uat_config_server_url"PORTAL_JAVA_OPTS="$BASE_JAVA_OPTS -Dspring.profiles.active=github,auth"JAVA_OPTS="$PORTAL_JAVA_OPTS -Dspring.datasource.url=$apollo_portal_db_url -Dspring.datasource.username=$apollo_portal_db_username -Dspring.datasource.password=$apollo_portal_db_password"export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -Xloggc:$LOG_DIR/heap_trace.txt -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"1.4 注意事項1.4.1 portal資料庫ServerConfig表中apollo.portal.envs配置所有支援的環境DEV, FAT, UAT1.4.2 portal啟動引數設定需要管理的所有環境的meta地址,如:# meta server urldev_config_server_url=http://106.75.28.32:8080fat_config_server_url=http://106.75.28.32:8180uat_config_server_url=http://106.75.28.32:8280-Ddev_meta=$dev_config_server_url -Dfat_meta=$fat_config_server_url -Duat_meta=$uat_config_server_url1.4.3 每個環境的adminservice和configservice設定各自的meta地址及 homePageUrl,如-Dfat_meta=$config_server_url -Deureka.instance.homePageUrl=$config_server_url1.4.4 新加環境配置後,已經有的專案, 可以通過補缺環境操作來把缺失的環境專案補上二、apollo客戶端1.設定環境變數 三種方法, 參看官方文件2.每個客戶端在apollo-env.properties中設定相應環境的meta地址,如dev.meta=http\://a.test.net\:8280fat.meta=http\://a.test.net\:8180uat.meta=http\://a.test.net\:8080

相關推薦

ctrip-apollo環境部署-簡單

一套Portal可以管理多個環境,但是每個環境都需要獨立部署一套Config Service、Admin Service和ApolloConfigDB,apollo 0.10.2版本預設支援的環境為:LOCAL, DEV, FWS, FAT, UAT, LPT, PRO, T

簡單的springboot國際化語言切換實現方案

messages conf main del span 語言 rop target 每天 每天學習一點點 編程PDF電子書、視頻教程免費下載:http://www.shitanlife.com/code 前提: 在resources目錄下建立 messages_en

簡單的SpringCloud教程 | 第十一篇: docker部署spring cloud項目

大數 imageview 建議 chapter 環境 多次 pan mas 存儲 Docker是一個開源的引擎,可以輕松的為任何應用創建一個輕量級的、可移植的、自給自足的容器。開發者在筆記本上編譯測試通過的容器可以批量地在生產環境中部署,包括VMs(虛擬機)、bare m

簡單的SpringCloud教程 | 第十一篇: docker部署spring cloud專案

Docker是一個開源的引擎,可以輕鬆的為任何應用建立一個輕量級的、可移植的、自給自足的容器。開發者在筆記本上編譯測試通過的容器可以批量地在生產環境中部署,包括VMs(虛擬機器)、bare metal、OpenStack 叢集和其他的基礎應用平臺。 Docker通常用於如下場景:

簡單lamp環境搭建

lamp,即linux、Apache、mysql、php 環境:centos 7.4 mysql官網下載安裝mysql-server wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarc

簡單MySQL教程詳解(基礎篇)之表聯合查詢

常用術語 內連線 外連線 左外連線 右外連線 注意事項: 自連線 子查詢 在上篇文章史上最簡單MySQL教程詳解(基礎篇)之資料庫設計正規化及應用舉例我們介紹過,在關係型資料庫中,我們通常為了減少資料的冗餘量將對資料表進行規範,將

簡單的jdk環境變數配置java環境變數配置

    一次性簡單教你學會JDK環境變數配置 一次性簡單教你學會JDK環境變數配置,先在網上下載個綠色版的jdk壓縮檔案。如:http://download.csdn.net/album/detai

簡單React開發環境搭建教程

1. 安裝nodenode js 官網安裝完成之後,開啟命令提示符 輸入 npm 出現下列提示說明安裝成功2. 根據react 官網提示,在命令提示符輸入npm install -g create-react-app經過一段時間的等待, 安裝成功然後按上圖所示輸入命令證明re

ctrip-apollo windows環境部署

1、下載原始碼 2、建立資料庫,所有的表等,github都有準備   參考連結:https://github.com/ctripcorp/apollo/wiki/%E5%88%86%E5%B8%83%E5%BC%8F%E9%83%A8%E7%BD%B2%E6%8C%87%E

簡單Android原始碼編譯環境搭建方法(基於Docker)

利用Docker映象確實可以簡化編譯環境的配置,現在Docker的用處還是挺多的,例如TensorFlow也可以在Docker上玩。有史以來,Android原始碼編譯環境的搭建始終是一件麻煩事兒。網上有數不清的文章介紹如何編譯Android原始碼,但是他們要麼方法複雜、步驟太

簡單的SpringCloud教程 | 第十一篇: docker部署spring cloud專案

一、docker簡介 Docker是一個開源的引擎,可以輕鬆的為任何應用建立一個輕量級的、可移植的、自給自足的容器。開發者在筆記本上編譯測試通過的容器可以批量地在生產環境中部署,包括VMs(虛擬機器)、bare metal、OpenStack 叢集和其他的基礎應用平臺

手把手教你從頭開始搭建友善之臂ARM-tiny4412開發環境詳細!!)

建立一個ARM目錄 mkdir   /disk/A9  -p 接下來你需要準備以下的東西 1、arm-linux-gcc-4.5.1     交叉編譯器 2、linux-3.5-tiny4412   

webpack入口腳手架,簡單入口,拿來即可用

# 基於webpack3的多入口腳手架非常簡單的一個多入口配置,全自動,無需修改任何webpack配置,只需新建資料夾即可配置多入口### 如何新建目錄需要新建一個入口?直接在src 目錄下建立資料夾 即可資料夾必須包含:index.html(模板HTML)index.js(

查找(一)簡單清晰的紅黑樹解說

ont 演示 detail align article 向上 節點 動態插入 列表 查找(一) 我們使用符號表這個詞來描寫敘述一張抽象的表格。我們會將信息(值)存儲在當中,然後依照指定的鍵來搜索並獲取這些信息。鍵和值的詳細意義取決於不同的應用。 符號表中可能會保

Intellij idea簡單的教程之Linux下安裝與破解Intellij idea2017

成功 zxvf java 新建 pre form 旗艦版 lan intel 一、前言 這一節我們介紹在Linux下如何安裝與破解Intellij idea2017。現在有很多公司開發環境都是Linux,所以掌握在Linux環境下使用Idea辦公也是咱們必須得掌握的技能。

簡單的ftp下載服務器

spa 最簡 pre 服務器 pat ror tin total true 服務端: 1 # encoding:utf-8 2 # Author:"richie" 3 # Date:8/23/2017 4 5 from socket import * 6 i

簡單的 SpringCloud 教程 | 終章

conf con 知識 實例 feign 地址 聚合 com red 版權聲明:本文為博主原創文章,歡迎轉載,轉載請註明作者、原文超鏈接 ,博主地址:http://blog.csdn.net/forezp。 目錄(?)[+] 轉載請標明出處: http

這恐怕是簡單傳 AAR 教程

Gradle 依賴管理 Android Studio 類庫 在做項目的時候,抽出來一些工具方法,然後做其他項目的時候需要使用,只是後就有將這些工具方法抽出來單獨形成一個庫的需求了。在 Android Studio 裏就是 AAR。因為我是個人開發,想到方便的方法就是把 AAR 上傳到本地 ma

簡單的 SpringCloud 教程 | 第十四篇: 服務註冊(consul)

配置 資料 源碼下載 擴展性 local sta tar value mark 這篇文章主要介紹 spring cloud consul 組件,它是一個提供服務發現和配置的工具。consul具有分布式、高可用、高擴展性。 consul 具有以下性質: 服務發現:cons

簡單的SpringCloud教程 | 第六篇: 分布式配置中心(Spring Cloud Config)(Finchley版本)

prope shu 由於 ext master strip div 文件配置 rap 在上一篇文章講述zuul的時候,已經提到過,使用配置服務來保存各個服務的配置文件。它就是Spring Cloud Config。 在分布式系統中,由於服務數量巨多,為了方便服務配置文件統