博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
携程Apollo一键编译脚本+部署实现
阅读量:7041 次
发布时间:2019-06-28

本文共 7046 字,大约阅读时间需要 23 分钟。

系统编译安装

  • ubuntu16.11
  • java 1.8

系统规划

  • Portal共用
  • 其它环境每个两台机器
  • mysql都做主从,所以每个环境的机器上都会安装admin 服务,config服务,以及一个mysql服务

env ip usage
all 192.168.1.1 portal
dev 192.168.2.1 admin+config+configdb
dev 192.168.2.2 admin+config+configdb
test 192.168.3.1 admin+config+configdb
test 192.168.3.2 admin+config+configdb
pre 192.168.4.1 admin+config+configdb
pre 192.168.4.2 admin+config+configdb
pro 192.168.5.1 admin+config+configdb
pro 192.168.5.2 admin+config+configdb

#!/bin/bash## 先安装jdk1.8以上到/usr/local/java 并设置系统环境变量java -versionbase_home="/home/test/Desktop"############################################################################dev_meta="http://192.168.2.1:8080,http://192.168.2.2:8080"fat_meta="http://192.168.3.1:8080,http://192.168.3.2:8080"uat_meta="http://192.168.4.1:8080,http://192.168.4.2:8080"pro_meta="http://192.168.5.1:8080,http://192.168.5.2:8080"########### portal 数据库 ,共用一个# apollo portal db infoapollo_portal_db_url=jdbc:mysql://192.168.1.1:3306/ApolloPortalDB?characterEncoding=utf8apollo_portal_db_password=portal_root_db_password############ 四个环境的配置数据库# apollo dev config db infodev_apollo_config_db_url=jdbc:mysql://192.168.2.1:3306/ApolloConfigDB?characterEncoding=utf8dev_apollo_config_db_password=dev_config_root_db_password# apollo fat config db infofat_apollo_config_db_url=jdbc:mysql://192.168.3.1:3306/ApolloConfigDB?characterEncoding=utf8fat_apollo_config_db_password=fat_config_root_db_password# apollo uat config db infouat_apollo_config_db_url=jdbc:mysql://192.168.4.1:3306/ApolloConfigDB?characterEncoding=utf8uat_apollo_config_db_password=uat_config_root_db_password# apollo pro config db infopro_apollo_config_db_url=jdbc:mysql://192.168.5.1:3306/ApolloConfigDB?characterEncoding=utf8pro_apollo_config_db_password=pro_config_root_db_password########################## 以下勿更改build_sh() {    cd "$base_home/apollo"    cp -pr apollo apollo_$1    cd apollo_$1/scripts    # apollo config db info    apollo_config_db_url=$2    apollo_config_db_username=root    apollo_config_db_password=$3    # apollo portal db info    apollo_portal_db_url=$4    apollo_portal_db_username=root    apollo_portal_db_password=$5    # meta server url, different environments should have different meta server addresses    dev_meta=$6    fat_meta=$7    uat_meta=$8    pro_meta=$9    META_SERVERS_OPTS="-Ddev_meta=$dev_meta -Dfat_meta=$fat_meta -Duat_meta=$uat_meta -Dpro_meta=$pro_meta"    # =============== Please do not modify the following content =============== #    # go to script directory    cd "${0%/*}"    cd ..    # package config-service and admin-service    echo "==== starting to build config-service and admin-service ===="    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 ===="    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 ===="    echo "==== starting to build client ===="    mvn clean install -DskipTests -pl apollo-client -am $META_SERVERS_OPTS    echo "==== building client finished ===="}####################初始化环境,下载apollosudo apt-get install -y maven gitsudo sed -i '/
/a\
nexus-aliyun
central
Nexus aliyun
http://maven.aliyun.com/nexus/content/groups/public/
' /etc/maven/settings.xmlmkdir -p apollocd apollogit clone https://github.com/ctripcorp/apollo.gitsource /etc/profilesudo mv /usr/bin/java /usr/bin/java_baksudo ln -s /usr/local/java/bin/java /usr/bin/################################################ devbuild_sh "dev" "$dev_apollo_config_db_url" \ "$dev_apollo_config_db_password" \ "$apollo_portal_db_url" \ "$apollo_portal_db_password" \ "$dev_meta" "$fat_meta" "$uat_meta" "$pro_meta"build_sh "fat" "$fat_apollo_config_db_url" \ "$fat_apollo_config_db_password" \ "$apollo_portal_db_url" \ "$apollo_portal_db_password" \ "$dev_meta" "$fat_meta" "$uat_meta" "$pro_meta"build_sh "uat" "$uat_apollo_config_db_url" \ "$uat_apollo_config_db_password" \ "$apollo_portal_db_url" \ "$apollo_portal_db_password" \ "$dev_meta" "$fat_meta" "$uat_meta" "$pro_meta"build_sh "pro" "$pro_apollo_config_db_url" \ "$pro_apollo_config_db_password" \ "$apollo_portal_db_url" \ "$apollo_portal_db_password" \ "$dev_meta" "$fat_meta" "$uat_meta" "$pro_meta"######################### 添加本地jar包到本地mvndev_home="$base_home/apollo/apollo_dev"apollo_version=`ls $dev_home/apollo-client/target/apollo-client-*.jar |grep -v sources |sed 's/.jar//g' |sed "s#.*apollo-client-##g"`mvn install:install-file -DgroupId=com.ctrip.framework.apollo -DartifactId=apollo-client -Dversion=$apollo_version -Dpackaging=jar -Dfile=$dev_home/apollo-client/target/apollo-client-$apollo_version.jarmvn install:install-file -DgroupId=com.ctrip.framework.apollo -DartifactId=apollo-core -Dversion=$apollo_version -Dpackaging=jar -Dfile=$dev_home/apollo-core/target/apollo-core-$apollo_version.jarmvn install:install-file -DgroupId=com.ctrip.framework.apollo -DartifactId=apollo-buildtools -Dversion=$apollo_version -Dpackaging=jar -Dfile=$dev_home/apollo-buildtools/target/apollo-buildtools-$apollo_version.jarmvn install:install-file -DgroupId=com.ctrip.framework.apollo -DartifactId=apollo-common -Dversion=$apollo_version -Dpackaging=jar -Dfile=$dev_home/apollo-common/target/apollo-common-$apollo_version.jar#mkdir -p /opt/setting#echo 'env=DEV' > /opt/setting/server.properties

