一次性搞定 centos7 安装 Apollo(亲测可用!!!)

Apollo简介

文档地址

Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境、不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限、流程治理等特性,适用于微服务配置管理场景。

在这里插入图片描述

环境准备

java: JDK 1.8.x
maven:3.x.x
mysql:5.7.x 【建议不要低于5.7,否则后面创建数据库表的sql会有问题,某些功能不支持】
apollo: 1.10.0

1、安装好其它依赖环境,开始 -> 拉取Apollo项目https://github.com/apolloconfig/apollo
在这里插入图片描述
2、创建需要的数据库(拿到对应2个sql去数据库执行)
在这里插入图片描述
在这里插入图片描述
3、打包项目(build package)
将下载下来的 apollo 源码导入到idea中,我们需要关注的几个项目:

apollo-configservice	apollo-adminservice	apollo-protal配置服务(meta server、eureka)	配置管理服务	apollo管理UI

找到 /apollo/scripts/build.bat(Linux 是 bulid.sh)
Windows下:build.bat

rem
rem Copyright 2021 Apollo Authors
rem
rem Licensed under the Apache License, Version 2.0 (the "License");
rem you may not use this file except in compliance with the License.
rem You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
rem
@echo off

rem apollo config db info
// & 后面拼接的内容可根据对应安装的数据库版本情况
set apollo_config_db_url="jdbc:mysql://localhost:3306/ApolloConfigDB?zeroDateTimeBehavior=convertToNull&characterEncoding=utf8&serverTimezone=UTC"
set apollo_config_db_username="root"
set apollo_config_db_password="123"

rem apollo portal db info
set apollo_portal_db_url="jdbc:mysql://localhost:3306/ApolloPortalDB?zeroDateTimeBehavior=convertToNull&characterEncoding=utf8&serverTimezone=UTC"
set apollo_portal_db_username="root"
set apollo_portal_db_password="123"

rem meta server url, different environments should have different meta server addresses
set dev_meta="http://localhost:configService对应的端口"
set fat_meta="http://someIp:8080"
set uat_meta="http://anotherIp:8080"
set pro_meta="http://yetAnotherIp:8080"

set META_SERVERS_OPTS=-Ddev_meta=%dev_meta% -Dfat_meta=%fat_meta% -Duat_meta=%uat_meta% -Dpro_meta=%pro_meta%

rem =============== Please do not modify the following content =============== 
rem go to script directory
cd "%~dp0"

cd ..

rem package config-service and admin-service
echo "==== starting to build config-service and admin-service ===="

call mvn clean package -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github -Dspring_datasource_url=%apollo_config_db_url% -Dspring_datasource_username=%apollo_config_db_username% -Dspring_datasource_password=%apollo_config_db_password%

echo "==== building config-service and admin-service finished ===="

echo "==== starting to build portal ===="

call mvn clean package -DskipTests -pl apollo-portal -am -Dapollo_profile=github,auth -Dspring_datasource_url=%apollo_portal_db_url% -Dspring_datasource_username=%apollo_portal_db_username% -Dspring_datasource_password=%apollo_portal_db_password% %META_SERVERS_OPTS%

echo "==== building portal finished ===="

pause

Linux下:bulid.sh

#!/bin/sh
#
# Copyright 2021 Apollo Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# apollo config db info
apollo_config_db_url='jdbc:mysql://虚拟机内网IP地址:3306/ApolloConfigDB?zeroDateTimeBehavior=convertToNull&characterEncoding=utf8&serverTimezone=UTC'
apollo_config_db_username='root'
apollo_config_db_password='123456'

# apollo portal db info
apollo_portal_db_url='jdbc:mysql://虚拟机内网IP地址:3306/ApolloPortalDB?zeroDateTimeBehavior=convertToNull&characterEncoding=utf8&serverTimezone=UTC'
apollo_portal_db_username='root'
apollo_portal_db_password='123456'

# meta server url, different environments should have different meta server addresses
dev_meta=http://虚拟机内网IP地址:configService对应的端口
fat_meta=http://fill-in-fat-meta-server:8080
uat_meta=http://fill-in-uat-meta-server:8080
pro_meta=http://fill-in-pro-meta-server:8080

META_SERVERS_OPTS="-Ddev_meta=$dev_meta -Dfat_meta=$fat_meta -Duat_meta=$uat_meta -Dpro_meta=$pro_meta"

# =============== Please do not modify the following content =============== #
# go to script directory
cd "${0%/*}" || exit 

