.Net Core 3.1简单搭建微服务

摘要:
最近,我们发现微服务确实是大势所趋。停留在公司使用的框架中严重无法满足未来项目的需求,因此我们花时间学习微服务并实现代码。虽然这个项目很简单,但我们在这个过程中确实学到了很多东西。我的服务器是用虚拟机构建的,环境是CentOS7。OrderController代码如下:使用Microsoft.AspNetCore.Mvc;使用Microsoft.Extension.Configuration;使用Microsoft.Extensions.Logging;使用系统;使用System.Collections.Generic;使用System.Linq;使用System.Threading.Tasks;namespaceOrder.API.Controllers{[ApiController,Route]publicclassOrderController:ControllerBase{privatereadonlyILogger<OrderController>_logger;privatereadOnly IConfiguration_configuration_configuration;publicOrderController{_logger=logger;_configuration=configuration;}[HttpGet]publicIActionResultGet(){stringresult=$“{DateTime.Now.ToString}--”+$“{Request.HttpContext.Connection.LocalIpAddress}:{_configuraturation[”ConsulSetting:ServicePort“]}”;returnOk;}}HealthCheckController控制器代码如下:使用Microsoft.AspNetCore.Mvc;使用系统;使用System.Collections.Generic;使用System.Linq;使用System.Threading.Tasks;命名空间顺序。应用程序编程接口。控制器{〔Route〕〔ApiController〕publicclassHealthCheckController:ControllerBase{//<summary>///健康检查接口///<summary˃///<return>˂/return>〔HttpGet〕publicIActionResultGet(){returnOK();}}}}创建ConsulHelper帮助类,用于向Consul注册服务。注意,首先在Nuget中添加Consul类库。

学如逆水行舟,不进则退!最近发现微服务真的是大势所趋,停留在公司所用框架里已经严重满足不了未来的项目需要了,所以抽空了解了一下微服务,并进行了代码落地。

虽然项目简单,但过程中确实也学到了不少东西。

写在前面:先看下项目总体目录以及拓扑图,其中包括2个服务(几乎一样),一个网关,一个mvc项目。我的服务器是用虚拟机搭建的,环境是CentOS 7。本片文章看似繁杂冗长,其实只是记录的步骤比较详细,实操完成你会发现并不难理解,只是微服务的简单入门而已。还请大神多多指教!

.Net Core 3.1简单搭建微服务第1张.Net Core 3.1简单搭建微服务第2张

一、准备Consul注册中心

在Docker中安装一个Consul

 1. 拉取镜像

docker pull consul

2. 启动Server

启动前, 先建立 /consul/data文件夹, 保存 consul 的数据

mkdir -p /data/consul

.Net Core 3.1简单搭建微服务第3张

3. 使用 docker run 启动 server

docker run -d -p 8500:8500 -v /consul/data:/consul/data -e --name=consul1 consul agent -server -bootstrap -ui -client='0.0.0.0'
  • agent: 表示启动 agent 进程
  • server: 表示 consul 为 server 模式
  • client: 表示 consul 为 client 模式
  • bootstrap: 表示这个节点是 Server-Leader
  • ui: 启动 Web UI, 默认端口 8500
  • node: 指定节点名称, 集群中节点名称唯一
  • client: 绑定客户端接口地址, 0.0.0.0 表示所有地址都可以访问
4. 启动后,就可以访问您的服务器Ip+8500端口看到Consul控制台了,如图:
 
.Net Core 3.1简单搭建微服务第4张

二、准备服务

1. 创建订单服务项目

.Net Core 3.1简单搭建微服务第5张

 2. 创建OrderController和HealthCheckController,用于显示订单信息和进行健康检查。

      (1)OrderController代码如下:

using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Order.API.Controllers
{
    [ApiController,Route("[controller]")]
    public class OrderController:ControllerBase
    {
        private readonly ILogger<OrderController> _logger;
        private readonly IConfiguration _configuration;

        public OrderController(ILogger<OrderController> logger, IConfiguration configuration)
        {
            _logger = logger;
            _configuration = configuration;
        }

        [HttpGet]
        public IActionResult Get()
        {
            string result = $"【订单服务】{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}——" +
                $"{Request.HttpContext.Connection.LocalIpAddress}:{_configuration["ConsulSetting:ServicePort"]}";
            return Ok(result);
        }
    }
}

  (2)HealthCheckController控制器代码如下:

using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Order.API.Controllers
{
    [Route("[controller]")]
    [ApiController]
    public class HealthCheckController : ControllerBase
    {
        /// <summary>
        /// 健康检查接口
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult Get()
        {
            return Ok();
        }
    }
}

  (3)创建ConsulHelper帮助类,用来向Consul(服务注册中心)进行服务注册。注意,先在Nuget中添加Consul类库。

.Net Core 3.1简单搭建微服务第6张

using Consul;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Order.API.Helper
{
    public static class ConsulHelper
    {
        /// <summary>
        /// 服务注册到consul
        /// </summary>
        /// <param name="app"></param>
        /// <param name="lifetime"></param>
        public static IApplicationBuilder RegisterConsul(this IApplicationBuilder app, IConfiguration configuration, IHostApplicationLifetime lifetime)
        {
            var consulClient = new ConsulClient(c =>
            {
                //consul地址
                c.Address = new Uri(configuration["ConsulSetting:ConsulAddress"]);
            });

            var registration = new AgentServiceRegistration()
            {
                ID = Guid.NewGuid().ToString(),//服务实例唯一标识
                Name = configuration["ConsulSetting:ServiceName"],//服务名称
                Address = configuration["ConsulSetting:ServiceIP"], //服务所在宿主机IP
                Port = int.Parse(configuration["ConsulSetting:ServicePort"] ?? "5000"),//服务端口 因为要运行多个实例,所以要在在docker容器启动时时动态传入 --ConsulSetting:ServicePort="port"
                Check = new AgentServiceCheck()
                {
                    DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(5),//服务启动多久后注册
                    Interval = TimeSpan.FromSeconds(10),//健康检查时间间隔
                    HTTP = $"http://{configuration["ConsulSetting:ServiceIP"]}:{configuration["ConsulSetting:ServicePort"]}{configuration["ConsulSetting:ServiceHealthCheck"]}",//健康检查地址
                    Timeout = TimeSpan.FromSeconds(5)//超时时间
                }
            };

            //服务注册
            consulClient.Agent.ServiceRegister(registration).Wait();

            //应用程序终止时,取消注册
            lifetime.ApplicationStopping.Register(() =>
            {
                consulClient.Agent.ServiceDeregister(registration.ID).Wait();
            });

            return app;
        }
    }
}

  (4)appsetting.json配置文件代码

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "ConsulSetting": {
    "ServiceName": "order", //服务名称
    "ServiceIP": "192.168.183.129", //服务所在宿主机的IP地址
    "ServiceHealthCheck": "/healthcheck",//健康检查地址
    "ConsulAddress": "http://192.168.183.129:8500/" //Consul注册中心所在宿主机的IP地址和端口
  }
}

  (5)Program类代码如下

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Order.API
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseUrls("http://0.0.0.0:5000");//用来在服务器中监听外部请求的,0.0.0.0代表任何地址都可访问该服务,5000端口
                    webBuilder.UseStartup<Startup>();
                });
    }
}

