Giter Site home page Giter Site logo

node-consul's Introduction

简介

nodejs 在 consul 完成服务注册和发现,并且使用 fabio 完成负载均衡和反向代理。

fabio 会从 consul 注册表中获取健康的服务,根据服务注册时的 tag 配置自动创建自己的路由,当接收到请求后自动去做负载均衡,支持的负载均衡模式为 权重模式

consul

一个提供服务发现,健康检测,K/V 存储,支持分布式高可用多数据中心

faibo

简单配置能够让 consul 部署的应用快速支持 http 的负载均衡路由

环境配置

consul 部署

$ docker run -d \
-p 8500:8500 \
--name consul \
-v $PWD/consul:/consul/data \
-e CONSUL_BIND_INTERFACE='eth0' \
consul:latest agent -server -ui -bind=0.0.0.0 -client=0.0.0.0 -bootstrap-expect=1

open url :http://localhost:8500/ui/dc1/services

fabio

创建配置文件 ./fabio/fabio.properties

registry.consul.addr = 10.10.0.12:8500
registry.consul.register.addr = 10.10.0.12:9998
metrics.target = stdout
$ docker run -d --name fabio -p 9999:9999 -p 9998:9998 -v $PWD/fabio/fabio.properties:/etc/fabio/fabio.properties fabiolb/fabio

open url: localhost:9998

服务关联

请修改仓库中的 config 配置信息的服务 ip 地址

$ yarn

$ yarn start

测试

安装 vsCode REST Client 插件,修改test.http中的 ip 地址,就可以直接点击测试路由功能

node-consul's People

Contributors

ddzyan avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

lypvc

node-consul's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.