spring cloud integrated distributed configuration center apollo (stand-alone deployment apollo)

First, what is apollo?

Apollo (Apollo) is a research and development department Ctrip framework for distributed configuration center, capable of centralized management applications in different environments, different cluster configuration, the configuration changes can be pushed to real-time application side, and have standardized permissions, process control and other features, applicable to micro-service configuration management scenarios.

image.png

Second, why should I integrate apollo?

Apollo features:
image.png

Since the spring cloud config apollo compared to other mainstream distribution center and more advanced features visual configuration management and publishing of gray, so I plan to give up the spring cloud config switch to apollo.

Third, the deployment of apollo

1. to github apollo the release page to download the required three zip package.
https://github.com/ctripcorp/apollo/releases
image.png

2. Install mysql, and then run the following two initialization scripts apollo, two basic library initialization.

https://github.com/nobodyiam/apollo-build-scripts/blob/master/sql/apolloportaldb.sql

https://github.com/nobodyiam/apollo-build-scripts/blob/master/sql/apolloconfigdb.sql

3. The three zip and unzip the package uploaded to the server, each zip unpack it has a application-github.properties file, modify the mysql ip address, port, user name, password information in it, points to a local mysql database, then pay attention to the application-github.properties file in the same directory jar package, the following is my content directory structure and file application-github.properties.

[root@localhost apollo]# ls
admin-service  config-service  protal
[root@localhost admin-service]# ls
apollo-adminservice-1.4.0.jar  application-github.properties  app.properties  shutdown.sh  startup.sh
[root@localhost protal]# ls
apollo-env.properties  apollo-portal-1.4.0.jar  application-github.properties  app.properties  shutdown.sh  startup.sh
[root@localhost config-service]# ls
apollo-configservice-1.4.0.jar  application-github.properties  app.properties  shutdown.sh  startup.sh
spring.datasource.url = jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123456

4. Modify apollo-env.properties files in the directory portal, fill each environment configuration center address corresponding to the stand-alone version so I have to fill local:

[root@localhost protal]# cat apollo-env.properties 
local.meta=http://localhost:8080
dev.meta=http://localhost:8080
fat.meta=http://localhost:8080
uat.meta=http://localhost:8080
lpt.meta=${lpt_meta}
pro.meta=http://localhost:8080

The three jar package run sequentially:
Java -jar Apollo-ConfigService-1.4.0.jar
Java -jar Apollo-AdminService-1.4.0.jar
Java -jar Apollo-Portal-1.4.0.jar

6. The browser access http://192.168.153.131:8070 , see the following interface description successful launch, the initial user name and password is: apollo / admin
image.png

Four, spring cloud (boot) client integration apollo

1. In an application dependent maven pom.xml add the following:

        <!-- 阿波罗配置中心客户端 -->
        <dependency>
            <groupId>com.ctrip.framework.apollo</groupId>
            <artifactId>apollo-client</artifactId>
            <version>1.1.0</version>
        </dependency>

2. Add app.properties file in src / main / resources / META-INF directory, as follows:

app.id=你自己的应用唯一标识,和apollo管理后台添加的项目appid对应
apollo.autoUpdateInjectedSpringProperties=true

application.yml file to add the following configuration:

apollo:
  meta: http://部署apollo服务器的ip:8080
  bootstrap:
    enabled: true
    eagerLoad:
      enabled: true

3. Add the following attributes in the code and annotations can be configured to use the background information apollo, apollo management background after modifying one second to take effect without restarting the application server:
image.png

    @Value("${name}")
    private String name;

Follow continue to update the distributed deployment apollo.

Guess you like

Origin www.cnblogs.com/powerjiajun/p/11295340.html