xxxxxxxxxx
11git clone https://github.com/nobodyiam/apollo-build-scripts
xxxxxxxxxx
11source sql/apolloportaldb.sql
xxxxxxxxxx
11select `Id`, `AppId`, `Name` from ApolloPortalDB.App;
xxxxxxxxxx
11source sql/apolloconfigdb.sql
xxxxxxxxxx
11select `NamespaceId`, `Key`, `Value`, `Comment` from ApolloConfigDB.Item;
xxxxxxxxxx
191delete 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
xxxxxxxxxx
91#apollo config db info
2apollo_config_db_url=jdbc:mysql://localhost:3306/ApolloConfigDB?characterEncoding=utf8
3apollo_config_db_username=用户名
4apollo_config_db_password=密码(如果没有密码,留空即可)
5
6# apollo portal db info
7apollo_portal_db_url=jdbc:mysql://localhost:3306/ApolloPortalDB?characterEncoding=utf8
8apollo_portal_db_username=用户名
9apollo_portal_db_password=密码(如果没有密码,留空即可)
Quick Start脚本会在本地启动3个服务,使用8070, 8080, 8090端口,要确保这3个端口当前没有被使用。
检测方法:
xxxxxxxxxx
11lsof -i:8080
xxxxxxxxxx
11./demo.sh start
当出现如下信息时,说明启动成功。
xxxxxxxxxx
121==== starting service ====
2Service logging file is ./service/apollo-service.log
3Started [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 started
8==== starting portal ====
9Portal logging file is ./portal/apollo-portal.log
10Started [34925]
11Waiting for portal startup.....
12Portal started. You can visit http://localhost:8070 now!
xxxxxxxxxx
11$ git clone https://github.com/apolloconfig/apollo.git
因为默认给的docker-compose暴露出来的meta server的ip不是主机的ip,是docker容器的ip,这个时候应用拉配置是连接不上meta server的,因此需要对docker-compose做一些改动。
xxxxxxxxxx
21$ cd apollo/scripts/docker-quick-start
2$ vi docker-compose.yml
在apollo-quick-start: 中加上
xxxxxxxxxx
21 environment:
2 EUREKA_INSTANCE_IP_ADDRESS: '你的IP地址'
完整示例:
xxxxxxxxxx
381version: '2'
2
3services:
4 apollo-quick-start:
5 image: nobodyiam/apollo-quick-start
6 container_name: apollo
7 environment:
8 EUREKA_INSTANCE_IP_ADDRESS: '你的IP地址'
9 depends_on:
10 - apollo-db
11 ports:
12 - "8080:8080"
13 - "8090:8090"
14 - "8070:8070"
15 links:
16 - apollo-db
17
18 apollo-db:
19 image: mysql:5.7
20 container_name: apollo-db
21 environment:
22 TZ: Asia/Shanghai
23 MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
24 depends_on:
25 - apollo-dbdata
26 ports:
27 - "13306:3306"
28 volumes:
29 - ./sql:/docker-entrypoint-initdb.d
30 - ./data:/var/lib/mysql
31 volumes_from:
32 - apollo-dbdata
33
34 apollo-dbdata:
35 image: alpine:latest
36 container_name: apollo-dbdata
37 volumes:
38 - /var/lib/mysql
xxxxxxxxxx
11$ 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后登录