一、环境准备
jdk : 1.8+ mysql 5.6.5+
二、安装包下载
https://github.com/ctripcorp/apollo/releases
下载如下三个压缩包
下载sql文件,下载地址 :https://github.com/apolloconfig/apollo-quick-start/tree/master/sql
三、部署apollo
1、新建安装目录,放置下载好的安装包
2、解压到当前目录
# 创建模块目录
mkdir apollo-adminservice-prod apollo-adminservice-dev apollo-portal
# 解压到对应的目录
unzip apollo-adminservice-1.6.0-github.zip -d apollo-adminservice-prod
unzip apollo-configservice-1.6.0-github.zip -d apollo-configservice-prod
unzip apollo-portal-1.6.0-github.zip -d apollo-portal
3、修改配置文件
3.1 修改生产环境adminservice、configservice配置
--进入目录
cd /opt/apollo
############################################ apollo-adminservice-prod ############################################
vim apollo-adminservice-prod/config/application-github.properties
# DataSource
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = apollo
spring.datasource.password = IOT@1033Ff
############################################ apollo-configservice-prod ############################################
vim apollo-configservice/config/application-github.properties
# DataSource
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = apollo
spring.datasource.password = IOT@1033Ff
3.2 复制生产环境的 adminservice 和 configservice目录,作为开发环境部署目录
cp -r apollo-adminservice-prod apollo-adminservice-dev
cp -r apollo-configservice-prod apollo-configservice-dev
修改开发环境配置
############################################ apollo-adminservice-dev ############################################vim apollo-configservice/
vim apollo-configservice-dev/scripts/startup.sh
#!/bin/bash
SERVICE_NAME=apollo-adminservice
Adjust log dir if necessary
LOG_DIR=/opt/logs/100003182
Adjust server port if necessary
SERVER_PORT=${SERVER_PORT:=8190}
....
############################################ apollo-configservice-dev ############################################vim apollo-configservice/
vim apollo-adminservice-dev/scripts/startup.sh
#!/bin/bash
SERVICE_NAME=apollo-configservice
Adjust log dir if necessary
LOG_DIR=/opt/logs/100003181
Adjust server port if necessary
SERVER_PORT=${SERVER_PORT:=8180}
.....
## 这里该的配置主要是为了避免跟生产环境的adminservice、configservice端口冲突,日志文件也要改
3.3 修改portal配置
############################################ apollo-portal ############################################
vim apollo-portal/config/application-github.properties
# DataSource
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/ApolloPortalDB?characterEncoding=utf8
spring.datasource.username = apollo
spring.datasource.password = IOT@1033Ff
---------------------------------------------------------------------------
vim apollo-portal/config/apollo-env.properties
pro.meta=http://localhost:8080
dev.meta=http://localhost:8180
#local.meta=http://localhost:8080
#fat.meta=http://fill-in-fat-meta-server:8080
#uat.meta=http://fill-in-uat-meta-server:8080
#lpt.meta=${lpt_meta}
四、数据库初始化
4.1 使用docker启动mysql
docker run --name mysql -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD="IOT@1033&ff" mysql:5.7
mysql> CREATE DATABASE ApolloPortalDB DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> CREATE DATABASE ApolloConfigDB DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> create user apollo@'%' identified by 'IOT@1033Ff';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'apollo'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
导入数据
mysql -uapollo -p"IOT@1033Ff" ApolloConfigDB < /opt/apolloconfigdb.sql
mysql -uapollo -p"IOT@1033Ff" ApolloPortalDB < /opt/apolloportaldb.sql
修改【apolloportaldb数据库】【serverconfig表】字段:apollo.portal.envs、configView.memberOnly.envs、apollo.portal.meta.servers
五、启动服务
5.1 启动生产环境
bash /opt/apollo/apollo-adminservice-prod/scripts/startup.sh
bash /opt/apollo/apollo-confingservice-prod/scripts/startup.sh
5.2 启动开发环境
bash /opt/apollo/apollo-adminservice-dev/scripts/startup.sh
bash /opt/apollo/apollo-confingservice-dev/scripts/startup.sh
5.3 启动portal
bash /opt/apollo/apollo-portal/scripts/startup.sh
六、访问
http://ip:8070 默认账号:apollo 默认密码:admin
点击实例项目。可以看到有两个环境列表