Distributed deployment of Apollo configuration center under CentOS8

Preface##

As we all know, Apollo is Ctrip's open source configuration center, so the Chinese documents are relatively complete, so I won't go into details here. The main purpose of this article is to record how to deploy Apollo Configuration Center in a distributed manner under CentOS8. Apollo's feature highlights:

The official distributed deployment document:

If you just want to quickly build an Apollo environment during local development, refer to the official Quick Start:


Ready to work##

The following figure is an overview of the Apollo architecture modules:

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

Therefore, we usually deploy two nodes responsible for different roles: ConfigServer (including config service, admin service, meta server) node and PortalServer node. First use virtualization software to create two CentOS8 virtual machines, I use VMware here:

Because Apollo is written based on the Spring Boot framework of Java, and relies on MySQL for data storage. So on these two virtual machines, I have installed MySQL and JDK in advance.

The official requirements for the runtime environment are:

And my runtime environment here is:

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.18for Linux on x86_64(Source distribution)[root@config-server ~]# cat /etc/redhat-release
CentOS Linux release 8.0.1905(Core)[root@config-server ~]# 

Create a database##

After completing the preparations, the first step is to create the corresponding database. Because Apollo relies on the MySQL database, you need to create and complete the initialization of the database tables in advance. Distributed deployment of Apollo services requires the creation of the two databases ApolloPortalDB and ApolloConfigDB on different MySQL instances.

Of course, if you don't need to manage it separately, you can also create it in a MySQL instance. Officially, SQL files are prepared for database, table creation, and sample data. We only need to import the database. The address of the SQL file is as follows:

It should be noted that ApolloPortalDB only needs to be deployed in the production environment, and ApolloConfigDB needs to be deployed in each environment, such as fat, uat and pro environments to deploy three sets of ApolloConfigDB. I have deployed a MySQL instance in Config-Server and Portal-Server respectively.

After successfully importing the two SQL files into the two databases, the created databases and tables are as follows:


Get the installation package##

There are 3 installation packages required:

You can download the official installation package directly, or you can build it from the source code. Since there is no need to modify the source code, I download the installation package directly here. See Github Releases for the download address.

Copy the download link and use the wget command to download on the server or upload it to the server after downloading locally. The installation package of config-server 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]# 

The installation package of portal-server 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

Unzip the compressed package to a suitable 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]# 

Configure the database connection information of apollo-configservice:

