Apollo初始环境搭建

apollo入门级安装

    • 下载apollo的zip包
    • 执行sql并验证
    • 查看8080端口是否在监听
    • 启动配置服务
    • 访问配置中心
    • 客户端验证
    • Eureka查看

参考: https://github.com/ctripcorp/apollo/wiki/Quick-Start

下载apollo的zip包

百度网盘
Apollo初始环境搭建_第1张图片

mkdir /usr/local/software/Apollo

将zip包传到/usr/local/software/Apollo下,解压缩。
Apollo初始环境搭建_第2张图片

执行sql并验证

在mysql命令终端下执行sql/apolloportaldb.sql 并验证

mysql> source /usr/local/software/Apollo/sql/apolloportaldb.sql 
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

.......

mysql> select `Id`, `AppId`, `Name` from ApolloPortalDB.App;
+----+-----------+------------+
| Id | AppId     | Name       |
+----+-----------+------------+
|  1 | SampleApp | Sample App |
+----+-----------+------------+
1 row in set (0.00 sec)

在mysql命令终端下执行sql/apolloconfigdb.sql 并验证

mysql> source apolloconfigdb.sql
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> select `NamespaceId`, `Key`, `Value`, `Comment` from ApolloConfigDB.Item;
+-------------+---------+-------+----------------------+
| NamespaceId | Key     | Value | Comment              |
+-------------+---------+-------+----------------------+
|           1 | timeout | 100   | sample timeout配置   |
+-------------+---------+-------+----------------------+
1 row in set (0.00 sec)

查看8080端口是否在监听

[root@iZwz94664y88ud9aroa5veZ Apollo]# lsof -i:8080
COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
java    17127 root   46u  IPv4 4421816      0t0  TCP *:webcache (LISTEN)

发现被监听了,kill掉避免冲突!
修改demo.sh连接mysql的部分,其他不需要改:

vim demo.sh 
#!/bin/bash

# apollo config db info
apollo_config_db_url=jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8
apollo_config_db_username=root
apollo_config_db_password=xxxxxxxxxxxx

# apollo portal db info
apollo_portal_db_url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8
apollo_portal_db_username=root
apollo_portal_db_password=xxxxxxxxx

# =============== Please do not modify the following content =============== #

启动配置服务

要确保8070,8080,8090这三个端口没有占用!

[root@iZwz94664y88ud9aroa5veZ Apollo]# ./demo.sh start
==== starting service ====
Service logging file is ./service/apollo-service.log
Started [14223]
Waiting for config service startup.

...........
Config service started. You may visit http://localhost:8080 for service status now!
Waiting for admin service startup..
Admin service started
==== starting portal ====
Portal logging file is ./portal/apollo-portal.log
Started [14482]
Waiting for portal startup...........
Portal started. You can visit http://localhost:8070 now!

访问配置中心

初始用户名apollo,密码admin
Apollo初始环境搭建_第3张图片

客户端验证

启动客户端

修改apollo配置中心的timeout配置为200
Apollo初始环境搭建_第4张图片
在这里插入图片描述
添加说明即可发布
Apollo初始环境搭建_第5张图片
在这里插入图片描述

可以看到客户端运行时,打印出了配置中心的改动!

root@iZwz94664y88ud9aroa5veZ Apollo]# ./demo.sh client
[apollo-demo][main]2020-03-31 18:53:08,026 INFO  [com.ctrip.framework.foundation.internals.provider.DefaultApplicationProvider] App ID is set to SampleApp by app.id property from /META-INF/app.properties
[apollo-demo][main]2020-03-31 18:53:08,039 INFO  [com.ctrip.framework.foundation.internals.provider.DefaultServerProvider] Environment is set to [dev] by JVM system property 'env'.
[apollo-demo][main]2020-03-31 18:53:08,105 INFO  [com.ctrip.framework.apollo.internals.DefaultMetaServerProvider] Located meta services from apollo.meta configuration: http://localhost:8080!
[apollo-demo][main]2020-03-31 18:53:08,106 INFO  [com.ctrip.framework.apollo.core.MetaDomainConsts] Located meta server address http://localhost:8080 for env DEV from com.ctrip.framework.apollo.internals.DefaultMetaServerProvider
Apollo Config Demo. Please input key to get the value. Input quit to exit.
> 
> timeout
Loading key : timeout with value: 100
> Changes for namespace application
Change - key: timeout, oldValue: 100, newValue: 200, changeType: MODIFIED

而且timeout再次获取值变为200.

> timeout
Loading key : timeout with value: 200
> 

Eureka查看

http://ip:8080打开eureka可以看到注册的服务。
Apollo初始环境搭建_第6张图片
Eureka作为AdminService和ConfigService的服务注册中心提供服务发现的功能,提供java访问客户端给Portal和Apollo Client使用,但是对其他语言的Eureka就做不到支持了,于是Apollo架构引入了MetaServer作为Eureka的代理来对Portal和Apollo Client提供简单的http调用,这样就屏蔽了语言的异构性,做到通用。
架构图如下:

Apollo初始环境搭建_第7张图片
初始环境搭建就介绍到这里,欢迎一起交流!
Apollo初始环境搭建_第8张图片

你可能感兴趣的:(Apollo)