当前位置: 移动技术网 > 科技>办公>CPU > Apollo配置中心,还挺高大上

Apollo配置中心,还挺高大上

2020年09月29日  | 移动技术网科技  | 我要评论
前言以前一直使用配置文件的形式,对Apollo感觉不屑一顾;自认为最多使用重启修改配置,在不行上一个XXL-Config即可;抱着学习的态度看了Apollo的一些文章,然后对它进行了安装研究,发现还是很强大的,有种相见恨晚的感觉了。安装机器安装备注192.168.1.81admin、config、protal可以使用默认安装包、单环境忽略79192.168.1.79admin、config需要源码编译192.168...

前言       

以前一直使用配置文件的形式,对Apollo感觉不屑一顾;自认为最多使用重启修改配置,在不行上一个XXL-Config即可;抱着学习的态度看了Apollo的一些文章,然后对它进行了安装研究,发现还是很强大的,有种相见恨晚的感觉了。

 安装

机器安装备注
192.168.1.81admin、config、protal可以使用默认安装包、单环境忽略79
192.168.1.79admin、config需要源码编译
192.168.1.73mysql数据库

1.下载安装包

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

2.创建数据库

1.找到sql

源码apollo-1.7.1\scripts\sql 下apolloconfigdb.sql、apolloportaldb.sql

2.为81建库

连接73服务器上mysql数据库
创建apolloconfigdb、apolloportaldb 库
执行sql进库

3.为79建库 (为多环境准备、单环境忽略)

连接73服务器上mysql数据库
新建apolloconfigdb1数据库
执行apolloconfigdb.sql

3.上传包解压包

1.在81服务器上传

rz -be

apollo-adminservice-1.7.1-github.zip

apollo-configservice-1.7.1-github.zip

apollo-portal-1.7.1-github.zip

2.解压

mkdir -p /opt/{apollo-admin,apollo-config,apollo-portal}

unzip apollo-adminservice-1.7.1-github.zip -d /opt/apollo-admin
unzip apollo-configservice-1.7.1-github.zip -d /opt/apollo-config
unzip apollo-portal-1.7.1-github.zip -d /opt/apollo-portal

3.修改数据库配置

/opt/apollo-admin/config/application-github.properties
/opt/apollo-config/config/application-github.properties
/opt/apollo-portal/config/application-github.properties

# DataSource    admin config 相同配置
spring.datasource.url = jdbc:mysql://192.168.1.73:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 

# DataSource
spring.datasource.url = jdbc:mysql://192.168.1.73:3306/ApolloPortalDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 

4.启动关闭

lsof -i:8080 查看是否被占用端口
/opt/apollo-admin/scripts/shutdown.sh  startup.sh
/opt/apollo-config/scripts/shutdown.sh  startup.sh
/opt/apollo-portal/scripts/shutdown.sh  startup.sh

5.日志查看

tail -f /opt/logs/100003171/apollo-configservice_optapollo-config.log
tail -f /opt/logs/100003172/apollo-adminservice_optapollo-admin.log
tail -f /opt/logs/100003173/apollo-portal_optapollo-protal.log

4.验证查看

5.在79多环境搭建

1.源码打包

修改apollo-1.7.1\scripts\bulid.bat 或 bulid.sh

rem apollo config db info
set apollo_config_db_url="jdbc:mysql://192.168.1.73:3306/ApolloConfigDB1?characterEncoding=utf8"
set apollo_config_db_username="root"
set apollo_config_db_password=""

rem apollo portal db info
set apollo_portal_db_url="jdbc:mysql://192.168.1.73:3306/ApolloPortalDB?characterEncoding=utf8"
set apollo_portal_db_username="root"
set apollo_portal_db_password=""

rem meta server url, different environments should have different meta server addresses
set dev_meta="http://192.168.1.81:8080"
#set fat_meta="http://someIp:8080"
#set uat_meta="http://anotherIp:8080"
set pro_meta="http://192.168.1.79:8080"

执行bulid.bat 或 bulid.sh

2.上包到79服务器

\apollo-1.7.1\apollo-adminservice\target\apollo-adminservice-1.7.1-github.zip
\apollo-1.7.1\apollo-configservice\target\apollo-configservice-1.7.1-github.zip

3.解压安装启动,参考81服务器

4.73服务器数据库apolloportaldb下 serverconfig表修改 apollo.portal.envs 为 dev,pro

5.修改81服务器上protal的配置指向
/opt/apollo-protal/config/apollo-env.properties

dev.meta=http://192.168.1.81:8080
#fat.meta=http://localhost:8080
#uat.meta=http://localhost:8080
#lpt.meta=${lpt_meta}
pro.meta=http://192.168.1.79:8080

重启81服务器上 protal服务

6.验证多环境

7.课外学习

其他配置:

namespace为配置的公共部分

集群可实现不同服务器之间使用不同配置,如果新集群未配置,走默认集群配置

本文地址:https://blog.csdn.net/qq_16116549/article/details/108864239

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网