启动项目测试,结果如下

.Net Core 3.1简单搭建微服务第7张

 2. 创建产品服务,内容跟Order服务一样,这里就不赘述了。注意为了区分两个服务,把ProductController中的输出信息做一下改变,如:把【订单服务】修改为【产品服务】

  (1)ProductController控制器代码

using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Product.API.Controllers
{
    [ApiController,Route("[controller]")]
    public class ProductController:ControllerBase
    {
        private readonly ILogger<ProductController> _logger;
        private readonly IConfiguration _configuration;

        public ProductController(ILogger<ProductController> logger, IConfiguration configuration)
        {
            _logger = logger;
            _configuration = configuration;
        }

        [HttpGet]
        public IActionResult Get()
        {
            string result = $"【产品服务】{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}——" +
                $"{Request.HttpContext.Connection.LocalIpAddress}:{_configuration["ConsulSetting:ServicePort"]}";
            return Ok(result);
        }
    }
}

  (2)appsetting.json代码

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "ConsulSetting": {
    "ServiceName": "product",//注意这里的服务名称跟Order不一样
    "ServiceIP": "192.168.183.129",
    "ServiceHealthCheck": "/healthcheck",
    "ConsulAddress": "http://192.168.183.129:8500/" 
  }
}

  (3)运行测试,输出内容跟Order服务大体一致。

