编程知识 cdmana.com

Distributed deployment of Apollo configuration center under centos8

Preface

as everyone knows Apollo It is the configuration center of Ctrip , So Chinese documents are also quite perfect , So here is just more details . The main purpose of this article is to record how to be in CentOS8 Next distributed deployment Apollo Configuration center .Apollo The function highlights of :

  • Unified management of different environments 、 Configuration of different clusters
  • Configuration changes take effect in real time ( Hot release )
  • Version release management
  • Grayscale Publishing
  • Rights management 、 Release review 、 Operational audit
  • Client configuration information monitoring
  • Provide Java and .Net Native Client
  • Provide an open platform API
  • Deployment is relatively simple
  • Chinese documents are perfect

Official distributed deployment documentation :

If you just want to build a quick one when you are developing locally Apollo Environment , Refer to the official Quick Start that will do :


preparation

The picture below is Apollo Overview of architecture modules :
 stay CentOS8 Next distributed deployment Apollo Configuration center

The picture above briefly describes Apollo The overall design of , We can see from the bottom up :

  • Config Service Provide read of configuration 、 Push and other functions , The object of service is Apollo client
  • Admin Service Provide configuration changes 、 Release and other functions , The object of service is Apollo Portal( Management interface )
  • Config Service and Admin Service It's all multi instance 、 Stateless deployment , So you need to register yourself with Eureka And keep your heart beating
  • stay Eureka On top of that we put up a layer Meta Server For encapsulation Eureka Service discovery interface
  • Client Access through domain name Meta Server obtain Config Service List of services (IP+Port), And then directly through IP+Port Access the service , At the same time Client The side will do load balance、 Error retry
  • Portal Access through domain name Meta Server obtain Admin Service List of services (IP+Port), And then directly through IP+Port Access the service , At the same time Portal The side will do load balance、 Error retry
  • To simplify deployment , We will actually put Config Service、Eureka and Meta Server Three logical roles are deployed in the same JVM In progress

therefore , We usually deploy two nodes responsible for different roles :ConfigServer( contain config service、admin service、meta server) Nodes and PortalServer node . First, use virtualization software to create two CentOS8 virtual machine , What I use here is VMware:
 stay CentOS8 Next distributed deployment Apollo Configuration center

  • Config-Server Of IP:192.168.243.159
  • Portal-Server Of IP:192.168.243.158

because Apollo Is based on Java Of Spring Boot It's written by the framework , And dependence MySQL Do data storage . So on these two virtual machines , I've installed it in advance MySQL and JDK.

The official requirements for the runtime environment are :

  • Apollo Server side :JDK 1.8+
  • Apollo client :JDK 1.7+
  • MySQL:5.6.5+
  • Suggest OS:CentOS7

And my runtime environment here is :

  • Apollo Server side :JDK 11
  • Apollo client :JDK 11
  • MySQL 8.0.18
  • OS:CentOS8

as follows :

[root@config-server ~]# java -version
java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)
[root@config-server ~]# mysql --version
mysql  Ver 8.0.18 for Linux on x86_64 (Source distribution)
[root@config-server ~]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core) 
[root@config-server ~]# 

Create database

After finishing the preparatory work , The first step is to create the corresponding database . because Apollo Depend on MySQL database , So we need to create and initialize the library table in advance . Distributed deployment Apollo Service needs to be ApolloPortalDB and ApolloConfigDB The two databases are in different MySQL Create on instance .

Of course , If you don't need to be managed separately , You can do it in one MySQL Instance . The official database 、 Table creation and sample data are prepared separately SQL file , We just need to import the database .SQL The address of the document is as follows :

It should be noted that ApolloPortalDB Just deploy one in the production environment , and ApolloConfigDB You need to deploy a set of... In each environment , Such as fat、uat and pro The environment is deployed separately 3 set ApolloConfigDB. Here I am Config-Server and Portal-Server We have deployed one MySQL example .

Put two SQL After the files are imported into the two databases successfully , Database created 、 The table is as follows :
 stay CentOS8 Next distributed deployment Apollo Configuration center
 stay CentOS8 Next distributed deployment Apollo Configuration center


Get installation package

The required installation packages are in common 3 individual :

  • apollo-configservice
  • apollo-adminservice
  • apollo-portal

