step1:创建apollo数据库

自己数据库导入下面两个地址的sql,这样就分别创建了ApolloConfigDB、ApolloPortalDB
sql地址
https://github.com/nobodyiam/apollo-build-scripts/blob/master/sql/apolloportaldb.sql
https://github.com/nobodyiam/apollo-build-scripts/blob/master/sql/apolloconfigdb.sql

step2:安装apollo

https://github.com/ctripcorp/apollo/releases/tag/v1.7.1下载
apollo-adminservice-1.7.1-github.zip
apollo-configservice-1.7.1-github.zip
apollo-portal-1.7.1-github.zip
分别解压到单独的文件夹,进行如下操作

  1. 1:修改下面三个目录内的文件,内容改为数据库地址和用户密码
  2. apollo-adminservice-1.7.1-github\config\application-github.properties
  3. apollo-configservice-1.7.1-github\config\application-github.properties
  4. apollo-portal-1.7.1-github\config\application-github.properties
  5. 2:自定义端口,三个服务端口分别如下
  6. apollo-configservice 18080 注册中心地址
  7. apollo-adminservice 18090
  8. apollo-portal 18070 门户登陆端口
  9. apollo-configservice不以8080端口启动的情况下,要修改ApolloConfigDB库的ServerConfig表的eureka.service.urlvalue值为http://localhost:18080/eureka/,我是单机环境,因此是localhost,端口从数据库默认的8080改为18080
  10. 我自己只是使用了dev环境,其他没使用,因此我的G:\apollo-portal-1.7.1-github\config\apollo-env.properties内容如下
  11. local.meta=http://localhost:18080
  12. dev.meta=http://localhost:18080
  13. #fat.meta=http://fill-in-fat-meta-server:8080
  14. #uat.meta=http://fill-in-uat-meta-server:8080
  15. lpt.meta=${lpt_meta}
  16. #pro.meta=http://fill-in-pro-meta-server:8080
  17. 3.上传并启动
  18. 上传下面三个文件夹到服务器/mydata/apollo-1.7.1目录下
  19. apollo-adminservice-1.7.1
  20. apollo-configservice-1.7.1
  21. apollo-portal-1.7.1
  22. 4.启动
  23. 启动顺序configservice->adminservice->portal
  24. nohup java -Dserver.port=18080 -Deureka.instance.ip-address={云服务器公网ip} -Deureka.instance.homePageUrl=http://{云服务器公网ip}:18080 -jar apollo-configservice-1.7.1.jar &
  25. nohup java -Dserver.port=18090 -Deureka.instance.ip-address={云服务器公网ip} -Deureka.instance.homePageUrl=http://{云服务器公网ip}:18090 -jar apollo-adminservice-1.7.1.jar &
  26. nohup java -Dserver.port=18070 -jar apollo-portal-1.7.1.jar &
  27. cd /mydata/apollo-1.7.1/apollo-configservice-1.7.1-github/
  28. nohup java -Xmx256m -Xms256m -Xmn128m -Dserver.port=18080 -Deureka.instance.ip-address=114.67.85.120 -jar apollo-configservice-1.7.1.jar &
  29. cd /mydata/apollo-1.7.1/apollo-adminservice-1.7.1-github/
  30. nohup java -Xmx256m -Xms256m -Xmn128m -Dserver.port=18090 -Deureka.instance.ip-address=114.67.85.120 -jar apollo-adminservice-1.7.1.jar &
  31. cd /mydata/apollo-1.7.1/apollo-portal-1.7.1-github/
  32. nohup java -Xmx512m -Xms512m -Xmn256m -Dserver.port=18070 -jar apollo-portal-1.7.1.jar &
  33. 每个命令输入后等2min再启动下一个服务,因为有依赖关系。
  34. 当然加jvm参数启动的命令参考如下(从startup.sh copy来的),不建议加一大堆这样参数,毕竟自己使用
  35. nohup java -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+DisableExplicitGC -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom -Dserver.port=18080 -Dlogging.file=/opt/logs/100003171/apollo-configservice.log -XX:HeapDumpPath=/opt/logs/100003171/HeapDumpOnOutOfMemoryError/ -XX:+UseParNewGC -Xloggc:/opt/logs/100003171/gc.log -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=60 -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:CMSFullGCsBeforeCompaction=9 -XX:+CMSClassUnloadingEnabled -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=5M -Deureka.instance.ip-address={云服务器公网ip} -Deureka.instance.homePageUrl=http://{云服务器公网ip}:18080 -jar apollo-configservice-1.7.1.jar &
  36. nohup java -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+DisableExplicitGC -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom -Dserver.port=18090 -Dlogging.file=/opt/logs/100003172/apollo-configservice.log -XX:HeapDumpPath=/opt/logs/100003172/HeapDumpOnOutOfMemoryError/ -XX:+UseParNewGC -Xloggc:/opt/logs/100003172/gc.log -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=60 -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:CMSFullGCsBeforeCompaction=9 -XX:+CMSClassUnloadingEnabled -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=5M -Deureka.instance.ip-address={云服务器公网ip} -Deureka.instance.homePageUrl=http://{云服务器公网ip}:18090 -jar apollo-adminservice-1.7.1.jar &
  37. nohup java -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=9 -XX:+DisableExplicitGC -XX:+ScavengeBeforeFullGC -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+ExplicitGCInvokesConcurrent -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -Duser.timezone=Asia/Shanghai -Dclient.encoding.override=UTF-8 -Dfile.encoding=UTF-8 -Djava.security.egd=file:/dev/./urandom -Dserver.port=18070 -Dlogging.file=/opt/logs/100003173/apollo-configservice.log -XX:HeapDumpPath=/opt/logs/100003173/HeapDumpOnOutOfMemoryError/ -XX:+UseParNewGC -Xloggc:/opt/logs/100003173/gc.log -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=60 -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:CMSFullGCsBeforeCompaction=9 -XX:+CMSClassUnloadingEnabled -XX:+PrintGCDateStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=5M -jar apollo-portal-1.7.1.jar &

step3:验证#