二、部署到Docker容器(以Order服务为例)

  1. 创建DockerFile文件,文件代码如下

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 5000
COPY . .
ENTRYPOINT ["dotnet", "Order.API.dll"]

  2. 发布项目

.Net Core 3.1简单搭建微服务第8张

 3. 发布完成之后将发布以后的文件目录放到服务器上,并将DockerFile文件放入根目录,如图

.Net Core 3.1简单搭建微服务第9张

 4. 构建Order服务的镜像

在Order服务的根目录下,执行docker命令,

docker build -t orderapi .

构建完成后,启动一个docker容器同时启动我们已经拷贝过来的Order服务,启动命令如下(以下启动了三个容器,分别为9050、9051、9052端口,都映射到了容器的5000端口)

docker run -d -p 9050:5000 --name order1 orderapi --ConsulSetting:ServicePort="9050"
docker run -d -p 9051:5000 --name order2 orderapi --ConsulSetting:ServicePort="9051"
docker run -d -p 9052:5000 --name order3 orderapi --ConsulSetting:ServicePort="9052"

以上,9050:5000,表示将服务器的9050端口映射到容器的5000端口,--ConsulSetting:ServicePort="9050" 表示向服务动态传入端口,服务通过此端口来向Consul注册端口信息

5. 观察Consul控制台,如果5秒后,控制台出现了新的服务,并从红色变味了绿色,那么恭喜您,您的第一个服务就向注册中心注册成功了!

    点击Order服务,您会发现有3个服务实例,这就是您刚刚用容器启动的三个服务实例了。

                                                                                       

同理,再次部署Product服务,注意,Product的服务端口要改为别的端口,比如9060,不能跟Order重复了!

docker命令如下:

docker build -t productapi .
docker run -d -p 9060:5000 --name product1 productapi --ConsulSetting:ServicePort="9060"
docker run -d -p 9061:5000 --name product2 productapi --ConsulSetting:ServicePort="9061"
docker run -d -p 9062:5000 --name product3 productapi --ConsulSetting:ServicePort="9062"

6. 至此,我们所需要的2个服务,6个实例已经都部署好了,那么我们在请求接口时,就会有6个请求地址:

http://ip:9050/order

http://ip:9051/order

http://ip:9052/order

http://ip:9060/product

http://ip:9061/product

http://ip:9062/product

那么我们mvc项目在请求接口的时候不可能挨个请求啊,这也不太现实,这时候,我么则需要一个网关Ocelot。有了Ocelot,我们只需要请求网关地址就可以了,网关就会根据我们请求的地址,自动匹配下游的服务。

比如,网关地址为http://ip:5000,那么当我们请求http://ip:5000/oder的时候,网关就会匹配路由,自动请求http://ip:9050/order、http://ip:9051/order、http://ip:9052/order的任意一个地址。

当然,这几个地址是通过Ocelot与Consul的集成实现的,Ocelot会自动获取Consul中已经存在的服务的地址,供路由进行自动匹配。

下面,我们来搭建网关。

三、搭建网关

1. 新建空的Web项目,如图:

.Net Core 3.1简单搭建微服务第10张

 2. 添加Ocelot和Consul的类库,如图

.Net Core 3.1简单搭建微服务第11张

 3. 添加代码

  (1)startup类的代码

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Consul;
using Ocelot.Provider.Polly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Ocelot.APIGateway
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOcelot()
                    .AddConsul()//集成Consul服务发现
                    .AddPolly();//添加超时/熔断服务

        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseOcelot().Wait();
        }
    }
}

  (2)添加ocelot.json配置文件,代码如下

