配置中心Apollo搭建全过程

配置中心Apollo搭建全过程

用户在Portal操作配置发布

Portal调用Admin Service的接口操作发布

Admin Service发布配置后,发送ReleaseMessage给各个Config Service

Config Service收到ReleaseMessage后,通知对应的客户端

实现原理

配置中心Apollo搭建全过程


上图简要描述了Apollo客户端的实现原理:

客户端和服务端保持了一个长连接,从而能第一时间获得配置更新的推送。(通过Http Long Polling实现)

客户端还会定时从Apollo配置中心服务端拉取应用的最新配置。

这是一个fallback机制,为了防止推送机制失效导致配置不更新

客户端定时拉取会上报本地版本,所以一般情况下,对于定时拉取的操作,服务端都会返回304 - Not Modified

定时频率默认为每5分钟拉取一次,客户端也可以通过在运行时指定System Property: apollo.refreshInterval来覆盖,单位为分钟。

客户端从Apollo配置中心服务端获取到应用的最新配置后,会保存在内存中

客户端会把从服务端获取到的配置在本地文件系统缓存一份

在遇到服务不可用,或网络不通的时候,依然能从本地恢复配置

应用程序可以从Apollo客户端获取最新的配置、订阅配置更新通知

MySQL安装

版本要求:5.6.5+
主机:10.2.42.28
清除mysql依赖包:

rpm -qa | grep mysql yum remove mysql-libs

安装mysql5.7:安装顺序: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

安装成功界面:

[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%]

启动mysql:

service mysqld start

mysql初始化:

[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数据库创建:SQL在官网自行下载

mysql> source apolloconfigdb.sql; mysql> source apolloportaldb.sql;

msyql连接用户授权:

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)

数据库配置更改:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zygdjd.html