docker安装nacos指南教程版

  • 161

docker安装nacos指南

Nacos是阿里巴巴集团开源的一款服务注册与发现的中间件产品,与zookeeper提供的功能大体一致,都是用于服务的注册与发现。但是Nacos相较于zookeeper提供了更为全面的功能,比如:动态配置服务、动态 DNS 服务等等。

Nacos简介

Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。

Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。 Nacos 是构建以“服务”为中心的现代应用架构 (例如微服务范式、云原生范式) 的服务基础设施。

Nacos特性

  • 服务发现和服务健康监测
    Nacos 支持基于 DNS 和基于 RPC 的服务发现。服务提供者使用 原生SDK、OpenAPI、或一个独立的Agent TODO注册 Service 后,服务消费者可以使用DNS TODO 或HTTP&API查找和发现服务。
    Nacos 提供对服务的实时的健康检查,阻止向不健康的主机或服务实例发送请求。Nacos 支持传输层 (PING 或 TCP)和应用层 (如 HTTP、MySQL、用户自定义)的健康检查。 对于复杂的云环境和网络拓扑环境中(如 VPC、边缘网络等)服务的健康检查,Nacos 提供了 agent 上报模式和服务端主动检测2种健康检查模式。Nacos 还提供了统一的健康检查仪表盘,帮助您根据健康状态管理服务的可用性及流量。
  • 动态配置服务
    动态配置服务可以让您以中心化、外部化和动态化的方式管理所有环境的应用配置和服务配置。
    动态配置消除了配置变更时重新部署应用和服务的需要,让配置管理变得更加高效和敏捷。
    配置中心化管理让实现无状态服务变得更简单,让服务按需弹性扩展变得更容易。
    Nacos 提供了一个简洁易用的UI 帮助您管理所有的服务和应用的配置。Nacos 还提供包括配置版本跟踪、金丝雀发布、一键回滚配置以及客户端配置更新状态跟踪在内的一系列开箱即用的配置管理特性,帮助您更安全地在生产环境中管理配置变更和降低配置变更带来的风险。
  • 动态 DNS 服务
    动态 DNS 服务支持权重路由,让您更容易地实现中间层负载均衡、更灵活的路由策略、流量控制以及数据中心内网的简单DNS解析服务。动态DNS服务还能让您更容易地实现以 DNS 协议为基础的服务发现,以帮助您消除耦合到厂商私有服务发现 API 上的风险。
  • 服务及其元数据管理
    Nacos 能让您从微服务平台建设的视角管理数据中心的所有服务及元数据,包括管理服务的描述、生命周期、服务的静态依赖分析、服务的健康状态、服务的流量管理、路由及安全策略、服务的 SLA 以及最首要的 metrics 统计数据。

Nacos的docker化部署

本篇文章分享的是nacos1.0.0版本的docker化部署,方式为单机部署,后续会持续更新nacos的集群部署方式。

从dockerHub仓库中拉取naocs镜像

//拉取nacos-server:1.0.0镜像
docker pull nacos/nacos-server:1.0.0

拉取后查看本地镜像

docker images
nacos/nacos-server                           1.0.0               00e14f790e63        10 weeks ago        697 MB

启动nacos镜像

//-env MODE=standalone 设置启动方式为单机模式
//--name 容器名称
//-p 端口映射为 8848
//nacos/nacos-server:1.0.0 本地镜像
docker run --env MODE=standalone --name nacos -d -p 8848:8848 nacos/nacos-server:1.0.0

查看容器

docker ps
c03f449b206e        nacos/nacos-server:1.0.0   "bin/docker-startup.s"   25 hours ago        Up 48 minutes       0.0.0.0:8848->8848/tcp                                           nacos1

进入naocs容器中

//通过/bin/bash方式进入nacos容器中
docker exec -it c03f449b206e /bin/bash
//进入容器中可以查看nacos的安装目录
[root@c03f449b206e nacos]# ls
LICENSE  NOTICE  bin  conf  data  derby.log  init.d  logs  plugins  target  work

nacos服务安装好后,可以通过nacos的conf目录对nacos服务进行配置。
注:如果系统所要注册的服务比较多的话,建议关闭nacos中的部分日志配置,工作中亲身经历nacos的日志如果没有进行有效管理的话,nacos的日志量是非常庞大的,毫不夸张的说nacos的日志量在一周内可达5GB+以上,时间一长就会撑爆物理机的容量存储,故而docker中的应用就会变为只读状态,无法进行服务注册与发现,导致系统崩溃。所以,我们需要对nacos的日志进行适当的屏蔽或者定时删除,可参考文章如何屏蔽Nacos日志输出?

通过上述步骤,就完成了对nacos应用的docker化部署,使用docker run命令后就会自动启动nacos服务。

本地nacos服务访问地址:

