Apollo部署

时间:2022-11-03 17:18:11

一、JDK安装

1. 解压

tar fx jdk-8u301-linux-x64.tar.gz -C /usr/local

2. 配置环境变量

vim /etc/profile
JAVA_HOME=/usr/local/jdk1.8.0_301
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar

3. 重新加载环境变量

source /etc/proflie

4. 测试

Apollo部署

二、Mysql安装

1. 配置yum源

wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

2. 安装rpm包

rpm -ivh mysql57-community-release-el7-11.noarch.rpm

3. 安装mysql服务

yum install -y mysql-server

4. 启动服务

systemctl start mysqld
systemctl enable mysqld

5. 查看初始密码

cat /var/log/mysqld.log|grep 'A temporary password'

6. 修改密码

alter user 'root'@'localhost' identified by 'your_password';

三、Apollo安装

1. 下载软件包

wget https://github.com/apolloconfig/apollo/releases/download/v1.9.0/apollo-adminservice-1.9.0-github.zip
wget https://github.com/apolloconfig/apollo/releases/download/v1.9.0/apollo-configservice-1.9.0-github.zip
wget https://github.com/apolloconfig/apollo/releases/download/v1.9.0/apollo-portal-1.9.0-github.zip

2. 下载数据库

wget https://github.com/ctripcorp/apollo/blob/master/scripts/sql/delta/v180-v190/apolloconfigdb-v180-v190.sql
wget https://github.com/ctripcorp/apollo/blob/master/scripts/sql/delta/v180-v190/apolloportaldb-v180-v190.sql

3.创建数据库

CREATE DATABASE IF NOT EXISTS ApolloConfigDB DEFAULT CHARACTER SET = utf8mb4;
CREATE DATABASE IF NOT EXISTS ApolloPortalDB DEFAULT CHARACTER SET = utf8mb4;
grant all on ApolloConfigDB.* to 'apollouser'@'%' identified by 'apollopassword';
grant all on ApolloPortalDB.* to 'apollouser'@'%' identified by 'apollopassword';

4. 导入数据库

mysql -uroot -p ApolloConfigDB < apolloconfigdb-v180-v190.sql
mysql -uroot -p ApolloPortalDB < apolloportaldb-v180-v190.sql

5. 安装Config Service

1)解压
mkdir /opt/apollo-config
unzip apollo-configservice-1.9.0-github.zip -d /opt/apollo-config
2)修改配置文件
vim /opt/apollo-config/config/application-github.properties
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = apollouser
spring.datasource.password = apollopassword
3)启动服务
/opt/apollo-config/scripts/startup.sh

6. 安装Admin Service

1)解压
mkdir /opt/apollo-admin
unzip apollo-adminservice-1.9.0-github.zip -d /opt/apollo-admin
2)修改配置文件
vim /opt/apollo-admin/config/application-github.properties
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = apollouser
spring.datasource.password = apollopassword
3)启动服务
/opt/apollo-admin/scripts/startup.sh

7. 安装portal

1)解压
mkdir /opt/apollo-portal
unzip apollo-portal-1.9.0-github.zip -d /opt/apollo-portal
2)修改配置文件
vim /opt/apollo-portal/config/application-github.properties
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/ApolloPortalDB?characterEncoding=utf8
spring.datasource.username = apollouser
spring.datasource.password = apollopassword
vim /opt/apollo-portal/config/apollo-env.properties
#分布式部署,需添加多条记录
pro.meta=http://127.0.0.1:8080
备注:
1.如果eureka配置集群模式,填入地址,使用逗号隔开
2.分布式部署需要管理多个环境,apollo.portal.envs的值应设置多个
update apolloportaldb.ServerConfig set Value="DEV,FAT,UAT,PRO" where Id=1;
3.ApolloPortalDB只需要在生产环境部署一个即可,而ApolloConfigDB需要每个环境部署一套
3)启动服务
/opt/apollo-portal/scripts/startup.sh

8. 测试

地址:192.168.9.71:8070
用户:apollo
密码:admin

Apollo部署