Apollo Client User Guide

Apollo Client User Guide


version number


Apollo:1.7.1

Client


After completing the Apollo deployment, use the browser to enter the 8070port.
Here are some examples of common operations

Use the default account password apollo/admin to log in

The page prompts a configuration error

New Project

 

According to the database configuration, the dev environment is created by default

New namespace

Add and publish configuration in the namespace

Read configuration

View application access documents

Application access

JAVA

Springboot recommended configuration

Step 1: Create a bootstrap.properties file and apollo-env.properties file in the resource directory  

Create a new bootstrap.properties file in the resource directory

# Apollo配置

# AppId
app.id=WXOauthAPI
# meta server地址,为方便区分不同环境,配置到apollo-env.properties
# apollo.meta=xxx.xxx.xxx.xxx
# 在应用启动阶段是否向Spring容器注入被托管的properties文件配置信息
apollo.bootstrap.enabled=true
# 指定命名空间
apollo.bootstrap.namespaces=application
# 将Apollo配置加载提到初始化日志系统之前
apollo.bootstrap.eagerLoad.enabled=true

Create a new apollo-env.properties file in the resource directory

# 配置apollo不同环境的地址
## 若为集群部署,支持输入多个地址,使用逗号(,)分隔

# dev(开发环境)
dev.meta=http://172.16.2.14:8080
# fat(测试环境)
#fat.meta=http://apollo.fat.xxx.com
# uat(预生产环境)
#uat.meta=http://apollo.uat.xxx.com
# pro(生产环境)
#pro.meta=http://apollo.xxx.com

 

Step on the pit

An error was reported when the project started

Error message This must be noted: If it is a cloud server, be sure to pay attention to the error message, because the cloud server is a random IP address, which may not be the same as the actual server address, so an error will be reported

Sync config failed, will retry. Repository class com.ctrip.framework.apollo.internals.RemoteConfigRepository, reason: Load Apollo Config failed - appId: bitongchong_bos, cluster: default, namespace: application, url: http://xxx.xxx.xxx.xxx:8080/configs/bitongchong_bos/default/application?ip=192.168.102.1&messages=%7B%22details%22%3A%7B%22bitongchong_bos%2Bdefault%2Bapplication%22%3A6%7D%7D&releaseKey=20190803112627-2b5dd0e414976d16 [Cause: Could not complete get operation [Cause: connect timed out]]

Solution
This error is due to the eureka entity address being resolved to the internal network by default when deployed to the cloud server, and the external network address needs to be mapped to modify the startup file

Docker deployment solution

Modify the startup parameters of the apollo-configservice and apollo-adminservice containers (because the two containers have the same structure except for the name, only one modification example is given)

 

 

Here, only apollo-configservice is used to modify the instance, and the apollo-adminservice is modified in the same way. You only need to modify it.

Enter the container

docker exec -it apollo-configservice bash

 Modify the startup file

vi /apollo-configservice/scripts/startup.sh

 Find the JAVA_OPTS instruction, add eureka parameters at the end

export JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/ -Deureka.instance.ip-address=172.16.5.31"

Exit docker: exit. You must exit docker to restart the docker container

Restart container

docker restart apollo-configservice 

Virtual machine deployment solution

The second step:

Configure the test environment: Add -Denv=environment name to the VM options of the running environment, for example: -Denv=dev

Step 3: Specific code implementation: In fact, you only need to use Value annotation to read the value of key as test. 123 is the default value. When it cannot be read, the default value is 123

@Value("${test:123}") 
private String test; 

// The first test method 
@RequestMapping("/ApolloInfo/get") 
public String getApolloInfo() { 

    return "123456---"+test; 
}

 

reference

Problems encountered

After deleting the namespace, re-creating the namespace with the same name shows that the same namespace already exists

Problem Description

 

 

solution

Normal deletion does not clear the data corresponding to the namespace, just use the administrator tool to delete the namespace.

 

Guess you like

Origin blog.csdn.net/xulong5000/article/details/113590429