apollo 使用源码本地安装

1.下载git项目

地址:https://github.com/apolloconfig/apollo

git clone https://github.com/apolloconfig/apollo.git

2.准备工作,创建mysql数据库

脚本地址:https://github.com/apolloconfig/apollo-build-scripts/tree/master/sql

本地mysql两个脚本都执行

3.配置项目数据库连接信息

Apollo服务端需要知道如何连接到你前面创建的数据库,所以需要编辑build.sh,修改ApolloPortalDB和ApolloConfigDB相关的数据库连接串信息。

文件位置:./scripts/build.sh

注意:填入的用户需要具备对ApolloPortalDB和ApolloConfigDB数据的读写权限。

#apollo config db info
apollo_config_db_url="jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai"
apollo_config_db_username=用户名
apollo_config_db_password=密码(如果没有密码,留空即可)

# apollo portal db info
apollo_portal_db_url="jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai"
apollo_portal_db_username=用户名
apollo_portal_db_password=密码(如果没有密码,留空即可)

# meta server url, different environments should have different meta server addresses
dev_meta=http://localhost:8080
fat_meta=http://localhost:8080
uat_meta=http://localhost:8080
pro_meta=http://localhost:8080

注意:不要修改build.sh的其它部分

扫描二维码关注公众号,回复: 15022542 查看本文章

4.启动Apollo配置中心

确保8070、8080、8090端口不被占用

lsof -i:8080

 执行脚本进行打包

//项目根目录
./scripts/build.sh

 打包成功jar文件分别在

./apollo-configservice/target/apollo-configservice-1.9.1.jar

./apollo-adminservice/target/apollo-adminservice-1.9.1.jar

./apollo-portal/target/apollo-portal-1.9.1.jar

分别执行三个jar包

java -jar ./apollo-configservice/target/apollo-configservice-1.9.1.jar
java -jar ./apollo-adminservice/target/apollo-adminservice-1.9.1.jar
java -jar ./apollo-portal/target/apollo-portal-1.9.1.jar

5.打开页面

http://localhost:8070/

用户名:apollo

密码:admin

6.踩坑

6.1 log报错,没找到文件夹

分别修改apollo-configservice、apollo-adminservice、apollo-portal三个项目下的application.yml文件中日志地址配置,要确保相关目录下有logs文件夹。

如我当前的配置,启动目录在apollo项目根目录,需要在根目录下创建好logs文件夹

6.2 启动portal报错

Error creating bean with name 'springSecurityFilterChain' defined in class path resource

这个没找到原因,刚开始用的master分支,一直报上面的错误,起不起来portal项目

后来改到了release分支重新打包,解决了,可能是master分支还不稳定,有bug

6.3 portal启动起来了,一直报健康检测日志,但apollo访问均正常

Env health check failed for 1 times which less than down threshold. down threshold:2, env: DEV, meta server address: http://localhost:8080

注册用的是ip地址,可能与localhost不匹配,顾健康检查报错,localhost改为本机的外网ip地址,解决了

教程地址:

Apollo

猜你喜欢

转载自blog.csdn.net/chen_peng7/article/details/123063359
今日推荐