Apollo配置中心搭建过程

Apollo搭建

官网GitHub地址:

https://github.com/ctripcorp/apollo

源码下载地址:

https://github.com/ctripcorp/apollo/releases

选择版本进行下载:
https://github.com/ctripcorp/apollo/releases/download/v1.7.1/apollo-adminservice-1.7.1-github.zip
https://github.com/ctripcorp/apollo/releases/download/v1.7.1/apollo-configservice-1.7.1-github.zip
https://github.com/ctripcorp/apollo/releases/download/v1.7.1/apollo-portal-1.7.1-github.zip

主要组件说明:

adminservice、configservice、portal等

configservice

提供配置获取接口
提供配置更新推送接口(基于Http long polling)
服务端使用 Spring DeferredResult实现异步化,从而大大增加长连接数量
目前使用的tomcat embed默认配置是最多10000个连接
接口服务对象为Apollo客户端

adminservice

提供配置管理接口
提供配置修改、发布等接口
接口服务对象为Portal

Portal

提供Web界面供用户管理配置
通过Meta Server获取Admin Service服务列表(IP+Port),通过IP+Port访问服务
在Portal侧做load balance、错误重试

安装

确保主机的JAVA、maven环境

配置MySQL数据库

# 下载官网的sql脚本
wget https://raw.githubusercontent.com/ctripcorp/apollo/master/scripts/sql/apolloconfigdb.sql
wget https://raw.githubusercontent.com/ctripcorp/apollo/master/scripts/sql/apolloportaldb.sql
[root@localhost]# mysql -uroot -p
Enter password: 
mysql> source apolloconfigdb.sql
Query OK, 0 rows affected (0.00 sec)
.........................
mysql> source apolloportaldb.sql
Query OK, 0 rows affected (0.00 sec)
.........................
mysql> flush privileges;
ok
mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| ApolloConfigDB     |
| ApolloPortalDB     |
| mysql              |
| performance_schema |
| sonar              |
| sys                |
+--------------------+
7 rows in set (0.00 sec)
mysql> quit
Bye

解压软件包

unzip apollo-adminservice-1.7.1-github.zip
unzip apollo-configservice-1.7.1-github.zip
unzip apollo-portal-1.7.1-github.zip

修改各组件的application.properties

注:在configservice组件中application.properties配置的数据库连接地址中的库为ApolloConfigDB,否则服务报错。
注:在adminservice组件中配置的数据库连接地址中的库为ApolloConfigDB,否则服务报错。
注:在protal中配置的数据库连接地址中的库必须为ApolloPortalDB,否则服务报错。

vim 解压后文件夹/config/application-github.properties
# DataSource
spring.datasource.url = jdbc:mysql://mysql主机IP:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123

修改protal组件的apollo-env.properties

local.meta=http://localhost:8080
dev.meta=http://localhost:8080 #配置一个环境
fat.meta=http://fill-in-fat-meta-server:8080
uat.meta=http://fill-in-uat-meta-server:8080
lpt.meta=${lpt_meta}
pro.meta=http://fill-in-pro-meta-server:8080

启动&停止

按顺序执行各组件文件夹下的config/scripts下的启动、停止脚本即可start.sh/shutdown.sh

configservice-->adminservice-->protal

[root@cka-m2 apollo]# ./config/scripts/startup.sh 
Mon Aug 24 03:51:59 EDT 2020 ==== Starting ==== 
Started [6567]
Waiting for server startup.....
Mon Aug 24 03:52:25 EDT 2020 Server started in 25 seconds!

[root@cka-m2 apollo]# ./admin/scripts/startup.sh 
Mon Aug 24 03:53:26 EDT 2020 ==== Starting ==== 
Already running [6831]
Waiting for server startup.....
Mon Aug 24 03:53:52 EDT 2020 Server started in 25 seconds!

[root@cka-m2 apollo]# ./portal/scripts/startup.sh 
Mon Aug 24 03:54:03 EDT 2020 ==== Starting ==== 
Started [7086]
Waiting for server startup......
Mon Aug 24 03:54:34 EDT 2020 Server started in 30 seconds!


默认端口:
configservice --> 8080
adminservice --> 8090
protal --> 8070

[root@cka-m2 apollo]# ss -tnl
State      Recv-Q Send-Q                      Local Address:Port                                     Peer Address:Port              
LISTEN     0      128                                     *:22                                                  *:*                  
LISTEN     0      100                             127.0.0.1:25                                                  *:*                  
LISTEN     0      128                                    :::8080                                               :::*                  
LISTEN     0      128                                    :::22                                                 :::*                  
LISTEN     0      100                                   ::1:25                                                 :::*                  
LISTEN     0      128                                    :::8090                                               :::*                  
LISTEN     0      128                                    :::8070                                               :::*                  
LISTEN     0      80                                     :::3306                                               :::*               

访问

原文地址:https://www.cnblogs.com/Smbands/p/13554411.html