{
  "ReRoutes": [
    {
      "DownstreamPathTemplate": "/order",
      "DownstreamScheme": "http",
      "UpstreamPathTemplate": "/order",
      "UpstreamHttpMethod": [ "GET", "POST" ],
      "ServiceName": "order", //Consul服务名称
      "RateLimitOptions": { //限流
        "ClientWhitelist": [ "SuperClient" ], //白名单,不受限
        "EnableRateLimiting": true,
        "Period": "5s", //1s,5m,1h,1d等
        "PeriodTimespan": 2,
        "Limit": 1
      },
      "QoSOptions": { //超时/熔断配置
        "ExceptionsAllowedBeforeBreaking": 3, //代表发生错误的次数
        "DurationOfBreak": 10000, //代表熔断时间
        "TimeoutValue": 5000 //代表超时时间
      }
    },
    {
      "DownstreamPathTemplate": "/product",
      "DownstreamScheme": "http",
      "UpstreamPathTemplate": "/product",
      "UpstreamHttpMethod": [ "GET", "POST" ],
      "ServiceName": "product", //Consul服务名称
      "RateLimitOptions": { //限流
        "ClientWhitelist": [ "SuperClient" ], //白名单,不受限
        "EnableRateLimiting": true,
        "Period": "5s", //1s,5m,1h,1d等
        "PeriodTimespan": 2,
        "Limit": 1 //最重要的就是Period,PeriodTimespan,Limit这几个配置。
      },
      "QoSOptions": { //超时/熔断配置
        "ExceptionsAllowedBeforeBreaking": 3, //代表发生错误的次数
        "DurationOfBreak": 10000, //代表熔断时间
        "TimeoutValue": 5000 //代表超时时间
      }
    }
  ],
  "GlobalConfiguration": {
    "BaseUrl": "http://192.168.183.129:5000", //用来访问服务的地址
    "ServiceDiscoveryProvider": {//Consul服务发现,用来获取Consul的服务地址的
      "Scheme": "http",
      "Host": "192.168.183.129",//Consul的IP地址
      "Port": 8500,//端口
      "Type": "Consul"
    },
    "RateLimitOptions": { //限流
      "DisableRateLimitHeaders": false, //代表是否禁用X-Rate-Limit和Retry-After标头(请求达到上限时response header中的限制数和多少秒后能重试)
      "QuotaExceededMessage": "too many requests...", //代表请求达到上限时返回给客户端的消息
      "HttpStatusCode": 999, //代表请求达到上限时返回给客户端的HTTP状态代码
      "ClientIdHeader": "Test" //可以允许自定义用于标识客户端的标头。默认情况下为“ ClientId”
    }
  }
}

  (3)Startup.cs类代码

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Consul;
using Ocelot.Provider.Polly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Ocelot.APIGateway
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddOcelot()
                    .AddConsul()//集成Consul服务发现
                    .AddPolly();//添加超时/熔断服务

        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseOcelot().Wait();
        }
    }
}

  (4)Program.cs类代码如下

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Ocelot.APIGateway
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureAppConfiguration((hostingContext, config) => {
                    config.AddJsonFile("ocelot.json");
                })  
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
}

  (5)启动网关项目,进行测试,结果如下

.Net Core 3.1简单搭建微服务第12张

 .Net Core 3.1简单搭建微服务第13张

 至此,网关搭建完成,之后,我们的MVC项目只需要访问网关的地址进行接口调用就可以了。

四、新建MVC项目,进行调用模拟

1. 新建空MVC项目并添加代码,如图

.Net Core 3.1简单搭建微服务第14张

 2. 添加代码

  (1)HomeController代码

using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Web.MVC.Helper;

namespace Web.MVC.Controllers
{
    public class HomeController:Controller
    {
        private readonly ILogger<HomeController> _logger;
        private readonly IServiceHelper _serviceHelper;

        public HomeController(ILogger<HomeController> logger, IServiceHelper serviceHelper)
        {
            _logger = logger;
            _serviceHelper = serviceHelper;
        }

        public async Task<IActionResult> Index()
        {
            ViewBag.OrderData = await _serviceHelper.GetOrder();
            ViewBag.ProductData = await _serviceHelper.GetProduct();
            return View();
        }
    }
}

  (2)IServiceHelper、ServiceHelper代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Web.MVC.Helper
{
    public interface IServiceHelper
    {
        /// <summary>
        /// 获取产品数据
        /// </summary>
        /// <returns></returns>
        Task<string> GetProduct();

        /// <summary>
        /// 获取订单数据
        /// </summary>
        /// <returns></returns>
        Task<string> GetOrder();
    }
}
using Consul;
using Microsoft.Extensions.Configuration;
using RestSharp;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Web.MVC.Helper
{
    public class ServiceHelper : IServiceHelper
    {
        public async Task<string> GetOrder()
        {
            var Client = new RestClient("http://ip:5000");//此处指的是网关项目的地址
            var request = new RestRequest("/order", Method.GET);
            var response = await Client.ExecuteAsync(request);
            return response.Content;
        }

        public async Task<string> GetProduct()
        {
            var Client = new RestClient("http://ip:5000");//此处指的是网关的地址
            var request = new RestRequest("/product", Method.GET);
            var response = await Client.ExecuteAsync(request);
            return response.Content;
        }
    }
}

  (3)Home/Index.cshtml的代码

