zoukankan      html  css  js  c++  java
  • zookeeper注册中心和客户端

    1、zookeeper和eureka区别 
    zookeeper向client进行ping操作,如果不通,就删除client节点
    eureka自我保护机制是client向注册中心发送心跳包,如果一定时间内没收到心跳包,则踢除client节点


    zookeeper工具ZooInspector

    @EnableDiscoveryClient 当服务使用consule、zookeeper时,使用@EnableDiscoveryClient向注册中心上注册服务
    ###订单服务的端口号
    server:
      port: 8002
    ###服务别名----服务注册到注册中心名称 
    spring:
      application:
        name: zk-member
      cloud:
        zookeeper:
          connect-string: 127.0.0.1:2181
    ## 关闭安全控制
    #management: 
    # security: 
    #  enabled: false

    consule通过yml配置client ,其他与zookeeper一样

     

     获取注册服务中心的服务信息函数

    @RequestMapping("/getServiceUrl")
        public List<String> getServiceUrl() {
            List<ServiceInstance> list = discoveryClient.getInstances("zk-member");
            List<String> services = new ArrayList<>();
            for (ServiceInstance serviceInstance : list) {
                if (serviceInstance != null) {
                    services.add(serviceInstance.getUri().toString());
                }
            }
            return services;
        }

  • 相关阅读:
    如何让json_decode解码变的更加强壮
    scp命令
    Centos7安装postgresql
    ubuntu安装Java环境
    ubuntu开放端口
    VMware安装Ubuntu
    redis主从安装
    redis主从学习
    redis集群学习
    C++ 09 顺序容器
  • 原文地址:https://www.cnblogs.com/zhaoyanhaoBlog/p/11947490.html
Copyright © 2011-2022 走看看