[ 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.

Configure the database connection information of apollo-adminservice:

[ 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.

If you need to adjust the configuration of apollo-configservice and apollo-adminservice's JVM startup parameters, service monitoring port, and log file storage directory, you can modify it in the scripts/startup.sh under the installation directory:

Start apollo-configservice:

[ root@config-server /usr/local/apollo-configservice]# scripts/startup.sh 
2020 Tuesday, November 10,:34:22 CST ==== Starting ==== 
Started [20958]
Waiting for server startup...Tuesday, November 10, 2020 16:34:38 CST Server started in15 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       00:::8080:::*             LISTEN      1655/java           
[ root@config-server /usr/local/apollo-configservice]# 

Start apollo-adminservice:

[ root@config-server /usr/local/apollo-adminservice]# scripts/startup.sh 
2020 Tuesday, November 10,:39:46 CST ==== Starting ==== 
Started [1886]
Waiting for server startup...Tuesday, November 10, 2020 16:40:01 CST Server started in15 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       00:::8090:::*             LISTEN      1886/java           
[ root@config-server /usr/local/apollo-adminservice]# 

If you want to stop the service, just execute the scripts/shutdown.sh in the corresponding service directory.


Deploy Apollo Portal Server

Similar to the previous section, unzip the compressed package to a suitable 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]# 

Configure the database connection information for apollo-portal:

[ 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.

Then it is to configure the meta service information of apollo-portal. Apollo Portal needs to access different meta service (apollo-configservice) addresses in different environments, so we need to provide this information in the configuration.

By default, meta service and config service are deployed in the same JVM process, so the address of meta service is the address of config service. 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

In addition to configuring meta service through apollo-env.properties, apollo also supports specifying meta service at runtime (priority is higher than apollo-env.properties):

  1. Specified by Java System Property ${env}_meta
  1. Specified by the operating system's System Environment ${ENV}_META

Start apollo-portal:

[ root@portal-server /usr/local/apollo-portal]# scripts/startup.sh 
2020 Tuesday, November 10,:56:36 CST ==== Starting ==== 
Started [21010]
Waiting for server startup........Tuesday, November 10, 2020 16:57:17 CST Server started in40 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       00:::8070:::*                    LISTEN      21010/java          
[ root@portal-server /usr/local/apollo-portal]# 

After the startup is successful, access port 8070 of portal-server through a browser:

After successful login, enter the home page:

Then you can enter the sample project to do some tests to see if it works normally:

At this point we have completed the distributed deployment of Apollo. Here is just one set of environments. If there are multiple sets of environments, you only need to repeat the steps in the Apollo Config Server section to deploy multiple Config Server nodes. Then configure the access addresses of these Config Server nodes in the apollo-env.properties configuration file of Portal Server.

Recommended Posts

Distributed deployment of Apollo configuration center under CentOS8
Installation and configuration of redis under centos7
Installation and configuration of rsync server under CentOS 6.5
Environment configuration of JDK, mysql and tomcat under Centos7
[CentOS environment deployment] Java7/Java8 deployment under CentOS
Centos7.4 deployment configuration Elasticsearch5.6 cluster
Deployment of graphite on centos7
Implementation of CentOS8.0 Network Configuration
Detailed explanation of Spark installation and configuration tutorial under centOS7
Centos7 installation and configuration of Jenkins
Centos6.5 installation and deployment of KVM
RabbitMQ cluster deployment record under Centos6.9
Elasticsearch cluster deployment record under CentOS7
Detailed examples of Centos6 network configuration
CentOS deployment method of flask project
FFmpeg environment deployment record under centos7
Erlang 20.2 installation and deployment under CentOS 7
PPTP environment deployment record under Centos
Using Elastic Stack on CentOS 8: Deployment and authentication configuration of Elasticsearch/Kibana 7.8
Installation and use of Mysql under CentOS
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
Centos-6.5 installation and deployment of LNMP environment
Zabbix installation and deployment and localization under CentOS
Jenkins installation and deployment tutorial under CentOS 7
The fourth installment of Zabbix under CentOs7
Complete deployment record for LDAP under Centos7.2
CentOS8 yum/dnf configuration method of domestic sources
Centos7 installation and deployment of Airflow detailed
Build a ScaleIO distributed storage cluster under CentOS7
CentOS 7 installation and configuration graphic tutorials under VMware10
The actual combat of rpm packaging under CentOS6
Installation and configuration of CentOS 7 in VMware Workstation
MySQL 8.0 installation and deployment under CentOS, super detailed!
Explain the implementation of Centos8 static IP configuration
Installing CentOS 6 and SSH configuration under Windows 8 Hyper-V
Modify the default encoding of mysql5.6 under CentOS7
Non-Root installation of Microsoft R Open under Centos
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
From installation to entry of FastDFS under Centos7
CentOS7.0 network configuration
CentOS 7.0 network configuration
CentOS7 basic configuration
Centos MySQL8 configuration
CentOS deployment Harbor
Installation and cracking of confluence6.3 operation records under Centos
Installation and cracking of Jira7 operation records under Centos
Use Cobbler to automate batch deployment of CentOS / Ubuntu
Detailed explanation of static DNS configuration under Ubuntu system
Summary of linux (centos) project deployment phase related commands
SFTP dual-machine high availability environment deployment record under Centos
Rapid deployment of Kubernetes (k8s) cluster in CentOS7 environment