spring cloud 使用consul作为注册中心

1.安装consul

使用docker安装

查找consul镜像    docker search consul 

下载镜像          docker pull consul

启动镜像          docker run -d -p 8500:8500  consul agent -server -bootstrap-expect=1   -

                  client 0.0.0.0 -ui

查看启动结果 netstat -tunlp       有8500启动成功    打开防火墙

使用浏览器打开8500  查看web界面

2.新建spring boot 项目

pom.xml 添加依赖

  <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>

application.properties 添加配置

server.port=8081
spring.application.name=consul-client spring.cloud.consul.host=127.0.0.1
spring.cloud.consul.port=8500 spring.cloud.consul.discovery.service-name=consul-client spring.cloud.consul.discovery.prefer-ip-address=true

启动类注解 @EnableDiscoveryClient

@SpringBootApplication
@EnableDiscoveryClient
public class ConsulClientApplication { public static void main(String[] args) {
SpringApplication.run(ConsulClientApplication.class, args);
} }

启动工程  查看consul中心服务

我这里健康检查是因为两个服务网络不互通   consul在阿里云服务器   consul-client 是本地工程

spring cloud(一) 副 consul的更多相关文章

  1. Spring Cloud 系列之 Consul 注册中心(二)

    本篇文章为系列文章,未读第一集的同学请猛戳这里:Spring Cloud 系列之 Consul 注册中心(一) 本篇文章讲解 Consul 集群环境的搭建. Consul 集群 上图是一个简单的 Co ...

  2. 服务注册发现consul之二:在Spring Cloud中使用Consul实现服务的注册和发现

    首先安装consul环境,参照之前的文章:<服务注册发现consul之一:consul介绍及安装>中的第一节介绍. Spring Cloud使用Consul的服务与发现 1.导入依赖pri ...

  3. Spring Cloud 系列之 Consul 注册中心(一)

    Netflix Eureka 2.X https://github.com/Netflix/eureka/wiki 官方宣告停止开发,但其实对国内的用户影响甚小,一方面国内大都使用的是 Eureka ...

  4. Spring Cloud 系列之 Consul 配置中心

    前面我们已经学习过 Spring Cloud Config 了: Spring Cloud 系列之 Config 配置中心(一) Spring Cloud 系列之 Config 配置中心(二) Spr ...

  5. spring cloud:搭建基于consul的服务提供者集群(spring cloud hoxton sr8 / spring boot 2.3.4)

    一,搭建基于consul的服务提供者集群 1,consul集群,共3个实例: 2, 服务提供者集群:共2个实例: 3,服务消费者:一个实例即可 4,consul集群的搭建,请参考: https://w ...

  6. Spring Cloud Consul

    1.2.0.RELEASE 该项目通过自动配置并绑定到Spring环境和其他Spring编程模型成语,为Spring Boot应用程序提供Consul集成.通过几个简单的注释,您可以快速启用和配置应用 ...

  7. 一起来学spring Cloud | 第一章:spring Cloud 与Spring Boot

    目前大家都在说微服务,其实微服务不是一个名字,是一个架构的概念,大家现在使用的基于RPC框架(dubbo.thrift等)架构其实也能算作一种微服务架构. 目前越来越多的公司开始使用微服务架构,所以在 ...

  8. Spring Cloud config之二:功能介绍

    SVN配置仓库 示例见:http://lvdccyb.iteye.com/blog/2282407 本地仓库 本地文件系统 使用本地加载配置文件.需要配置:spring.cloud.config.se ...

  9. Spring Cloud与微服务构建:Spring Cloud简介

    Spring Cloud简介 微服务因该具备的功能 微服务可以拆分为"微"和"服务"二字."微"即小的意思,那到底多小才算"微&q ...

随机推荐

  1. C#中的stathread标签【待填的坑】

    stathread这种线程是给COM组件使用的线程,如果不适用com对象 如果com对象标记为sta的,则它就是单线程运行的 stathread 组件线程遗留的标签

  2. Codeforces 525E Anya and Cubes 中途相遇法

    题目链接:点击打开链接 题意: 给定n个数.k个感叹号,常数S 以下给出这n个数. 目标: 随意给当中一些数变成阶乘.至多变k个. 再随意取一些数,使得这些数和恰好为S 问有多少方法. 思路: 三进制 ...

  3. unity font研究小结

    项目用ngui制作的界面.字体使用了unity默认的Arial,公布后在一些android手机上发现中文不显示,就此作了一些调查. 參考unity的font说明文档:http://docs.unity ...

  4. Justinmind使用教程(1)——概述部分

    Justinmind(http://www.justinmind.com/),类似于Axure的一个原型设计工具.就眼下而言,最适合移动端进行原型设计的工具,预计抛开Axure几条街了,可是眼下国内站 ...

  5. git笔记之eclipse使用github远程仓库进行版本号管理

    原文地址:http://dtbuluo.com/90.html 这里记录一下eclipse开发工具中git的使用说明. 环境:centOS.eclipse-jee-kepler-SR2-linux-g ...

  6. Red Hat Linux分辨率调整

    在/etc/X11下手动产生xorg.conf文件, # vi /etc/X11/xorg.conf 文件中内容如下: ##Add the following codes: Section " ...

  7. oc23--变量修饰符

    // // Person.h #import <Foundation/Foundation.h> /* @public:所有类访问 @private:本类访问 @protected:本类子 ...

  8. CodeForces 131C C (组合)

    There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory" ...

  9. (Go)02.go 安装delve调试工具测试

    安装调试工具 go get github.com/derekparker/delve/cmd/dlv 增加断点调试 调试--->启动调试

  10. Javascript万物皆对象?

    在javascript的世界里,有这么一句话,万物皆对象. 但是这个对象,应该怎么理解呢? exm........??,难道值类型也是对象?!! 当然,不是. 准确地讲是对于“引用类型”而言. 那,在 ...