先每个环境写个springboot项目作为APOLLO自己用的eureka注册中心
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>eureka-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>eureka-server</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.example.eurekaserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
server:
port: 9001
# ??eureka???
eureka:
client:
register-with-eureka: false # ????????
fetch-registry: false # ??????????????
service-url:
defaultZone: http://localhost:9001/eureka/ # eureka??????
代码仓库下载三个ZIP后,分别复制修改
1-四台EUREKA,各自端口不同
2-修改每个amdinservice的端口以及它使用的EUREKA的端口,以及使用的CONFIGDB的地址
3-修改每个configservice的端口以及它使用的EUREKA的端口,以及使用的CONFIGDB的地址
4-修改PORTAL使用的PROTALDB的地址
local
EUREKA 9001
ADMIN 8090 CONFIG 8080
fat
EUREKA 9002
ADMIN 8091 CONFIG 8081
uat
EUREKA 9003
ADMIN 8092 CONFIG 8082
PRD
EUREKA 9004
ADMIN 8093 CONFIG 8083
protal
8070
完整架构:
所以每个环境有自己的EUREKA,CONFIGSERVICE,ADMINSERVICE,CONFIGDB。
所有环境共用一个PORTAL,背后有个PORTALDB