xxxxxxxxxx11git clone https://github.com/nobodyiam/apollo-build-scriptsxxxxxxxxxx11source sql/apolloportaldb.sqlxxxxxxxxxx11select `Id`, `AppId`, `Name` from ApolloPortalDB.App;xxxxxxxxxx11source sql/apolloconfigdb.sqlxxxxxxxxxx11select `NamespaceId`, `Key`, `Value`, `Comment` from ApolloConfigDB.Item;xxxxxxxxxx191delete from `ApolloPortalDB`.`App`;2delete from `ApolloPortalDB`.`AppNamespace`;3ALTER TABLE `ApolloPortalDB`.`App` AUTO_INCREMENT = 1;4ALTER TABLE `ApolloPortalDB`.`AppNamespace` AUTO_INCREMENT = 1;5
6delete from `ApolloConfigDB`.`App`;7delete from `ApolloConfigDB`.`AppNamespace`;8delete from `ApolloConfigDB`.`Cluster`;9delete from `ApolloConfigDB`.`Item`;10delete from `ApolloConfigDB`.`Namespace`;11delete from `ApolloConfigDB`.`Release`;12delete from `ApolloConfigDB`.`ReleaseHistory`;13ALTER TABLE `ApolloConfigDB`.`App` AUTO_INCREMENT = 1;14ALTER TABLE `ApolloConfigDB`.`AppNamespace` AUTO_INCREMENT = 1;15ALTER TABLE `ApolloConfigDB`.`Cluster` AUTO_INCREMENT = 1;16ALTER TABLE `ApolloConfigDB`.`Item` AUTO_INCREMENT = 1;17ALTER TABLE `ApolloConfigDB`.`Namespace` AUTO_INCREMENT = 1;18ALTER TABLE `ApolloConfigDB`.`Release` AUTO_INCREMENT = 1;19ALTER TABLE `ApolloConfigDB`.`ReleaseHistory` AUTO_INCREMENT = 1;vim ./demo.sh
xxxxxxxxxx91#apollo config db info2apollo_config_db_url=jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf83apollo_config_db_username=用户名4apollo_config_db_password=密码(如果没有密码,留空即可)5
6# apollo portal db info7apollo_portal_db_url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf88apollo_portal_db_username=用户名9apollo_portal_db_password=密码(如果没有密码,留空即可)Quick Start脚本会在本地启动3个服务,使用8070, 8080, 8090端口,要确保这3个端口当前没有被使用。
检测方法:
xxxxxxxxxx11lsof -i:8080xxxxxxxxxx11./demo.sh start当出现如下信息时,说明启动成功。
xxxxxxxxxx121==== starting service ====2Service logging file is ./service/apollo-service.log3Started [34867]4Waiting for config service startup.....5Config service started. You may visit http://localhost:8080 for service status now!6Waiting for admin service startup..7Admin service started8==== starting portal ====9Portal logging file is ./portal/apollo-portal.log10Started [34925]11Waiting for portal startup.....12Portal started. You can visit http://localhost:8070 now!xxxxxxxxxx11$ git clone https://github.com/apolloconfig/apollo.git因为默认给的docker-compose暴露出来的meta server的ip不是主机的ip,是docker容器的ip,这个时候应用拉配置是连接不上meta server的,因此需要对docker-compose做一些改动。
xxxxxxxxxx21$ cd apollo/scripts/docker-quick-start2$ vi docker-compose.yml在apollo-quick-start: 中加上
xxxxxxxxxx21 environment: 2 EUREKA_INSTANCE_IP_ADDRESS: '你的IP地址'完整示例:
xxxxxxxxxx381version: '2'2
3services:4 apollo-quick-start:5 image: nobodyiam/apollo-quick-start6 container_name: apollo7 environment: 8 EUREKA_INSTANCE_IP_ADDRESS: '你的IP地址'9 depends_on:10 - apollo-db11 ports:12 - "8080:8080"13 - "8090:8090"14 - "8070:8070"15 links:16 - apollo-db17
18 apollo-db:19 image: mysql:5.720 container_name: apollo-db21 environment:22 TZ: Asia/Shanghai23 MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'24 depends_on:25 - apollo-dbdata26 ports:27 - "13306:3306"28 volumes:29 - ./sql:/docker-entrypoint-initdb.d30 - ./data:/var/lib/mysql31 volumes_from:32 - apollo-dbdata33
34 apollo-dbdata:35 image: alpine:latest36 container_name: apollo-dbdata37 volumes:38 - /var/lib/mysqlxxxxxxxxxx11$ docker-compose up -d注意:如果提示端口冲突(Bind for 0.0.0.0:8080 failed: port is already allocated),那就把docker-compose.yml中“左边的”端口号调整一下,再行启动。比如把8080改成8081,形如 - "8081:8080"
输入用户名apollo,密码admin后登录