1.怎么搭建集群版的eureka:
需要在eureka yml文件中配置其它eureka的服务地址。如下7001的服务配置的是7002的地址,7002的服务配置的是7001的地址。相互关联。
server:
port: 7001
spring:
application:
name: eureka-cloud-7001
datasource:
url: jdbc:mysql://127.0.0.1:3306/cloud?useUnicode=true&characterEncoding=utf8&useSSL=false
driverClassName: com.mysql.jdbc.Driver
password: root
username: root
eureka:
instance:
hostname: eureka-cloud-7001
client:
register-with-eureka: false
fetch-registry: false
serviceUrl:
defaultZone: http://eureka-cloud-7002:7002/eureka/
2.集群版的生产者服务:
修改host文件模拟多个服务器。修改yml文件,将服务注册到eureka服务中去,
server:
port: 7002
spring:
application:
name: eureka-cloud-7002
datasource:
url: jdbc:mysql://127.0.0.1:3306/cloud?useUnicode=true&characterEncoding=utf8&useSSL=false
driverClassName: com.mysql.jdbc.Driver
password: root
username: root
eureka:
instance:
hostname: eureka-cloud-7002
client:
register-with-eureka: false
fetch-registry: false
serviceUrl:
defaultZone: http://eureka-cloud-7001:7001/eureka/
网友评论