http://127.0.0.1:8848/nacos/index.html#/

nacos的初始化用户名/密码 nacos/nacos 如下图:

docker安装nacos指南

进入管理页面后,可以使用配置列表、监听查询、服务列表等功能,如下图:

docker安装nacos指南

dubbo集成nacos

dubbo是一款分布式RPC调用框架,可以完美的集成nacos注册中心。让服务注册与发现变得更加简单。
本次分享创建的工程是基于springboot框架,所以dubbo的依赖引用了start

  • maven依赖
<dependency>
            <groupId>com.alibaba.boot</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>0.2.0</version>
</dependency>

<dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo-registry-nacos</artifactId>
            <version>0.0.1</version>
</dependency>

首先,来看下生产者的服务配置以及代码实现
这里分享的duboo案例是基于注解来实现的

  • springboot的配置文件信息
dubbo.scan.basePackages=com.liumengxi.hellodemo //dubbo注解扫描的类文件
dubbo.application.id=hellodemo                  //应用id
dubbo.application.name=hellodemo                //应用名称
dubbo.application.environment=product           //应用环境
dubbo.registry.address=nacos://127.0.0.1:8848   //注册地址
dubbo.registry.session=20000                    //注册会话
dubbo.registry.check=false                      //注册检查
dubbo.protocol.threads=300                      //协议线程数
dubbo.protocol.iothreads=20                     //协议io线程数
dubbo.protocol.queues=512                       //协议队列
dubbo.service.core.version=1.0                  //服务版本号
dubbo.service.core.group=dev                    //服务组
  • 暴露的服务接口
package com.liumengxi.hellodemo.service;

/**
 * @author liumengxi.zh
 * @date 2019/09/11
 */
public interface HelloDemo {
    String mxSayHello(String word);
}

服务的实现类如下,在实际开发中一般会把服务的接口和服务的实现类分开,将服务的接口作为maven依赖引入实现类中。

package com.liumengxi.hellodemo.service;
import com.alibaba.dubbo.config.annotation.Service;
/**
 * @Description 实现类
 * @Author mengxi.zh
 * @date 2019-09-11 14:21
 */
@Service(interfaceClass = HelloDemo.class, version = "${dubbo.service.core.version}",
    group = "${dubbo.service.core.group}", retries = -1)
public class HelloDemoImpl implements HelloDemo {
    @Override
    public String mxSayHello(String word) {
        String result = "mengxi say " + word;
        return result;
    }
}

稍微解释下上述注解的含义。
@Service注解引用的是dubbo里的注解,而并不是spring中的@service注解。
interfaceClass表示对外暴露的接口名称。
version 表示接口的版号
group 表示服务组

上面的例子写完后,就可以启动springboot的主类,将应用启动后,生产者的服务就会被注册到Nacos,启动日志如下:


 :: Dubbo Spring Boot (v0.2.0) : https://github.com/apache/incubator-dubbo-spring-boot-project
 :: Dubbo (v2.6.2) : https://github.com/apache/incubator-dubbo
 :: Google group : dev@dubbo.incubator.apache.org

2019-09-17 11:19:31.772  INFO 16468 --- [           main] e.OverrideDubboConfigApplicationListener : Dubbo Config was overridden by externalized configuration {dubbo.application.environment=product, dubbo.application.id=hellodemo, dubbo.application.name=hellodemo, dubbo.protocol.iothreads=20, dubbo.protocol.queues=512, dubbo.protocol.threads=300, dubbo.registry.address=nacos://127.0.0.1:8848, dubbo.registry.check=false, dubbo.registry.session=20000, dubbo.scan.basePackages=com.liumengxi.hellodemo, dubbo.service.core.group=dev, dubbo.service.core.version=1.0}

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.8.RELEASE)

