摩洛哥网站后缀,广州公司注册多久时间,网页版游戏入口,网页设计与制作大全文章目录一、介绍1. 痛点2. 为什么选择Apollo二、快速开始2.1. 安装mysql2.2. 下载脚本2.3. 初始化脚本三、服务端配置3.1. 下载安装包3.2. 创建目录3.3. 解压3.4. 配置3.5. 启动3.6. 防火墙策略3.6. 效果验证四、测试4.1. 引入依赖4.2. 配置4.3. 测试类4.4. 启动项目4.5. 效果…
文章目录一、介绍1. 痛点2. 为什么选择Apollo二、快速开始2.1. 安装mysql2.2. 下载脚本2.3. 初始化脚本三、服务端配置3.1. 下载安装包3.2. 创建目录3.3. 解压3.4. 配置3.5. 启动3.6. 防火墙策略3.6. 效果验证四、测试4.1. 引入依赖4.2. 配置4.3. 测试类4.4. 启动项目4.5. 效果图一、介绍 Apollo阿波罗是携程框架部门研发的分布式配置中心能够集中化管理应用不同环境、不同集群的配置配置修改后能够实时推送到应用端并且具备规范的权限、流程治理等特性适用于微服务配置管理场景。 – 摘自Apollo官网 1. 痛点
修改配置后需要重启项目 大量重复的配置不便于管理
2. 为什么选择Apollo
Apollo VS Spring Cloud Config Spring Cloud Config 依赖于GitHub所有配置都是写在文件中然后通过提交GitHub上来生效的不同的环境用不用的文件区分 Apollo VS 阿里云应用配置管理ACM
依赖于阿里云不便于后续迁移 阿里云已经放弃了该项目不再维护
二、快速开始 这里安装mysql需要提前安装docker环境 docker yum 安装 https://blog.csdn.net/weixin_40816738/article/details/121595991 2.1. 安装mysql
docker mysql:8.0.27
2.2. 下载脚本
链接https://github.com/apolloconfig/apollo/tree/master/scripts/sql
2.3. 初始化脚本 直接运行脚本不需要提前创建数据库 初始化后就会有2个数据库
三、服务端配置
3.1. 下载安装包
下载链接https://github.com/ctripcorp/apollo/releases
wget https://github.com/apolloconfig/apollo/releases/download/v1.9.2/apollo-adminservice-1.9.2-github.zipwget https://github.com/apolloconfig/apollo/releases/download/v1.9.2/apollo-configservice-1.9.2-github.zipwget https://github.com/apolloconfig/apollo/releases/download/v1.9.2/apollo-portal-1.9.2-github.zip3.2. 创建目录
mkdir apollo-adminservice-1.9.2
mkdir apollo-configservice-1.9.2
mkdir apollo-portal-1.9.23.3. 解压
unzip apollo-adminservice-1.9.2-github.zip
unzip apollo-configservice-1.9.2-github.zip
unzip apollo-portal-1.9.2-github.zip3.4. 配置
apollo-adminservice配置
cd apollo-adminservice-1.9.2/config/
vim application-github.properties这里需要修改数据的连接地址、用户名、密码 apollo-configservice配置
cd apollo-adminservice-1.9.2/config
application-github.properties这里需要修改数据的连接地址、用户名、密码 apollo-portal配置
cd apollo/apollo-portal-1.9.2/config
vim application-github.properties这里需要修改数据的连接地址、用户名、密码 vim apollo-env.properties将其他环境都注释掉打开第一个和第二个即可 3.5. 启动
apollo-configservice启动
cd apollo/apollo-configservice-1.9.2/script
./startup.shapollo-adminservice启动
cd apollo/apollo-adminservice-1.9.2/script
./startup.shapollo-portal启动
cd apollo/apollo-portal-1.9.2/script
./startup.sh如无意外至此adminservice、configservice、portal都起来了
3.6. 防火墙策略
firewall-cmd --zonepublic --add-port3306/tcp --permanent
firewall-cmd --zonepublic --add-port8080/tcp --permanent
firewall-cmd --zonepublic --add-port8070/tcp --permanent
firewall-cmd --reload
systemctl status firewalld3.6. 效果验证
http://192.168.159.139:8080/ http://192.168.159.139:8070/signin 初始账号密码是apollo/admin
四、测试
4.1. 引入依赖
dependencygroupIdcom.ctrip.framework.apollo/groupIdartifactIdapollo-client/artifactIdversion1.5.0/version/dependency4.2. 配置
application.properties
server.port9000# 配置Appid
app.idhello# 配置 Apollo Meta Server
apollo.metahttp://192.168.159.139:8080/# 配置本地缓存路径
apollo.cacheDirC:/Users/gblfy/Desktop/apollo/data# 配置Environment
envDEVapollo.bootstrap.enabledtrue
4.3. 测试类
package com.gblfy.apolloclient.controller;import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;RestController
RequestMapping(/hello)
public class HelloController {Value(${my.name})private String name;GetMapping(/index)public String getName() {return name;}
}
4.4. 启动项目
4.5. 效果图
http://localhost:9000/hello/index