北京天津网站建设哪家公司好,制作网页软件手机版,上海百度移动关键词排名优化,seo精华网站2019独角兽企业重金招聘Python工程师标准 关于springboot的学习请参考前面的文章 接下来我们会开启一系列关于springcloud的学习文章。 一、概念 首先我们看下官方的解释 Service Discovery is one of the key tenets of a microservice-based architecture. Try… 2019独角兽企业重金招聘Python工程师标准 关于springboot的学习请参考前面的文章 接下来我们会开启一系列关于springcloud的学习文章。 一、概念 首先我们看下官方的解释 Service Discovery is one of the key tenets of a microservice-based architecture. Trying to hand-configure each client or some form of convention can be difficult to do and can be brittle. Eureka is the Netflix Service Discovery Server and Client. The server can be configured and deployed to be highly available, with each server replicating state about the registered services to the others.服务发现是基于微服务架构的关键原则之一。 尝试手动配置每个客户端或某种形式的约定可能很难做到并且可能很脆弱。 Eureka是Netflix服务发现服务器和客户端。 服务器可以配置和部署为高可用性每台服务器将注册服务的状态复制到其他服务器。 Spring Cloud Eureka,Eureka是个什么呢他主要是用来做服务治理的我们知道如果系统的服务少的情况下通过静态配置就行了。如果服务数量特别多静态配置如果修改维护起来就相当麻烦Eureka就是解决这个事儿的。 进一步解释 The Eureka server does not have a backend store, but the service instances in the registry all have to send heartbeats to keep their registrations up to date (so this can be done in memory). Clients also have an in-memory cache of Eureka registrations (so they do not have to go to the registry for every request to a service).
Eureka服务器没有后端存储但注册表中的服务实例必须发送心跳信号以保持其注册是最新的所以这可以在内存中完成。 客户端还有一个Eureka注册的内存缓存因此他们不必每次请求注册服务都去注册中心。 二.首先从spring官网下载一个关于springboot的项目 1.访问 https://start.spring.io/ 2.按照截图中的内容进行操作 3.将工程下载下来后导入到ideaidea会根据pom中的配置自动构建项目的依赖 二、在src/main/resources目录中的application.properties文件中填写一些配置 server.port1111
eureka.instance.hostnamelocalhost
eureka.client.register-with-eurekafalse
eureka.client.fetch-registryfalse
eureka.client.serviceUrl.defaultZonehttp://${eureka.instance.hostname}:${server.port}/eureka 1.配置解释 server.port : 服务器的ip eureka.instance.hostname : eureka的主机名 eureka.client.register-with-eureka : 这个项目是注册中心这个配置代表不向注册中心注册自己 eureka.client.fetch-registry : 注册中心的职务就是维护服务示例他不需要去检索服务。所以设置成false 三、主类配置启用EurekaServer 在 com/myspringboot/eurekaserver 包下的 EurekaServerApplication 上面加入 EnableEurekaServer 代表启用eureka服务 EnableEurekaServer
SpringBootApplication
public class EurekaServerApplication {public static void main(String[] args) {SpringApplication.run(EurekaServerApplication.class, args);}
}四、启动项目 访问 http://localhost:1111/ 我们看到这个界面就等于配置成功了 五、总结 本章介绍了注册中心的概念以及如何搭建单节点注册中心。 如果大家对此章有什么疑问欢迎留言提问。 转载于:https://my.oschina.net/u/1178126/blog/1815493