2019-09-17 11:19:33.062  INFO 16468 --- [           main] c.l.hellodemo.HelloDemoApplication       : No active profile set, falling back to default profiles: default
2019-09-17 11:19:34.570  INFO 16468 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : hellodemo, class : com.alibaba.dubbo.config.ApplicationConfig] has been registered.
2019-09-17 11:19:34.575  INFO 16468 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : hellodemo] has been registered.
2019-09-17 11:19:34.576  INFO 16468 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : com.alibaba.dubbo.config.RegistryConfig#0, class : com.alibaba.dubbo.config.RegistryConfig] has been registered.
2019-09-17 11:19:34.577  INFO 16468 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : com.alibaba.dubbo.config.RegistryConfig#0] has been registered.
2019-09-17 11:19:34.577  INFO 16468 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : com.alibaba.dubbo.config.ProtocolConfig#0, class : com.alibaba.dubbo.config.ProtocolConfig] has been registered.
2019-09-17 11:19:34.577  INFO 16468 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : com.alibaba.dubbo.config.ProtocolConfig#0] has been registered.
2019-09-17 11:19:34.868  INFO 16468 --- [           main] b.f.a.ServiceAnnotationBeanPostProcessor :  [DUBBO] BeanNameGenerator bean can't be found in BeanFactory with name [org.springframework.context.annotation.internalConfigurationBeanNameGenerator], dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:34.868  INFO 16468 --- [           main] b.f.a.ServiceAnnotationBeanPostProcessor :  [DUBBO] BeanNameGenerator will be a instance of org.springframework.context.annotation.AnnotationBeanNameGenerator , it maybe a potential problem on bean name generation., dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:34.906  WARN 16468 --- [           main] b.f.a.ServiceAnnotationBeanPostProcessor :  [DUBBO] The BeanDefinition[Root bean: class [com.alibaba.dubbo.config.spring.ServiceBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] of ServiceBean has been registered with name : ServiceBean:helloDemoImpl:com.liumengxi.hellodemo.service.HelloDemo:${dubbo.service.core.version}:${dubbo.service.core.group}, dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:34.907  INFO 16468 --- [           main] b.f.a.ServiceAnnotationBeanPostProcessor :  [DUBBO] 1 annotated Dubbo's @Service Components { [Bean definition with name 'helloDemoImpl': Generic bean: class [com.liumengxi.hellodemo.service.HelloDemoImpl]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/Users/Documents/dockerDemo/hello-demo/target/classes/com/liumengxi/hellodemo/service/HelloDemoImpl.class]] } were scanned under package[com.liumengxi.hellodemo], dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:34.909  INFO 16468 --- [           main] o.s.c.a.ConfigurationClassPostProcessor  : Cannot enhance @Configuration bean definition 'com.alibaba.boot.dubbo.autoconfigure.DubboAutoConfiguration' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2019-09-17 11:19:35.521  INFO 16468 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'relaxedDubboConfigBinder' of type [com.alibaba.boot.dubbo.autoconfigure.RelaxedDubboConfigBinder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-17 11:19:35.523  INFO 16468 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'relaxedDubboConfigBinder' of type [com.alibaba.boot.dubbo.autoconfigure.RelaxedDubboConfigBinder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-17 11:19:35.525  INFO 16468 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'relaxedDubboConfigBinder' of type [com.alibaba.boot.dubbo.autoconfigure.RelaxedDubboConfigBinder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-17 11:19:35.600  INFO 16468 --- [           main] .f.a.DubboConfigBindingBeanPostProcessor : The properties of bean [name : hellodemo] have been binding by prefix of configuration properties : dubbo.application
2019-09-17 11:19:35.614  INFO 16468 --- [           main] .f.a.DubboConfigBindingBeanPostProcessor : The properties of bean [name : com.alibaba.dubbo.config.RegistryConfig#0] have been binding by prefix of configuration properties : dubbo.registry
2019-09-17 11:19:35.631  INFO 16468 --- [           main] .f.a.DubboConfigBindingBeanPostProcessor : The properties of bean [name : com.alibaba.dubbo.config.ProtocolConfig#0] have been binding by prefix of configuration properties : dubbo.protocol
2019-09-17 11:19:36.669  INFO 16468 --- [           main] com.alibaba.dubbo.config.AbstractConfig  :  [DUBBO] The service ready on spring started. service: com.liumengxi.hellodemo.service.HelloDemo, dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:37.049  INFO 16468 --- [           main] com.alibaba.dubbo.config.AbstractConfig  :  [DUBBO] Export dubbo service com.liumengxi.hellodemo.service.HelloDemo to local registry, dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:37.050  INFO 16468 --- [           main] com.alibaba.dubbo.config.AbstractConfig  :  [DUBBO] Export dubbo service com.liumengxi.hellodemo.service.HelloDemo to url dubbo://192.168.43.146:20880/com.liumengxi.hellodemo.service.HelloDemo?anyhost=true&application=hellodemo&bind.ip=192.168.43.146&bind.port=20880&dubbo=2.6.2&environment=product&generic=false&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&iothreads=20&methods=mxSayHello&pid=16468&queues=512&retries=-1&revision=1.0&side=provider&threads=300×tamp=1568690376721&version=1.0, dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:37.050  INFO 16468 --- [           main] com.alibaba.dubbo.config.AbstractConfig  :  [DUBBO] Register dubbo service com.liumengxi.hellodemo.service.HelloDemo url dubbo://192.168.43.146:20880/com.liumengxi.hellodemo.service.HelloDemo?anyhost=true&application=hellodemo&bind.ip=192.168.43.146&bind.port=20880&dubbo=2.6.2&environment=product&generic=false&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&iothreads=20&methods=mxSayHello&pid=16468&queues=512&retries=-1&revision=1.0&side=provider&threads=300×tamp=1568690376721&version=1.0 to registry registry://127.0.0.1:8848/com.alibaba.dubbo.registry.RegistryService?application=hellodemo&check=false&dubbo=2.6.2&environment=product&pid=16468®istry=nacos&session=20000×tamp=1568690376683, dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:37.714  INFO 16468 --- [           main] c.a.d.remoting.transport.AbstractServer  :  [DUBBO] Start NettyServer bind /0.0.0.0:20880, export /192.168.43.146:20880, dubbo version: 2.6.2, current host: 192.168.43.146
Tue Sep 17 11:19:37 CST 2019 sun.misc.Launcher$AppClassLoader@18b4aac2 JM.Log:INFO Init JM logger with Slf4jLoggerFactory success, sun.misc.Launcher$AppClassLoader@18b4aac2
Tue Sep 17 11:19:37 CST 2019 sun.misc.Launcher$AppClassLoader@18b4aac2 JM.Log:INFO Log root path: /Users/logs/
Tue Sep 17 11:19:37 CST 2019 sun.misc.Launcher$AppClassLoader@18b4aac2 JM.Log:INFO Set nacos log path: /Users/logs/nacos
2019-09-17 11:19:37.954  INFO 16468 --- [           main] c.a.dubbo.registry.nacos.NacosRegistry   :  [DUBBO] Register: dubbo://192.168.43.146:20880/com.liumengxi.hellodemo.service.HelloDemo?anyhost=true&application=hellodemo&dubbo=2.6.2&environment=product&generic=false&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&iothreads=20&methods=mxSayHello&pid=16468&queues=512&retries=-1&revision=1.0&side=provider&threads=300×tamp=1568690376721&version=1.0, dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:39.182  INFO 16468 --- [           main] c.a.dubbo.registry.nacos.NacosRegistry   :  [DUBBO] Subscribe: provider://192.168.43.146:20880/com.liumengxi.hellodemo.service.HelloDemo?anyhost=true&application=hellodemo&category=configurators&check=false&dubbo=2.6.2&environment=product&generic=false&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&iothreads=20&methods=mxSayHello&pid=16468&queues=512&retries=-1&revision=1.0&side=provider&threads=300×tamp=1568690376721&version=1.0, dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:39.395  WARN 16468 --- [           main] c.a.dubbo.registry.nacos.NacosRegistry   :  [DUBBO] Ignore empty notify urls for subscribe url provider://192.168.43.146:20880/com.liumengxi.hellodemo.service.HelloDemo?anyhost=true&application=hellodemo&category=configurators&check=false&dubbo=2.6.2&environment=product&generic=false&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&iothreads=20&methods=mxSayHello&pid=16468&queues=512&retries=-1&revision=1.0&side=provider&threads=300×tamp=1568690376721&version=1.0, dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:39.399  WARN 16468 --- [client.listener] c.a.dubbo.registry.nacos.NacosRegistry   :  [DUBBO] Ignore empty notify urls for subscribe url provider://192.168.43.146:20880/com.liumengxi.hellodemo.service.HelloDemo?anyhost=true&application=hellodemo&category=configurators&check=false&dubbo=2.6.2&environment=product&generic=false&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&iothreads=20&methods=mxSayHello&pid=16468&queues=512&retries=-1&revision=1.0&side=provider&threads=300×tamp=1568690376721&version=1.0, dubbo version: 2.6.2, current host: 192.168.43.146
2019-09-17 11:19:39.431  INFO 16468 --- [           main] c.l.hellodemo.HelloDemoApplication       : Started HelloDemoApplication in 9.229 seconds (JVM running for 24.755)
2019-09-17 11:19:39.439  INFO 16468 --- [pool-3-thread-1] .d.c.e.AwaitingNonWebApplicationListener :  [Dubbo] Current Spring Boot Application is await...

上述日志中,我们可以看到
Register dubbo service com.liumengxi.hellodemo.service.HelloDemo url dubbo://192.168.43.146:20880/com.liumengxi.hellodemo.service.HelloDemo
就是往nacos里注册服务,包括服务的元数据、ip地址等信息。如下图:

docker安装nacos指南

docker安装nacos指南

接下来,我们看下如何注册消费者服务,其实它和生产者服务注册方式基本一致。

  • maven依赖
 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba.boot</groupId>
            <artifactId>dubbo-spring-boot-starter</artifactId>
            <version>0.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.liumengxi</groupId>
            <artifactId>hello-demo</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

上述引用hello-demo依赖包,是为了在消费者模块找到该接口信息,引用之前使用 mvn clean install -Dmaven.test.skip=true或 mvn clean deploy -Dmaven.test.skip=true 将需要暴露的模块打好本地包或者远程包。

  • springboot配置文件
dubbo.scan.basePackages=com.liumengxi.hellodemo.consumer
dubbo.application.id=hellodemoconsumer
dubbo.application.name=hellodemoconsumer
dubbo.application.environment=product
dubbo.registry.address=nacos://127.0.0.1:8848
dubbo.registry.session=20000
dubbo.registry.check=false
dubbo.consumer.check=false
dubbo.protocol.threads=300
dubbo.protocol.iothreads=20
dubbo.protocol.queues=512
dubbo.service.core.version=1.0
dubbo.service.core.group=dev
  • 引用生产者服务

package com.liumengxi.hellodemo.consumer.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.liumengxi.hellodemo.service.HelloDemo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description 控制层
 * @date 2019-09-17 17:35
 * @Copyright 2019 Alibaba.com All right reserved.
 */
@Controller
public class HelloDemoController {
    /**
     * 算子服务
     */
    @Reference(version = "${dubbo.service.core.version}", group = "${dubbo.service.core.group}", timeout = 100000)
    private HelloDemo helloDemo;

    @GetMapping(value = "/hello")
    @ResponseBody
    public String hello(@RequestParam(value = "hello") String hello) {
        String result = helloDemo.mxSayHello(hello);
        return result;
    }
}

  • 启动生产者服务
:: Dubbo Spring Boot (v0.2.0) : https://github.com/apache/incubator-dubbo-spring-boot-project
 :: Dubbo (v2.6.2) : https://github.com/apache/incubator-dubbo
 :: Google group : dev@dubbo.incubator.apache.org

2019-09-17 18:02:02.002  INFO 17309 --- [           main] e.OverrideDubboConfigApplicationListener : Dubbo Config was overridden by externalized configuration {dubbo.application.environment=product, dubbo.application.id=hellodemoconsumer, dubbo.application.name=hellodemoconsumer, dubbo.consumer.check=false, dubbo.protocol.iothreads=20, dubbo.protocol.queues=512, dubbo.protocol.threads=300, dubbo.registry.address=nacos://127.0.0.1:8848, dubbo.registry.check=false, dubbo.registry.session=20000, dubbo.scan.basePackages=com.liumengxi.hellodemo.consumer, dubbo.service.core.group=dev, dubbo.service.core.version=1.0}

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.8.RELEASE)

2019-09-17 18:02:12.495  INFO 17309 --- [           main] c.l.h.c.HelloDemoConsumerApplication     : No active profile set, falling back to default profiles: default
2019-09-17 18:02:13.939  INFO 17309 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : hellodemoconsumer, class : com.alibaba.dubbo.config.ApplicationConfig] has been registered.
2019-09-17 18:02:13.941  INFO 17309 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : hellodemoconsumer] has been registered.
2019-09-17 18:02:13.941  INFO 17309 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : com.alibaba.dubbo.config.RegistryConfig#0, class : com.alibaba.dubbo.config.RegistryConfig] has been registered.
2019-09-17 18:02:13.941  INFO 17309 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : com.alibaba.dubbo.config.RegistryConfig#0] has been registered.
2019-09-17 18:02:13.942  INFO 17309 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : com.alibaba.dubbo.config.ProtocolConfig#0, class : com.alibaba.dubbo.config.ProtocolConfig] has been registered.
2019-09-17 18:02:13.942  INFO 17309 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : com.alibaba.dubbo.config.ProtocolConfig#0] has been registered.
2019-09-17 18:02:13.942  INFO 17309 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : com.alibaba.dubbo.config.ConsumerConfig#0, class : com.alibaba.dubbo.config.ConsumerConfig] has been registered.
2019-09-17 18:02:13.943  INFO 17309 --- [           main] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : com.alibaba.dubbo.config.ConsumerConfig#0] has been registered.
2019-09-17 18:02:19.118  INFO 17309 --- [           main] b.f.a.ServiceAnnotationBeanPostProcessor :  [DUBBO] BeanNameGenerator bean can't be found in BeanFactory with name [org.springframework.context.annotation.internalConfigurationBeanNameGenerator], dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:02:19.119  INFO 17309 --- [           main] b.f.a.ServiceAnnotationBeanPostProcessor :  [DUBBO] BeanNameGenerator will be a instance of org.springframework.context.annotation.AnnotationBeanNameGenerator , it maybe a potential problem on bean name generation., dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:02:19.127  WARN 17309 --- [           main] b.f.a.ServiceAnnotationBeanPostProcessor :  [DUBBO] No Spring Bean annotating Dubbo's @Service was found under package[com.liumengxi.hellodemo.consumer], dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:02:19.129  INFO 17309 --- [           main] o.s.c.a.ConfigurationClassPostProcessor  : Cannot enhance @Configuration bean definition 'com.alibaba.boot.dubbo.autoconfigure.DubboAutoConfiguration' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2019-09-17 18:02:19.942  INFO 17309 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'relaxedDubboConfigBinder' of type [com.alibaba.boot.dubbo.autoconfigure.RelaxedDubboConfigBinder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-17 18:02:19.950  INFO 17309 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'relaxedDubboConfigBinder' of type [com.alibaba.boot.dubbo.autoconfigure.RelaxedDubboConfigBinder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-17 18:02:19.952  INFO 17309 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'relaxedDubboConfigBinder' of type [com.alibaba.boot.dubbo.autoconfigure.RelaxedDubboConfigBinder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-17 18:02:19.954  INFO 17309 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'relaxedDubboConfigBinder' of type [com.alibaba.boot.dubbo.autoconfigure.RelaxedDubboConfigBinder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-17 18:02:21.445  INFO 17309 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-09-17 18:02:21.555  INFO 17309 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-09-17 18:02:21.555  INFO 17309 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.24]
2019-09-17 18:02:22.034  INFO 17309 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-09-17 18:02:22.035  INFO 17309 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 9447 ms
2019-09-17 18:02:23.825  INFO 17309 --- [           main] .f.a.DubboConfigBindingBeanPostProcessor : The properties of bean [name : com.alibaba.dubbo.config.ConsumerConfig#0] have been binding by prefix of configuration properties : dubbo.consumer
2019-09-17 18:02:23.842  INFO 17309 --- [           main] .f.a.DubboConfigBindingBeanPostProcessor : The properties of bean [name : hellodemoconsumer] have been binding by prefix of configuration properties : dubbo.application
2019-09-17 18:02:23.857  INFO 17309 --- [           main] .f.a.DubboConfigBindingBeanPostProcessor : The properties of bean [name : com.alibaba.dubbo.config.RegistryConfig#0] have been binding by prefix of configuration properties : dubbo.registry
Tue Sep 17 18:02:28 CST 2019 sun.misc.Launcher$AppClassLoader@18b4aac2 JM.Log:INFO Init JM logger with Slf4jLoggerFactory success, sun.misc.Launcher$AppClassLoader@18b4aac2
Tue Sep 17 18:02:28 CST 2019 sun.misc.Launcher$AppClassLoader@18b4aac2 JM.Log:INFO Log root path: /Users/yaozhihao/logs/
Tue Sep 17 18:02:28 CST 2019 sun.misc.Launcher$AppClassLoader@18b4aac2 JM.Log:INFO Set nacos log path: /Users/yaozhihao/logs/nacos
2019-09-17 18:02:29.028  INFO 17309 --- [           main] c.a.dubbo.registry.nacos.NacosRegistry   :  [DUBBO] Load registry store file /Users/yaozhihao/.dubbo/dubbo-registry-hellodemoconsumer-127.0.0.1:8848.cache, data: {dev/com.liumengxi.hellodemo.service.HelloDemo:1.0=dubbo://192.168.43.146:20880?anyhost=true&application=hellodemo&category=providers&dubbo=2.6.2&environment=product&generic=false&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&iothreads=20&methods=mxSayHello&pid=16468&protocol=dubbo&queues=512&retries=-1&revision=1.0&side=provider&threads=300×tamp=1568690376721&version=1.0}, dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:02:29.066  INFO 17309 --- [           main] c.a.dubbo.registry.nacos.NacosRegistry   :  [DUBBO] Register: consumer://192.168.125.116/com.liumengxi.hellodemo.service.HelloDemo?application=hellodemoconsumer&category=consumers&check=false&default.check=false&dubbo=2.6.2&environment=product&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&methods=mxSayHello&pid=17309&revision=1.0&side=consumer&timeout=100000×tamp=1568714543861&version=1.0, dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:02:29.559  INFO 17309 --- [           main] c.a.dubbo.registry.nacos.NacosRegistry   :  [DUBBO] Subscribe: consumer://192.168.125.116/com.liumengxi.hellodemo.service.HelloDemo?application=hellodemoconsumer&category=providers,configurators,routers&default.check=false&dubbo=2.6.2&environment=product&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&methods=mxSayHello&pid=17309&revision=1.0&side=consumer&timeout=100000×tamp=1568714543861&version=1.0, dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:02:34.607  WARN 17309 --- [           main] c.a.dubbo.registry.nacos.NacosRegistry   :  [DUBBO] Ignore empty notify urls for subscribe url consumer://192.168.125.116/com.liumengxi.hellodemo.service.HelloDemo?application=hellodemoconsumer&category=providers,configurators,routers&default.check=false&dubbo=2.6.2&environment=product&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&methods=mxSayHello&pid=17309&revision=1.0&side=consumer&timeout=100000×tamp=1568714543861&version=1.0, dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:02:34.611  WARN 17309 --- [client.listener] c.a.dubbo.registry.nacos.NacosRegistry   :  [DUBBO] Ignore empty notify urls for subscribe url consumer://192.168.125.116/com.liumengxi.hellodemo.service.HelloDemo?application=hellodemoconsumer&category=providers,configurators,routers&default.check=false&dubbo=2.6.2&environment=product&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&methods=mxSayHello&pid=17309&revision=1.0&side=consumer&timeout=100000×tamp=1568714543861&version=1.0, dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:02:34.617  INFO 17309 --- [           main] com.alibaba.dubbo.config.AbstractConfig  :  [DUBBO] Refer dubbo service com.liumengxi.hellodemo.service.HelloDemo from url nacos://127.0.0.1:8848/com.alibaba.dubbo.registry.RegistryService?application=hellodemoconsumer&default.check=false&dubbo=2.6.2&environment=product&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&methods=mxSayHello&pid=17309®ister.ip=192.168.125.116&revision=1.0&side=consumer&timeout=100000×tamp=1568714543861&version=1.0, dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:02:34.655  INFO 17309 --- [           main] c.a.d.c.s.b.f.a.ReferenceBeanBuilder     : <dubbo:reference object="com.alibaba.dubbo.common.bytecode.proxy0@4705ef23" singleton="true" interface="com.liumengxi.hellodemo.service.HelloDemo" uniqueServiceName="dev/com.liumengxi.hellodemo.service.HelloDemo:1.0" generic="false" version="1.0" group="dev" timeout="100000" id="com.liumengxi.hellodemo.service.HelloDemo" /> has been built.
2019-09-17 18:02:35.642  INFO 17309 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-09-17 18:02:36.172  INFO 17309 --- [           main] .f.a.DubboConfigBindingBeanPostProcessor : The properties of bean [name : com.alibaba.dubbo.config.ProtocolConfig#0] have been binding by prefix of configuration properties : dubbo.protocol
2019-09-17 18:02:36.578  INFO 17309 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-09-17 18:02:36.589  INFO 17309 --- [           main] c.l.h.c.HelloDemoConsumerApplication     : Started HelloDemoConsumerApplication in 40.522 seconds (JVM running for 55.153)
2019-09-17 18:04:05.737  INFO 17309 --- [client.listener] c.a.dubbo.registry.nacos.NacosRegistry   :  [DUBBO] Notify urls for subscribe url consumer://192.168.125.116/com.liumengxi.hellodemo.service.HelloDemo?application=hellodemoconsumer&category=providers,configurators,routers&default.check=false&dubbo=2.6.2&environment=product&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&methods=mxSayHello&pid=17309&revision=1.0&side=consumer&timeout=100000×tamp=1568714543861&version=1.0, urls: [dubbo://192.168.125.116:20880?anyhost=true&application=hellodemo&category=providers&dubbo=2.6.2&environment=product&generic=false&group=dev&interface=com.liumengxi.hellodemo.service.HelloDemo&iothreads=20&methods=mxSayHello&pid=17333&protocol=dubbo&queues=512&retries=-1&revision=1.0&side=provider&threads=300×tamp=1568714638583&version=1.0], dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:04:06.253  INFO 17309 --- [client.listener] c.a.d.remoting.transport.AbstractClient  :  [DUBBO] Successed connect to server /192.168.125.116:20880 from NettyClient 192.168.125.116 using dubbo version 2.6.2, channel is NettyChannel [channel=[id: 0x2834155a, /192.168.125.116:63690 => /192.168.125.116:20880]], dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:04:06.253  INFO 17309 --- [client.listener] c.a.d.remoting.transport.AbstractClient  :  [DUBBO] Start NettyClient yaozhihaodeMacBook-Air.local/192.168.125.116 connect to the server /192.168.125.116:20880, dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:04:29.755  INFO 17309 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-09-17 18:04:29.755  INFO 17309 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-09-17 18:04:29.801  INFO 17309 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 45 ms
2019-09-17 18:06:06 JRebel: Reloading class 'com.liumengxi.hellodemo.consumer.controller.HelloDemoController'.
2019-09-17 18:06:11.457  INFO 17309 --- [nio-8080-exec-5] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : hellodemoconsumer, class : com.alibaba.dubbo.config.ApplicationConfig] has been registered.
2019-09-17 18:06:11.458  INFO 17309 --- [nio-8080-exec-5] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : hellodemoconsumer] has been registered.
2019-09-17 18:06:11.460  INFO 17309 --- [nio-8080-exec-5] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : com.alibaba.dubbo.config.RegistryConfig#1, class : com.alibaba.dubbo.config.RegistryConfig] has been registered.
2019-09-17 18:06:11.461  INFO 17309 --- [nio-8080-exec-5] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : com.alibaba.dubbo.config.RegistryConfig#1] has been registered.
2019-09-17 18:06:11.462  INFO 17309 --- [nio-8080-exec-5] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : com.alibaba.dubbo.config.ProtocolConfig#1, class : com.alibaba.dubbo.config.ProtocolConfig] has been registered.
2019-09-17 18:06:11.462  INFO 17309 --- [nio-8080-exec-5] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : com.alibaba.dubbo.config.ProtocolConfig#1] has been registered.
2019-09-17 18:06:11.465  INFO 17309 --- [nio-8080-exec-5] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The dubbo config bean definition [name : com.alibaba.dubbo.config.ConsumerConfig#1, class : com.alibaba.dubbo.config.ConsumerConfig] has been registered.
2019-09-17 18:06:11.476  INFO 17309 --- [nio-8080-exec-5] .a.d.c.s.c.a.DubboConfigBindingRegistrar : The BeanPostProcessor bean definition [com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor] for dubbo config bean [name : com.alibaba.dubbo.config.ConsumerConfig#1] has been registered.
2019-09-17 18:06:12 JRebel: Adding bean 'com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor#4'
2019-09-17 18:06:12 JRebel: Adding bean 'com.alibaba.dubbo.config.RegistryConfig#1'
2019-09-17 18:06:12 JRebel: Adding bean 'com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor#5'
2019-09-17 18:06:12 JRebel: Adding bean 'com.alibaba.dubbo.config.ProtocolConfig#1'
2019-09-17 18:06:12 JRebel: Adding bean 'com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor#6'
2019-09-17 18:06:12 JRebel: Adding bean 'com.alibaba.dubbo.config.ConsumerConfig#1'
2019-09-17 18:06:12 JRebel: Adding bean 'com.alibaba.dubbo.config.spring.beans.factory.annotation.DubboConfigBindingBeanPostProcessor#7'
2019-09-17 18:06:12 JRebel: Reconfiguring bean 'helloDemoController' [com.liumengxi.hellodemo.consumer.controller.HelloDemoController]
2019-09-17 18:33:42.394  INFO 17309 --- [:20880-thread-2] c.a.d.rpc.protocol.dubbo.DubboProtocol   :  [DUBBO] disconnected from /192.168.125.116:20880,url:dubbo://192.168.125.116:20880/com.liumengxi.hellodemo.service.HelloDemo?anyhost=true&application=hellodemoconsumer&category=providers&check=false&codec=dubbo&default.check=false&dubbo=2.6.2&environment=product&generic=false&group=dev&heartbeat=60000&interface=com.liumengxi.hellodemo.service.HelloDemo&iothreads=20&methods=mxSayHello&pid=17309&protocol=dubbo®ister.ip=192.168.125.116&remote.timestamp=1568714638583&retries=-1&revision=1.0&side=consumer&timeout=100000×tamp=1568714543861&version=1.0, dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:33:44.051  INFO 17309 --- [tTimer-thread-1] c.a.d.r.transport.netty.NettyClient      :  [DUBBO] Close old netty channel [id: 0x2834155a, /192.168.125.116:63690 :> /192.168.125.116:20880] on create new netty channel [id: 0x77b6b83a, /192.168.125.116:64675 => /192.168.125.116:20880], dubbo version: 2.6.2, current host: 192.168.125.116
2019-09-17 18:33:44.052  INFO 17309 --- [tTimer-thread-1] c.a.d.remoting.transport.AbstractClient  :  [DUBBO] Successed connect to server /192.168.125.116:20880 from NettyClient 192.168.125.116 using dubbo version 2.6.2, channel is NettyChannel [channel=[id: 0x77b6b83a, /192.168.125.116:64675 => /192.168.125.116:20880]], dubbo version: 2.6.2, current host: 192.168.125.116

  • 查看nacos消费者服务

docker安装nacos指南

docker安装nacos指南

  • 页面验证

我们可以通过页面访问,验证服务是否注册。

docker安装nacos指南

如上图,服务可以正常访问到。到这里,dubbo集成nacos服务就成功了。

更多免费软件分享与学习资料请查看=======>互联网架构学习资料分享

📚文章说明:
1、本文章链接失效后,请通过右下角企鹅QQ告知管理员,24小时内补链接,谢谢。点击下载说明了解。
2、天天精品分享的资源均通过网络公开合法渠道获取的,仅阅读交流测试使用,请在下载后24小时内删除。
3、版权归作者或出版社方所有,本站不对涉及的版权问题负法律责任。点击免责申明了解详情。
4、若版权方认为天天精品侵权,请联系客服QQ或发送邮件myttjp@163.com处理。
5、会员和精品豆系对搜集搬运、整理及网站运营做的友情赞助,非购买文件费用,敬请谅解。点击关于本站了解本站。
6、每位访客应尊重版权方的知识产权,支持版权方和出版社。