Configuration Center Apollo installation and configuration

Official website address: http://apollo.auto/

GitLab address: https://github.com/ctripcorp/apollo

Overall architecture

Configuration Center Apollo installation and configuration

  1. User configuration release in Portal operation

  2. Portal call Admin Service interface operation release

  3. After Admin Service publishes the configuration, it sends ReleaseMessage to each Config Service

  4. After the Config Service receives the ReleaseMessage, it notifies the corresponding client

Realization principle

Configuration Center Apollo installation and configuration
The figure above briefly describes the implementation principle of the Apollo client:

  1. The client and the server maintain a long connection, so that the configuration update can be pushed as soon as possible. (Achieved by Http Long Polling)

  2. The client will also periodically pull the latest configuration of the application from the Apollo configuration center server.
  • This is a fallback mechanism, in order to prevent the push mechanism from failing and the configuration is not updated

  • The client will report the local version when pulling regularly, so in general, for the operation of pulling regularly, the server will return 304-Not Modified

  • By default, the timing frequency is pulled every 5 minutes, and the client can also be overridden by specifying System Property: apollo.refreshInterval at runtime, in minutes.

1. After the client obtains the latest configuration of the application from the Apollo configuration center server, it will be saved in the memory

2. The client will cache a copy of the configuration obtained from the server in the local file system

  • When the service is unavailable or the network is unavailable, the configuration can still be restored from the local

1. The application can get the latest configuration from the Apollo client and subscribe to configuration update notifications

MySQL installation

Version requirements: 5.6.5+
Host: 10.2.42.28
Clear mysql dependent packages:

rpm -qa | grep mysql

yum remove mysql-libs

Install mysql5.7: Installation sequence: common→libs→client→server

rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm

Successful installation interface:

[root@DCA-APP-COM-apollo02 mysql]# rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm

warning: mysql-community-common-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-common-5.7.26-1.e################################# [100%]

[root@DCA-APP-COM-apollo02 mysql]# rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm

warning: mysql-community-libs-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-libs-5.7.26-1.el7################################# [100%]

[root@DCA-APP-COM-apollo02 mysql]# rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm

warning: mysql-community-client-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-client-5.7.26-1.e################################# [100%]

[root@DCA-APP-COM-apollo02 mysql]# rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm

warning: mysql-community-server-5.7.26-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY

Preparing...                          ################################# [100%]

Updating / installing...

   1:mysql-community-server-5.7.26-1.e################################# [100%]

Start mysql:

service mysqld start

mysql initialization:

[root@DCA-APP-COM-apollo02 mysql]# grep 'temporary password' /var/log/mysqld.log

2019-07-17T14:10:02.559365Z 1 [Note] A temporary password is generated for root@localhost: %hNW)P3Ly,8v

[root@DCA-APP-COM-apollo02 mysql]# mysql -uroot -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.7.26

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# 更改密码长度

mysql> set global validate_password_length=1;

Query OK, 0 rows affected (0.00 sec)

# 更改密码强度

mysql> set global validate_password_policy=0;

Query OK, 0 rows affected (0.00 sec)

mysql> set password for root@localhost=password('123456');

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> grant all privileges on *.* to 'root' @'%' identified by '123456';

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

Apollo database creation: SQL download by yourself on the official website

mysql> source apolloconfigdb.sql;

mysql> source apolloportaldb.sql;

Msyql connection user authorization:

mysql> grant all privileges on ApolloConfigDB.* to Apollo@'%' IDENTIFIED BY 'Apollo' ;

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> grant all privileges on ApolloPortalDB.* to Apollo@'%';

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

Database configuration changes:

ApolloPortalDB:
Configuration Center Apollo installation and configuration

ApolloConfigDB:
Configuration Center Apollo installation and configuration

Apollo installation

Official address: https://github.com/ctripcorp/apollo
This test version is: 0.10.2
Download address: https://github.com/ctripcorp/apollo/releases/tag/v0.10.2
apollo-adminservice-0.10 .2-github.zip
apollo-configservice-0.10.2-github.zip
apollo-portal-0.10.2-github.zip

apollo-config

Host: 10.2.42.27
Create apollo user:

groupadd apollo && useradd -g apollo apollo

Configure configserver:

cd /home/apollo/

mkdir apollo-config

unzip apollo-configservice-0.10.2-github.zip -d apollo-config

ApolloconfigDB configuration:

