一、环境准备
操作系统:CentOS release 7.5 (启动脚本理论上支持所有Linux发行版,建议)JDK :jdk1.8.0_162 (建议安装Java 1.8+)MySQL:5.7.26 (Apollo的表结构对timestamp使用了多个default声明,所以需要5.6.5以上版本)架构:(官方默认支持DEV(开发环境)、FAT(功能测试)、UAT(回归测试)、PRO(生产环境),由于机器有限,只部署Dev,Pro)Portal service: 172.16.150.131 Dev config&& admin 172.16.150.132Pro config && admin 172.16.150.133#自定义环境参考: 关闭防火墙同步时间 #注意事项: 如果实际部署的机器有多块网卡(如docker),或者存在某些网卡的IP是Apollo客户端和Portal无法访问的(如网络安全限制),那么我们就需要在apollo-configservice和apollo-adminservice中做相关限制以避免Eureka将这些网卡的IP注册到Meta Server。 参考地址:
二、服搭建数据库服务及创建相关库
1.搭建MySQL
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpmrpm -ivh mysql80-community-release-el7-3.noarch.rpmvim mysql-community.repo #启动5.7,禁用8.0
yum clean all && yum makecacheyum install mysql-community-server -ysystemctl start mysqldgrep "temporary password" /var/log/mysqld.log #获取MySQL初始化密码mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 152Server version: 5.7.26 MySQL Community Server (GPL) #MySQL版本号...mysql> \qBye
#以上操作在三台服务器都需要执行
2.创建Apollo PortalDB数据库(在Portal service:172.16.150.131服务器上操作)
wget https://raw.githubusercontent.com/ctripcorp/apollo/master/scripts/db/migration/portaldb/V1.0.0__initialization.sql #下载官方提供的SQL文件mysql -uroot -pmysql> source /root/V1.0.0__initialization.sql #手动导入show databases;use ApolloPortalDB;show tables; select `Id`, `Key`, `Value`, `Comment` from `ApolloPortalDB`.`ServerConfig` limit 1;
3.创建ApolloConfigDB数据库(172.16.150.132、172.16.150.133上部署)
wget https://raw.githubusercontent.com/ctripcorp/apollo/master/scripts/db/migration/configdb/V1.0.0__initialization.sql source /root/V1.0.0__initialization.sqlselect `Id`, `Key`, `Value`, `Comment` from `ApolloConfigDB`.`ServerConfig` limit 1;
三、安装Apollo服务
1.安装apollo-portal 服务(在Portal service:172.16.150.131服务器上执行)
https://github.com/ctripcorp/apollo/releases/download/v1.4.0/apollo-portal-1.4.0-wget github.zipunzip apollo-portal-1.4.0-github.zipcd apollo-portal/cat config/application-github.properties #ApolloPortalDB数据库连接串信息# DataSourcespring.datasource.url = jdbc:mysql://172.16.150.131:3306/ApolloPortalDB?characterEncoding=utf8spring.datasource.username = xxxxspring.datasource.password = xxx cat config/apollo-env.properties #配置apollo-portal的meta service信息dev.meta=http://172.16.150.132:8080pro.meta=http://172.16.150.133:8080
修改Apollo-portal启动脚本
[root@localhost ~]# grep "^export JAVA_OPTS" apollo-portal/scripts/startup.sh #根据实际情况修改相应的值export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=8"
2.配置apollo-configservice、apollo-adminservice(172.16.150.132、172.16.150.133上操作)
https://github.com/ctripcorp/apollo/releases/download/v1.4.0/apollo-adminservice-1.4.0-github.ziphttps://github.com/ctripcorp/apollo/releases/download/v1.4.0/apollo-configservice-1.4.0-github.zipunzip apollo-adminservice-1.4.0-github.zipunzip apollo-configservice-1.4.0-github.zip[root@localhost ~]# cat apollo-adminservice/config/application-github.properties # DataSourcespring.datasource.url = jdbc:mysql://172.16.150.132:3306/ApolloConfigDB?characterEncoding=utf8 #注意修改MySQL连接地址spring.datasource.username = rootspring.datasource.password = xxxx[root@localhost ~]# cat apollo-configservice/config/application-github.properties #注意修改MySQL连接地址# DataSourcespring.datasource.url = jdbc:mysql://172.16.150.132:3306/ApolloConfigDB?characterEncoding=utf8spring.datasource.username = rootspring.datasource.password = xxx
修改apollo-configservice、apollo-adminservice启动脚本
[root@localhost ~]# grep "^export JAVA_OPTS" apollo-configservice/scripts/startup.sh #根据实际情况修改相应的值
export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=8"[root@localhost ~]# grep "^export JAVA_OPTS" apollo-adminservice/scripts/startup.sh
export JAVA_OPTS="-server -Xms1024m -Xmx1024m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:SurvivorRatio=8"3.启动服务
#要先启动apollo-configservice再启动apollo-adminservice等所有apollo-configservice和apollo-adminservice启动完成后再启动apollo-portal
scripts/startup.sh #启动scripts/shutdown.sh #关闭服务
日志文件查看
apollo-configservice /opt/logs/100003171/ #日志路径启动脚本中可定义路径apollo-adminservice /opt/logs/100003172apollo-portal /opt/logs/100003173
登录Apollo,浏览器访问apollo-portal服务,端口8070,初始用户名是apollo,密码是admin