@{
    ViewData["Title"] = "Home Page";
}

<div class="text-center">
    <h1 class="display-4">Welcome</h1>
    <p>
        @ViewBag.OrderData
    </p>
    <p>
        @ViewBag.ProductData
    </p>
</div>

  (4)Startup.cs中在ConfigureServices中,添加代码

services.AddSingleton<IServiceHelper, ServiceHelper>();

  (5)设置应用的访问地址

  .Net Core 3.1简单搭建微服务第15张

 3. 启动项目,查看结果

.Net Core 3.1简单搭建微服务第16张

 访问成功,至此,我们就把一个简单版的微服务搭建起来了!

看起来步骤繁琐,其实只是本人记录的比较详细而已,实操完成后并没有那么多东西!下图为本项目的基本架构:

.Net Core 3.1简单搭建微服务第17张

 好了,今天就到这里,下班!

参考链接:.Net Core微服务入门全纪录

免责声明:文章转载自《.Net Core 3.1简单搭建微服务》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇android 自定义控件属性获取bitmap和drawable的绘制安卓自定义控件下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

ServU使用方法及应用技巧

Serv-U使用方法及应用技巧(一) 2007年03月30日 星期五 17:08 1.1 Serv-U的安装  Serv-U的安装很简单,和其他windows程序一样,执行setup.exe,即可开始安装;全部选默认选项即可。安装完成后不需要重新启动,在“开始→程序→Serv-U FTP Server”中就能看到相关文件,桌面上也会产生快捷方式图标。  ...

nfs-rpcbind-portmap挂载nfs-network file system

NFS原理详解 PS:哈哈,这篇的篇幅真的非常的长。要看完真的要有很强的耐心那。我自己写也快写吐了呢。 [ATong学习linux]NFS原理详解 一、NFS介绍 1)什么是NFS 它的主要功能是通过网络让不同的机器系统之间可以彼此共享文件和目录。NFS服务器可以允许NFS客户端将远端NFS服务器端的共享目录挂载到本地的NFS客户端中。在本地的NFS客...

coredns 代理consul 运行noamd 部署的应用

nomad 是一个方便的应用调度平台,consul 一个很不错的服务发现工具,coredns 很不错, 扩展性比较强的dns 服务器,集成起来可能做很强大的事情 我的运行环境是mac,实际情况按需部署即可 组件下载 nomad 下载 https://www.nomadproject.io/docs/install/index.html consul 下载...

Consul集群搭建

  近几年随着Docker容器技术、微服务等架构的兴起,人们开始意识到服务发现的必要性。微服务架构简单来说,是一种以一些微服务来替代开发单个大而全应用的方法, 每一个小服务运行在自己的进程里,并以轻量级的机制来通信, 通常是 HTTP RESTful API。微服务强调小快灵, 任何一个相对独立的功能服务不再是一个模块, 而是一个独立的服务。那么,当我们需...

HPC7000刀片Flex-10_VC配置与vsphere网络设计

    本文主要描述了HP C7000刀片服务器系统中的Flex-10 VirtualConnect模块的配置 及VMware vSphere的网络,分析讲解了FlexNIC和vmnic的对应关系,以及如何设计一个高可用高冗余的VMware基础架构。 【C7000刀箱和VMware虚拟机架构的千兆网络设计】 图片来源:P4《HP Virtual Conn...

springcloud(一)-初识

springCloud简介   尽管springCloud带有“cloud”字样,但它并不是云计算解决方案,而是在SpringBoot基础上构建的,用于快速构建分布式系统的通用的工具集。从技术架构上降低了对大型系统构建的要求,使我们以非常低的成本(技术或者硬件)搭建一套高效、分布式、容错的平台,但Spring Cloud也不是没有缺点,小型独立的项目不适合...