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:修改下面三个目录内的文件,内容改为数据库地址和用户密码
apollo-adminservice-1.7.1-github\config\application-github.properties
apollo-configservice-1.7.1-github\config\application-github.properties
apollo-portal-1.7.1-github\config\application-github.properties
2:自定义端口,三个服务端口分别如下
apollo-configservice 18080 注册中心地址
apollo-adminservice 18090
apollo-portal 18070 门户登陆端口
apollo-configservice不以8080端口启动的情况下,要修改ApolloConfigDB库的ServerConfig表的eureka.service.url的value值为http://localhost:18080/eureka/,我是单机环境,因此是localhost,端口从数据库默认的8080改为18080
我自己只是使用了dev环境,其他没使用,因此我的G:\apollo-portal-1.7.1-github\config\apollo-env.properties内容如下
local.meta=http://localhost:18080
dev.meta=http://localhost:18080
#fat.meta=http://fill-in-fat-meta-server:8080
#uat.meta=http://fill-in-uat-meta-server:8080
lpt.meta=${lpt_meta}
#pro.meta=http://fill-in-pro-meta-server:8080
3.上传并启动
上传下面三个文件夹到服务器/mydata/apollo-1.7.1目录下
apollo-adminservice-1.7.1
apollo-configservice-1.7.1
apollo-portal-1.7.1
4.启动
启动顺序configservice->adminservice->portal
nohup java -Dserver.port=18080 -Deureka.instance.ip-address={云服务器公网ip} -Deureka.instance.homePageUrl=http://{云服务器公网ip}:18080 -jar apollo-configservice-1.7.1.jar &
nohup java -Dserver.port=18090 -Deureka.instance.ip-address={云服务器公网ip} -Deureka.instance.homePageUrl=http://{云服务器公网ip}:18090 -jar apollo-adminservice-1.7.1.jar &
nohup java -Dserver.port=18070 -jar apollo-portal-1.7.1.jar &
cd /mydata/apollo-1.7.1/apollo-configservice-1.7.1-github/
nohup java -Xmx256m -Xms256m -Xmn128m -Dserver.port=18080 -Deureka.instance.ip-address=114.67.85.120 -jar apollo-configservice-1.7.1.jar &
cd /mydata/apollo-1.7.1/apollo-adminservice-1.7.1-github/
nohup java -Xmx256m -Xms256m -Xmn128m -Dserver.port=18090 -Deureka.instance.ip-address=114.67.85.120 -jar apollo-adminservice-1.7.1.jar &
cd /mydata/apollo-1.7.1/apollo-portal-1.7.1-github/
nohup java -Xmx512m -Xms512m -Xmn256m -Dserver.port=18070 -jar apollo-portal-1.7.1.jar &
每个命令输入后等2min再启动下一个服务,因为有依赖关系。
当然加jvm参数启动的命令参考如下(从startup.sh copy来的),不建议加一大堆这样参数,毕竟自己使用
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 &
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 &
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 &