vim apollo-config/config/application-github.properties

# DataSource

spring.datasource.url = jdbc:mysql://10.2.42.28:3306/ApolloConfigDB?characterEncoding=utf8

spring.datasource.username = Apollo

spring.datasource.password = Apollo

Log path and JVM parameter modification: part of the configuration, the following configuration does not need to be modified

vim apollo-config/scripts/startup.sh

# 修改日志路径

LOG_DIR=/home/apollo/logs/100003171

# 默认端口

SERVER_PORT=8080

# 默认注释看需求打开

## Adjust memory settings if necessary

export JAVA_OPTS="-Xms6144m -Xmx6144m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=4096m -XX:MaxNewSize=4096m -XX:SurvivorRatio=8"

Start Apollo-configservice:

cd /home/apollo/

chown -R apollo.apollo *

su apollo

./apollo-config/scripts/startup.sh

Successful startup:

Thu Jul 18 15:06:53 CST 2019 ==== Starting ==== 

Started [53700]

Waiting for server startup......

Thu Jul 18 15:07:24 CST 2019 Server started in 30 seconds!

apollo-admin

Host: 10.2.42.28

groupadd apollo && useradd -g apollo apollo

cd /home/apollo/

mkdir {apollo-admin,apollo-portal}

unzip apollo-adminservice-0.10.2-github.zip -d apollo-admin

unzip apollo-portal-0.10.2-github.zip -d apollo-portal

ApolloconfigDB configuration:

cd apollo-admin

vim config/application-github.properties

# DataSource

spring.datasource.url = jdbc:mysql://10.2.42.28:3306/ApolloConfigDB?characterEncoding=utf8

spring.datasource.username = Apollo

spring.datasource.password = Apollo

Log path and JVM parameter configuration: part of the configuration, the latter configuration does not need to be modified

vim scripts/startup.sh

#!/bin/bash

SERVICE_NAME=apollo-adminservice

## Adjust log dir if necessary

LOG_DIR=/home/apollo/logs/100003172

## Adjust server port if necessary

SERVER_PORT=8090

## Adjust memory settings if necessary

export JAVA_OPTS="-Xms2560m -Xmx2560m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=8"

Start apollo-admin:

cd /home/apollo/

chown -R apollo.apollo *

su apollo

./scripts/startup.sh

Thu Jul 18 16:17:32 CST 2019 ==== Starting ==== 

Started [56497]

Waiting for server startup......

Thu Jul 18 16:18:02 CST 2019 Server started in 30 seconds!

apollo-portal

Host: 10.2.42.28
apolloportlDB configuration:

cd /home/apollo/apollo-portal

vim config/application-github.properties

# DataSource

spring.datasource.url = jdbc:mysql://10.2.42.28:3306/ApolloPortalDB?characterEncoding=utf8

spring.datasource.username = Apollo

spring.datasource.password = Apollo

configservice configuration: a set of portal can manage multiple configservices, or it can be directly configured in the startup.sh script

vim config/apollo-env.properties

local.meta=http://localhost:8080

dev.meta=http://10.2.42.27:8080

fat.meta=http://10.2.42.27:8080

uat.meta=${lpt_meta}

lpt.meta=${lpt_meta}

pro.meta=${lpt_meta}

Log path and JVM parameter modification: part of the configuration, the following configuration does not need to be modified

vim scripts/startup.sh

#!/bin/bash

SERVICE_NAME=apollo-portal

## Adjust log dir if necessary

LOG_DIR=/home/apollo/logs/100003173

## Adjust server port if necessary

SERVER_PORT=8070

## Adjust memory settings if necessary

export JAVA_OPTS="-Xms2560m -Xmx2560m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=1536m -XX:MaxNewSize=1536m -XX:SurvivorRatio=8"

apollo-portal starts:

su apollo

./scripts/startup.sh

Thu Jul 18 16:25:55 CST 2019 ==== Starting ==== 

Started [56773]

Waiting for server startup...

Thu Jul 18 16:26:10 CST 2019 Server started in 15 seconds!

Apollo use

Server page display: 10.2.42.27:8080
Configuration Center Apollo installation and configuration

Configuration center page display: 10.2.42.28:8070
apollo/admin
Configuration Center Apollo installation and configuration

Project creation:

Configuration Center Apollo installation and configuration

Configuration Center Apollo installation and configuration

Guess you like

Origin blog.51cto.com/15080014/2654773