You can download the official installation package directly , You can also build it from source . Because there is no need to modify the source code , So I download the installation package directly here . See... For download address Github Releases.

Copy the download link to use on the server wget Command download or upload to server after local download .config-server The installation package is as follows :

[root@config-server ~]# cd /usr/local/src
[root@config-server /usr/local/src]# ls
apollo-adminservice-1.7.1-github.zip    apollo-configservice-1.7.1-github.zip
[root@config-server /usr/local/src]# 

portal-server The installation package is as follows :

[root@portal-server ~]# cd /usr/local/src
[root@portal-server /usr/local/src]# ls
apollo-portal-1.7.1-github.zip
[root@portal-server /usr/local/src]# 

Deploy Apollo Config Server

Will compress the package , Unzip it to the appropriate directory :

[root@config-server /usr/local/src]# mkdir /usr/local/apollo-configservice
[root@config-server /usr/local/src]# unzip apollo-configservice-1.7.1-github.zip -d /usr/local/apollo-configservice
[root@config-server /usr/local/src]# mkdir /usr/local/apollo-adminservice
[root@config-server /usr/local/src]# unzip apollo-adminservice-1.7.1-github.zip -d /usr/local/apollo-adminservice/
[root@config-server /usr/local/src]# ls /usr/local/apollo-configservice
apollo-configservice-1.7.1.jar  apollo-configservice-1.7.1-sources.jar  apollo-configservice.conf  config  scripts
[root@config-server /usr/local/src]# ls /usr/local/apollo-adminservice/
apollo-adminservice-1.7.1.jar  apollo-adminservice-1.7.1-sources.jar  apollo-adminservice.conf  config  scripts
[root@config-server /usr/local/src]# 

To configure apollo-configservice Database connection information :

[root@config-server /usr/local/src]# cd /usr/local/apollo-configservice/
[root@config-server /usr/local/apollo-configservice]# vim config/application-github.properties 
# DataSource
spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false
spring.datasource.username = root
spring.datasource.password = 123456a.
  • Correctly filled ApolloConfigDB Database connection string information , Note that there are no spaces after the user name and password !

To configure apollo-adminservice Database connection information :

[root@config-server /usr/local/apollo-configservice]# cd ../apollo-adminservice/
[root@config-server /usr/local/apollo-adminservice]# vim config/application-github.properties 
# DataSource
spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false
spring.datasource.username = root
spring.datasource.password = 123456a.
  • Correctly filled ApolloConfigDB Database connection string information , Note that there are no spaces after the user name and password !

If you need to adjust apollo-configservice and apollo-adminservice Of JVM Launch parameters 、 Service monitoring port and log file storage directory , It can be found in its installation directory scripts/startup.sh Modify in the script :

  • If modification is needed JVM Parameters , You can modify scripts/startup.sh Of JAVA_OPTS part
  • To adjust the log output path of the service , You can modify scripts/startup.sh and apollo-configservice.conf Medium LOG_DIR
  • To adjust the listening port of the service , You can modify scripts/startup.sh Medium SERVER_PORT. In addition, due to apollo-configservice At the same time undertake meta server duty , If you want to modify the port , Be careful to modify ApolloConfigDB.ServerConfig In the table eureka.service.url Configuration items and apollo-portal and apollo-client It's used in meta server Information

start-up apollo-configservice:

[root@config-server /usr/local/apollo-configservice]# scripts/startup.sh 
2020 year  11 month  10 Japan   Tuesday  16:34:22 CST ==== Starting ==== 
Started [20958]
Waiting for server startup...
2020 year  11 month  10 Japan   Tuesday  16:34:38 CST Server started in 15 seconds!
[root@config-server /usr/local/apollo-configservice]# 

Check whether the startup is successful :

[root@config-server /usr/local/apollo-configservice]# jps
1655 apollo-configservice.jar
1807 Jps
[root@config-server /usr/local/apollo-configservice]# netstat -lntp |grep 8080
tcp6       0      0 :::8080            :::*             LISTEN      1655/java           
[root@config-server /usr/local/apollo-configservice]# 

start-up apollo-adminservice:

[root@config-server /usr/local/apollo-adminservice]# scripts/startup.sh 
2020 year  11 month  10 Japan   Tuesday  16:39:46 CST ==== Starting ==== 
Started [1886]
Waiting for server startup...
2020 year  11 month  10 Japan   Tuesday  16:40:01 CST Server started in 15 seconds!
[root@config-server /usr/local/apollo-adminservice]# 