cd ..

# package config-service and admin-service
echo "==== starting to build config-service and admin-service ===="

mvn clean package -DskipTests -pl apollo-configservice,apollo-adminservice -am -Dapollo_profile=github -Dspring_datasource_url=$apollo_config_db_url -Dspring_datasource_username=$apollo_config_db_username -Dspring_datasource_password=$apollo_config_db_password

echo "==== building config-service and admin-service finished ===="

echo "==== starting to build portal ===="

mvn clean package -DskipTests -pl apollo-portal -am -Dapollo_profile=github,auth -Dspring_datasource_url=$apollo_portal_db_url -Dspring_datasource_username=$apollo_portal_db_username -Dspring_datasource_password=$apollo_portal_db_password $META_SERVERS_OPTS

echo "==== building portal finished ===="

修改完上面的配置之后,执行build.sh 批处理命令文件进行编译打包,在执行的过程中可能会出现一些异常(一般是maven依赖异常),自行百度解决之后,再重新执行。

打包成功之后,找到 apollo-configservice、apollo-adminservice、apollo-portal 下的 target 目录(build是执行 maven 的 package 命令),找到已经打好的三个压缩包,copy 出来放到一个单独的目录(方便启动)。
在这里插入图片描述
解压到某个目录下
在这里插入图片描述
4、修改 config 目录下的 properties 文件
在这里插入图片描述

# DataSource
spring.jpa.database=mysql -- 默认不是MySQL,不设置会报错
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://虚拟机内网IP:3306/ApolloConfigDB?zeroDateTimeBehavior=convertToNull&characterEncoding=utf8&serverTimezone=UTC&useSSL=false
spring.datasource.username = 用户名
spring.datasource.password = 密码
server.port=对应端口
server.address=虚拟机内网IP
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false 

5、进入jar 的当前目录,=依次=启动apollo-configservice、apollo-adminservice、apollo-portal 三个服务相隔服务启动等2分钟,有依赖

nohup java -Dserver.port=configservice对应的端口 -Deureka.instance.ip-address=虚拟机外网IP地址 -Deureka.instance.homePageUrl=http://虚拟机外网IP地址:configservice对应的端口 -jar apollo-configservice-1.10.0-SNAPSHOT.jar &

nohup java -Dserver.port=adminservice对应的端口 -Deureka.instance.ip-address=虚拟机外网IP地址 -Deureka.instance.homePageUrl=http://虚拟机外网IP地址:adminservice对应的端口 -jar apollo-adminservice-1.10.0-SNAPSHOT.jar &

nohup java -Dserver.port=portal对应的端口  -jar apollo-portal-1.10.0-SNAPSHOT.jar &   

全部启动完成之后,打开浏览器输入:http://localhost:8070
登录名/密码:apollo/admin在这里插入图片描述
http://localhost:8080 如果出现eureka 的管理界面,说明服务启动正常
在这里插入图片描述

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在CentOS 7上安装Apollo,可以按照以下步骤进行操作: 1. 使用yum命令在CentOS 7上安装MySQL 5.7。详细安装步骤可以参考 "CentOS 7 使用yum方式安装MySQL 5.7" 的教程。 2. 在服务器中使用wget命令从GitHub上下载Apollo安装包。可以使用以下命令进行下载: ``` wget https://github.com/nobodyiam/apollo-build-scripts/archive/master.zip ``` 请耐心等待下载完成。 3. 解压下载的压缩包。使用以下命令解压压缩包: ``` unzip master.zip ``` 4. 在解压后的目录中,可以找到apollo-build-scripts-master目录。进入该目录,可以找到demo.sh文件。编辑该文件,修改ApolloPortalDB和ApolloConfigDB相关的数据库连接信息。根据你自己的数据库配置,修改以下信息: ``` # apollo config db info apollo_config_db_url=jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8 apollo_config_db_username=用户名 apollo_config_db_password=密码(如果没有密码,留空即可) # apollo portal db info apollo_portal_db_url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8 apollo_portal_db_username=用户名 apollo_portal_db_password=密码(如果没有密码,留空即可) ``` 请注意,不要修改demo.sh文件中的其他内容。 以上是在CentOS 7上安装Apollo的基本步骤。根据你的实际情况,可能还需要进行其他配置和调整。建议在安装前仔细阅读官方文档或者相关教程,以获得更详细的安装指导。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [CentOS 7 快速搭建 Apollo](https://blog.csdn.net/wchenjt/article/details/95458365)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值