Apollo(二)-单机环境搭建

Apollo单机环境搭建-详细过程

  • 前提
  • 搭建
      • 数据库配置
      • 虚拟机部署
  • 测试
      • 启动apollo
      • 浏览器访问
      • 客户端测试
  • 参考

以github上的apollo-quick-start搭建运行为例

前提

本地win10上安装jdk和mysql,apollo跑在虚拟机Centos上;

  • jdk1.8
  • mysql5.7、navicat
  • 虚拟机上Centos7

搭建

1)下载Demo:https://github.com/nobodyiam/apollo-build-scripts
2)解压到本地“E:\YDSource\appolo\apollo-quick-start”:
Apollo(二)-单机环境搭建_第1张图片

数据库配置

1)利用navicat运行sql文件夹下的两个sql文件
Apollo(二)-单机环境搭建_第2张图片
Apollo(二)-单机环境搭建_第3张图片
2)修改登录数据库,以便虚拟机能访问本地Mysql
Apollo(二)-单机环境搭建_第4张图片
并赋予ip访问权限
Apollo(二)-单机环境搭建_第5张图片

C:\WINDOWS\system32>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.7.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>

3)重启数据库
Apollo(二)-单机环境搭建_第6张图片
4)修改配置文件“E:\YDSource\appolo\apollo-quick-start\demo.sh”,其中192.168.0.137为本地服务器的ip,123456位mysql的登录密码;
Apollo(二)-单机环境搭建_第7张图片

虚拟机部署

1)关闭防火墙

systemctl stop firewalld

2)利用xftp复制项目到服务器
Apollo(二)-单机环境搭建_第8张图片
3)修改文件夹权限

[root@localhost apollo-quick-start]# chmod 777 -R /usr/local/apollo-quick-start
[root@localhost apollo-quick-start]# 

测试

启动apollo

[root@localhost ~]# cd /usr/local/apollo-quick-start/

[root@localhost apollo-quick-start]# ./demo.sh start
==== starting service ====
Service logging file is ./service/apollo-service.log
Started [8723]
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 [8949]
Waiting for portal startup.........
Portal started. You can visit http://localhost:8070 now!
[root@localhost apollo-quick-start]#

Apollo(二)-单机环境搭建_第9张图片

浏览器访问

Apollo(二)-单机环境搭建_第10张图片
Apollo(二)-单机环境搭建_第11张图片
Apollo(二)-单机环境搭建_第12张图片

客户端测试

启动并查看timeout的值:

Last login: Thu Jul 18 06:12:16 2019
[root@localhost ~]# cd /usr/local
[root@localhost local]# cd apollo-quick-start/
[root@localhost apollo-quick-start]# ./demo.sh client

[apollo-demo][main]2019-07-18 06:43:24,246 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]2019-07-18 06:43:24,249 INFO  [com.ctrip.framework.foundation.internals.provider.DefaultServerProvider] Environment is set to [dev] by JVM system property 'env'.
[apollo-demo][main]2019-07-18 06:43:24,315 INFO  [com.ctrip.framework.apollo.internals.DefaultMetaServerProvider] Located meta services from apollo.meta configuration: http://localhost:8080!
[apollo-demo][main]2019-07-18 06:43:24,316 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
> timeout
Loading key : timeout with value: 100
> 

修改值并观察客户端
Apollo(二)-单机环境搭建_第13张图片
Apollo(二)-单机环境搭建_第14张图片
可以看到最后,提示了修改:
Apollo(二)-单机环境搭建_第15张图片

参考

官网文档:https://github.com/ctripcorp/apollo/wiki/Quick-Start

你可能感兴趣的:(Apollo)