apollo 配置中心_apollo-1:apollo配置中心单机模拟分布式部署
原創(chuàng);微信公眾號(hào):千里行走;
受限圖片大小限制,有些圖片不是很清晰,可以到微信公眾號(hào)查看;
1.隨著微服務(wù)和容器化大行起到,配置中心的重要性越來(lái)越高,攜程的apollo(幾月eureka)是其中的佼佼者。
2.真實(shí)分布式部署類似,部署在3臺(tái)機(jī)器即可。
效果圖:
目錄
(1).mysql5.7安裝(centos7)
(2).導(dǎo)入數(shù)據(jù)庫(kù)
(3).下載安裝包
(4).單機(jī)模擬分布式部署環(huán)境部署&拓?fù)?amp;配置
(5).更改apollo數(shù)據(jù)庫(kù)中的配置
(6).啟動(dòng)
(7).驗(yàn)證
(8).關(guān)閉
(9).參考資料
(1).mysql5.7安裝(centos7)
vi /etc/yum.repos.d/mysql-community.repo
開(kāi)啟5.7-server的enabled=1,別的版本關(guān)掉。
yum install mysql安裝
service mysqld start 啟動(dòng)
注意記住臨時(shí)密碼。然后登陸Mysql,修改root密碼:ALTER USER 'root'@'localhost' IDENTIFIED BY 'newPassword123@';
SHOW VARIABLES WHERE Variable_name = 'version'; 查看版本
mysql -uroot -pnewPassword123@
(2).導(dǎo)入數(shù)據(jù)庫(kù)
有可能地址發(fā)生變更,請(qǐng)到master/對(duì)應(yīng)tag下找到對(duì)應(yīng)sql。
https://github.com/ctripcorp/apollo/blob/master/scripts/sql/apolloconfigdb.sql
https://github.com/ctripcorp/apollo/blob/master/scripts/sql/apolloportaldb.sql
mysql -uroot -pnewPassword123@ < a.sql
(3).下載安裝包
最新release:https://github.com/ctripcorp/apollo/releases
Apollo v1.0.0 Release
apollo-adminservice-1.0.0-github.zip
41.2 MB
apollo-configservice-1.0.0-github.zip
43.9 MB
apollo-portal-1.0.0-github.zip
32.7 MB
(4).單機(jī)模擬分布式部署環(huán)境部署&拓?fù)?amp;配置
4.1.apollo-dev機(jī)器:
(4.1.a.)config-service配置.
4.1.a.1.apollo-dev-x/apollo-configservice-1.0.0/scripts/startup.sh 配置不一樣
LOG_DIR=/data/coohua/logs/apollo-dev/apollo-dev-1/apollo-config-service-dev1-100003171
LOG_DIR=/data/coohua/logs/apollo-dev/apollo-dev-2/apollo-config-service-dev2-100003172
LOG_DIR=/data/coohua/logs/apollo-dev/apollo-dev-3/apollo-config-service-dev3-100003173
/data/coohua/logs/apollo-staging/apollo-staging/apollo-config-service-staging
SERVER_PORT=8080
SERVER_PORT=8081
SERVER_PORT=8082
注釋掉:apollo-configservice.conf 中的:
LOG_FOLDER
mkdir -p /data/coohua/logs/apollo-dev/apollo-dev-1/apollo-config-service-dev1-100003171
mkdir -p /data/coohua/logs/apollo-dev/apollo-dev-2/apollo-config-service-dev2-100003172
mkdir -p /data/coohua/logs/apollo-dev/apollo-dev-3/apollo-config-service-dev3-100003173
4.1.a.2.apollo-dev-x/apollo-configservice-1.0.0/config/app.properties 配置不一樣
appId=100003171
appId=100003172
appId=100003173
4.1.a.3.apollo-dev-x/apollo-configservice-1.0.0/config/application-github.properties 配置都一樣
# DataSource
spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = newPassword123@
(4.1.b.)admin-service配置.
4.1.b.1.apollo-dev-1/apollo-adminservice-1.0.0/scripts/startup.sh 配置不一樣
LOG_DIR=/data/coohua/logs/apollo-dev/apollo-dev-1/apollo-admin-service-dev1-100004171
LOG_DIR=/data/coohua/logs/apollo-dev/apollo-dev-2/apollo-admin-service-dev2-100004172
LOG_DIR=/data/coohua/logs/apollo-dev/apollo-dev-3/apollo-admin-service-dev3-100004173
SERVER_PORT=8090
SERVER_PORT=8091
SERVER_PORT=8092
注釋掉:apollo-adminservice.conf 中的:
LOG_FOLDER
mkdir -p /data/coohua/logs/apollo-dev/apollo-dev-1/admin-service-dev1-100004171
mkdir -p /data/coohua/logs/apollo-dev/apollo-dev-2/admin-service-dev2-100004172
mkdir -p /data/coohua/logs/apollo-dev/apollo-dev-3/admin-service-dev3-100004173
4.1.b.2.apollo-dev-x/apollo-adminservice-1.0.0/config/app.properties 配置不一樣
appId=100004171
appId=100004172
appId=100004173
4.1.b.3.apollo-dev-x/apollo-adminservice-1.0.0/config/application-github.properties 配置都一樣
# DataSource
spring.datasource.url = jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = newPassword123@
(4.1.c.)portal配置.全局所有環(huán)境的portal都通過(guò)dev的portal操作.
4.1.c.1.apollo-dev-x/apollo-portal-1.0.0/apollo-portal.conf 配置不一樣
LOG_DIR=/data/coohua/logs/apollo-dev/apollo-dev-1/apollo-portal-dev1-100005171
LOG_DIR=/data/coohua/logs/apollo-dev/apollo-dev-2/apollo-portal-dev2-100005172
LOG_DIR=/data/coohua/logs/apollo-dev/apollo-dev-3/apollo-portal-dev3-100005173
SERVER_PORT=8070
SERVER_PORT=8071
SERVER_PORT=8072
注釋掉:apollo-portal.conf 中的:
LOG_FOLDER
mkdir -p /data/coohua/logs/apollo-dev/apollo-dev-1/apollo-portal-dev1-100005171
mkdir -p /data/coohua/logs/apollo-dev/apollo-dev-2/apollo-portal-dev2-100005172
mkdir -p /data/coohua/logs/apollo-dev/apollo-dev-3/apollo-portal-dev3-100005173
4.1.c.2.apollo-dev-x/apollo-portal-1.0.0/config/app.properties 配置不一樣
appId=100005171
appId=100005172
appId=100005173
4.1.c.3.apollo-dev-x/apollo-portal-1.0.0/config/apollo-env.properties 配置不一樣,域名不一樣(如果是在同一臺(tái)機(jī)器,則端口不一樣)
apollo-dev-1
#local.meta=http://localhost:8080
dev.meta=http://apollo-dev-1: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
4.1.c.4.apollo-dev-x/apollo-portal-1.0.0/config/application-github.properties 配置都一樣
# DataSource
spring.datasource.url = jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = newPassword123@
(5).更改apollo數(shù)據(jù)庫(kù)中的配置
5.1.更改ApolloConfigDB.ServerConfig中的eureka地址為集群
apollo-dev-1 apollo-dev-2 apollo-dev-3
eureka.service.url
update ServerConfig set value="http://apollo-dev-1:8080/eureka/,http://apollo-dev-2:8081/eureka/,http://apollo-dev-3:8082/eureka/" where `key`="eureka.service.url"G
原值:
update ServerConfig set value="http://localhost:8080/eureka/" where `key`="eureka.service.url"G
5.2.調(diào)整ApolloPortalDB配置
配置項(xiàng)統(tǒng)一存儲(chǔ)在ApolloPortalDB.ServerConfig表中,也可以通過(guò)管理員工具 - 系統(tǒng)參數(shù)頁(yè)面進(jìn)行配置。
apollo.portal.envs - 可支持的環(huán)境列表
DEV,FAT,UAT,PRO
初始值只有DEV
update ServerConfig set value='DEV,UAT,PRO' where id=1;
(6).啟動(dòng)
apollo-dev-1/apollo-configservice-1.0.0/scripts/startup.sh
apollo-dev-1/apollo-adminservice-1.0.0/scripts/startup.sh
apollo-dev-1/apollo-portal-1.0.0/scripts/startup.sh
apollo-dev-2/apollo-configservice-1.0.0/scripts/startup.sh
apollo-dev-2/apollo-adminservice-1.0.0/scripts/startup.sh
apollo-dev-2/apollo-portal-1.0.0/scripts/startup.sh
apollo-dev-3/apollo-configservice-1.0.0/scripts/startup.sh
apollo-dev-3/apollo-adminservice-1.0.0/scripts/startup.sh
apollo-dev-3/apollo-portal-1.0.0/scripts/startup.sh
默認(rèn)用戶名:apollo
默認(rèn)密碼:admin
(7).驗(yàn)證
以apollo-dev-1為例:
portal: http://192.32.6.103:8070/
eureka/configservice: http://192.32.6.103:8080/
adminservice: http://192.32.6.103:8090/
(8).關(guān)閉
apollo-dev-1/apollo-configservice-1.0.0/scripts/shutdown.sh
apollo-dev-1/apollo-adminservice-1.0.0/scripts/shutdown.sh
apollo-dev-1/apollo-portal-1.0.0/scripts/shutdown.sh
apollo-dev-2/apollo-configservice-1.0.0/scripts/shutdown.sh
apollo-dev-2/apollo-adminservice-1.0.0/scripts/shutdown.sh
apollo-dev-2/apollo-portal-1.0.0/scripts/shutdown.sh
apollo-dev-3/apollo-configservice-1.0.0/scripts/shutdown.sh
apollo-dev-3/apollo-adminservice-1.0.0/scripts/shutdown.sh
apollo-dev-3/apollo-portal-1.0.0/scripts/shutdown.sh
(9).參考資料
1.官方github地址:
https://github.com/ctripcorp/apollo
總結(jié)
以上是生活随笔為你收集整理的apollo 配置中心_apollo-1:apollo配置中心单机模拟分布式部署的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 蒲公英怎么加入别人的网络_挖蒲公英吃的,
- 下一篇: python抖音github_GitHu