高可用Eureka集羣

加入依賴

<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.9.RELEASE</version>
	</parent>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>Dalston.SR4</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-web</artifactId>
			</dependency>

			<dependency>
				<groupId>org.projectlombok</groupId>
				<artifactId>lombok</artifactId>
				<optional>true</optional>
			</dependency>
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-starter-test</artifactId>
				<scope>test</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>
	<modules>
		<module>eurekaServer</module>
			<module>eurekaServer-ha</module>
	</modules>
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>
	<distributionManagement>
		<repository>
			<id>lcl_hosted</id>
			<url>http://localhost:8081/repository/lcl_hosted/</url>
		</repository>
	</distributionManagement>

啓動類

package com.liu.fukua;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class Application {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

}

配置

spring.application.name=eureka-server
server.port=8761

eureka.instance.hostname=eureka1

#設置服務註冊中心地址,指向另一個註冊中心
eureka.client.serviceUrl.defaultZone=http://user:123456@eureka2:8761/eureka/


# 安全認證
#開啓基於http basic的安全認證
security.basic.enabled=true  
security.user.name=user
security.user.password=123456

spring.application.name=eureka-server
server.port=8761

eureka.instance.hostname=eureka2

#設置服務註冊中心地址,指向另一個註冊中心
eureka.client.serviceUrl.defaultZone=http://user:123456@eureka1:8761/eureka/



# 安全認證
#開啓基於http basic的安全認證
security.basic.enabled=true  
security.user.name=user
security.user.password=123456

啓動

	java -jar  eurekaServer-ha-0.0.1-SNAPSHOT.jar --spring.profiles.active=eureka2
	java -jar  eurekaServer-ha-0.0.1-SNAPSHOT.jar --spring.profiles.active=eureka1

效果

在這裏插入圖片描述

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章