Check whether the startup is successful :

[root@config-server /usr/local/apollo-adminservice]# jps
1655 apollo-configservice.jar
2012 Jps
1886 apollo-adminservice.jar
[root@config-server /usr/local/apollo-adminservice]# netstat -lntp |grep 8090
tcp6       0      0 :::8090          :::*             LISTEN      1886/java           
[root@config-server /usr/local/apollo-adminservice]# 

If you want to stop the service, you should execute the corresponding service directory scripts/shutdown.sh The script can be .


Deploy Apollo Portal Server

Similar to the previous section , Will compress the package , Unzip it to the appropriate directory :

[root@portal-server /usr/local/src]# mkdir /usr/local/apollo-portal
[root@portal-server /usr/local/src]# unzip apollo-portal-1.7.1-github.zip -d /usr/local/apollo-portal/
[root@portal-server /usr/local/src]# ls /usr/local/apollo-portal/
apollo-portal-1.7.1.jar  apollo-portal-1.7.1-sources.jar  apollo-portal.conf  config  scripts
[root@portal-server /usr/local/src]# 

To configure apollo-portal Database connection information :

[root@portal-server /usr/local/src]# cd /usr/local/apollo-portal/
[root@portal-server /usr/local/apollo-portal]# vim config/application-github.properties
# DataSource
spring.datasource.url = jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false
spring.datasource.username = root
spring.datasource.password = 123456a.

And then configuration apollo-portal Of meta service Information .Apollo Portal Need to access different... In different environments meta service(apollo-configservice) Address , So we need to provide this information in the configuration .

By default ,meta service and config service Is deployed in the same JVM process , therefore meta service The address of is config service The address of . The format of the configuration item is ${env}.meta=http://${config-service-url:port}, As shown below :

[root@portal-server /usr/local/apollo-portal]# vim config/apollo-env.properties
dev.meta=http://192.168.243.159:8080
  • If an environment doesn't need it , You can also delete the corresponding configuration item directly , I have deleted other default environments , Only configuration dev.meta

In addition to apollo-env.properties Mode configuration meta service outside ,apollo It also supports specifying at run time meta service( Priority ratio apollo-env.properties high ):

  1. adopt Java System Property ${env}_meta Appoint
    • Can pass Java Of System Property ${env}_meta To specify the
    • Such as java -Ddev_meta=http://config-service-url -jar xxx.jar
    • You can also specify , Such as System.setProperty("dev_meta", "http://config-service-url");
  2. Through the operating system System Environment ${ENV}_META Appoint
    • Such as DEV_META=http://config-service-url
    • Be careful key For all capitals , And in the middle is “_” Separate

start-up apollo-portal:

[root@portal-server /usr/local/apollo-portal]# scripts/startup.sh 
2020 year  11 month  10 Japan   Tuesday  16:56:36 CST ==== Starting ==== 
Started [21010]
Waiting for server startup........
2020 year  11 month  10 Japan   Tuesday  16:57:17 CST Server started in 40 seconds!
[root@portal-server /usr/local/apollo-portal]# 

Check whether the startup is successful :

[root@portal-server /usr/local/apollo-portal]# jps
21010 apollo-portal.jar
21162 Jps
[root@portal-server /usr/local/apollo-portal]# netstat -lntp |grep 8070
tcp6       0      0 :::8070                 :::*                    LISTEN      21010/java          
[root@portal-server /usr/local/apollo-portal]# 

After successful startup , Access... Through a browser portal-server Of 8070 port :
 stay CentOS8 Next distributed deployment Apollo Configuration center

  • The default username and password are :apollo/admin

After successful login , Enter the home page :
 stay CentOS8 Next distributed deployment Apollo Configuration center

You can then go into the sample project and do some testing , See if it works :
 stay CentOS8 Next distributed deployment Apollo Configuration center

So far we have finished Apollo Distributed deployment , It's just a set of environments deployed here , If there are multiple environments , Just repeat the deployment Apollo Config Server Section to deploy multiple Config Server The node can be . And then in Portal Server Of apollo-env.properties Configure these in the configuration file Config Server The access address of the node .

版权声明
本文为[osc_ m3eztdrr]所创,转载请带上原文链接,感谢

Scroll to Top