spring cloud eureka server 单节点配置
-
使用 idea 创建 eureka-server
-
重命名 application.yml 并加入如下配置信息
spring:
application:
name: eureka-server
server:
port: 1111
eureka:
instance:
hostname: peer1
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://peer1:1111/eureka
server:
enable-self-preservation: false
-
启用 EnableEurekaServer
-
在
C:\Windows\System32\drivers\etc\hosts
文件中加入域名映射
127.0.0.1 peer1 peer2 peer3
spring cloud eureka server 双节点设置
在 resources
文件夹下创建两个节点的配置文件
- 节点一:
application-peer1.yml
spring:
application:
name: eureka-server
server:
port: 1111
eureka:
instance:
hostname: peer1
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://peer2:2222/eureka
server:
enable-self-preservation: false
- 节点二:
application-peer2.yml
spring:
application:
name: eureka-server
server:
port: 2222
eureka:
instance:
hostname: peer2
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://peer1:1111/eureka
server:
enable-self-preservation: false
使用 eureka’s rest api 查看 content of registry: 查看一个服务的所有实例信息
http://<eureka service>:<port>/eureka/apps/<APPID>
例子:查看 eureka-server 注册信息
网友评论