安装Portal

Portal是共用的,代码都一样,所以这里从dev环境拿个编译包就可以

  1. portal服务器的mysql上面执行该SQL : apollo/apollo_dev/scripts/sql/apolloportaldb.sql
    1. 修改数据表ApolloPortalDB.ServerConfig配置如下,修改 apollo.portal.envs : dev,fat,uat,pro
  2. 上传 apollo/apollo_dev/apollo-portal/target/apollo-portal-0.11.0-SNAPSHOT-github.zip 到 portal服务器(192.168.1.1)/data/apollo_portal
  3. unzip apollo-portal-0.11.0-SNAPSHOT-github.zip
  4. 启动portal ./scripts/startup.sh
  5. 访问portal管理后台 . 默认管理员 : apollo / admin

安装config服务

···这里以DEV环境设置为例···

  1. dev环境的两个mysql做好主从,执行 apollo/apollo_dev/scripts/sql/apolloconfigdb.sql 的sql文件创建库表
  2. 修改apolloconfigdb库中的ServerConfig
    • 修改 eureka.service.url :
    • 这里根据环境不同修改,这里配置的是dev环境的IP
  3. 上传apollo/apollo_dev/apollo-configservice/target/apollo-configservice-0.11.0-SNAPSHOT-github.zip 到 dev两个机器的/data/apollo_config 目录里面
  4. unzip apollo-configservice-0.11.0-SNAPSHOT-github.zip
  5. 启动: ./scripts/startup.sh

安装admin服务

  1. 上传apollo/apollo_dev/apollo-adminservice/target/apollo-adminservice-0.11.0-SNAPSHOT-github.zip 到dev两个服务器的/data/apollo_admin 目录里面
  2. unzip apollo-adminservice-0.11.0-SNAPSHOT-github.zip
  3. 启动 scripts/startup.sh

  • 如果能看懂这个图,Apollo的基本架构也就理解了。下一篇就开始来讲讲Apollo的一些组件,或是服务

携程Apollo一键编译脚本+部署实现

转载于:https://blog.51cto.com/brucewang/2141050

你可能感兴趣的文章
php 用于绘图使用的颜色数组
查看>>
批处理命令 For循环命令具体解释!
查看>>
JSON扩展类——JsonHelper
查看>>
只有程序员了解的9个真相
查看>>
BDB (Berkeley DB)数据库简单介绍(转载)
查看>>
gpu显存(全局内存)在使用时数据对齐的问题
查看>>
开始使用 Markdown
查看>>
Apache性能优化总结
查看>>
atitit.基于虚拟机的启动器设计 --java 启动器 java生成exe
查看>>
他答对一半(打一字)asp.net开源简答题项目
查看>>
Windows系统创建符号链接文件
查看>>
GCC编译器ABI
查看>>
用python做oj上的简单题(持续更新中.......)
查看>>
ShowcaseView-master
查看>>
ODAC(V9.5.15) 学习笔记(六)TOraSQL、TOraTable和TOraStoredProc
查看>>
c++ A类包含B类指针,B类包含A类指针的情况
查看>>
SQL Server 存储(1/8):理解数据页结构
查看>>
解读ASP.NET 5 & MVC6系列(13):TagHelper
查看>>
JAVA & JSON详解
查看>>
C#编程总结(八)数字签名
查看>>