And build client applications distributed configuration center Apollo

In order to unify management of micro-service profile, dynamic profile of refresh, two common ways to Apollo, SpringCloudConfig , with respect to both the main difference is:

Apollo configuration file stored in the database, SpringCloudConfig stored in Git inside

A build process

Data in this chapter demonstrate ways to build Apollo, detailed steps are as follows:

1. Download aploll Configuration Center

Download: https: //github.com/nobodyiam/apollo-build-scripts

After downloading unzip a local First, get two sql files sql folder, connect the server address, run create these two databases.

2, uploaded to the server

Apollo-build-scripts-master.zip to upload files to the server, I upload / use / local directory, unzip the zip file upload.

3, modify the file demo.sh

Edit demo.sh file, modify ApolloPortalDB and ApolloConfigDB related database connection string information.

#apollo config db info
apollo_config_db_url=jdbc:mysql://数据库:3306/ApolloConfigDB?characterEncoding=utf8
apollo_config_db_username=用户名
apollo_config_db_password=密码(如果没有密码,留空即可)

# apollo portal db info
apollo_portal_db_url=jdbc:mysql://数据库:3306/ApolloPortalDB?characterEncoding=utf8
apollo_portal_db_username=用户名
apollo_portal_db_password=密码(如果没有密码,留空即可)

And then import the file under two sql sql file, which is to create two databases, ApolloPortalDB and ApolloConfigDB, as for the role of both libraries, please see the official documentation on their own right.

Modify meta server for deploying server address:

# meta server url
config_server_url=http://192.168.10.130:8080
admin_server_url=http://192.168.10.130:8090
eureka_service_url=$config_server_url/eureka/
portal_url=http://192.168.10.130:8070

Fill according to their own circumstances.

4. Start Apollo
./demo.sh start

As shown in FIG lasts about 1 minute after the activation, as shown below:

address:

Default Password: apollo admin

Create a project:

Create a configuration:

Fill key, value can be submitted:

Second, client integration profiles

1, the local configuration is stored in the Apollo platform.

The properties configuration file format to paste the contents of the text.

Conversion tool: http: //www.toyaml.com/index.html

2, dependent on the introduction Maven
<dependency>
    <groupId>com.ctrip.framework.apollo</groupId>
    <artifactId>apollo-client</artifactId>
    <version>1.0.0</version>
</dependency>
<dependency>
    <groupId>com.ctrip.framework.apollo</groupId>
    <artifactId>apollo-core</artifactId>
    <version>1.0.0</version>
</dependency>
3. Create application.properties
app.id=mayikt644064779

apollo.meta=http://192.168.212.236:8080
4, the project started to open the configuration file Apollo

@EnableApolloConfig

运行后,可以在 eureka 中看到注册的客户端:

5、本地缓存

项目启动后会在本地缓存一份,详细可见

C:\opt\settings\server.properties(Windows)

我创建了一个java相关的公众号,用来记录自己的学习之路,感兴趣的小伙伴可以关注一下微信公众号哈:niceyoo

Guess you like

Origin www.cnblogs.com/niceyoo/p/11210267.html