Orleans 2.0 官方文档 —— 5.5.5 集群和客户端 -> 配置指南 -> 典型的配置

典型的配置

以下是可用于开发和生产部署的典型的配置示例。

本地开发

请参阅本地开发配置

使用Azure进行可靠的生产部署

对于使用Azure进行可靠的生产部署,您需要使用Azure表用于集群的成员身份管理。此配置是部署到内部部署服务器、容器或Azure虚拟机实例的典型配置。

DataConnection字符串的格式是 "DefaultEndpointsProtocol=https;AccountName=<Azure storage account>;AccountKey=<Azure table storage account key>"

silo的配置:

// TODO replace with your connection string
const string connectionString = "YOUR_CONNECTION_STRING_HERE";
var silo = new SiloHostBuilder()
    .Configure<ClusterOptions>(options =>
    {
        options.ClusterId = "Cluster42";
        options.ServiceId = "MyAwesomeService";
    })
    .UseAzureStorageClustering(options => options.ConnectionString = connectionString)
    .ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000)
    .ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole())
    .Build();

客户端配置:

// TODO replace with your connection string
const string connectionString = "YOUR_CONNECTION_STRING_HERE";
var client = new ClientBuilder()
    .Configure<ClusterOptions>(options =>
    {
        options.ClusterId = "Cluster42";
        options.ServiceId = "MyAwesomeService";
    })
    .UseAzureStorageClustering(options => options.ConnectionString = connectionString)
    .ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole())
    .Build();

使用SQL Server进行可靠的生产部署

对于使用SQL Server进行可靠的生产部署,需要提供SQL Server连接字符串。

silo的配置:

// TODO replace with your connection string
const string connectionString = "YOUR_CONNECTION_STRING_HERE";
var silo = new SiloHostBuilder()
    .Configure<ClusterOptions>(options =>
    {
        options.ClusterId = "Cluster42";
        options.ServiceId = "MyAwesomeService";
    })
    .UseAdoNetClustering(options =>
    { 
      options.ConnectionString = connectionString;
      options.Invariant = "System.Data.SqlClient";
    })
    .ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000)
    .ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole())
    .Build();

客户端配置:

// TODO replace with your connection string
const string connectionString = "YOUR_CONNECTION_STRING_HERE";
var client = new ClientBuilder()
    .Configure<ClusterOptions>(options =>
    {
        options.ClusterId = "Cluster42";
        options.ServiceId = "MyAwesomeService";
    })
    .UseAdoNetClustering(options =>
    { 
      options.ConnectionString = connectionString;
      options.Invariant = "System.Data.SqlClient";
    })
    .ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole())
    .Build();

专用服务器集群上的不可靠部署

当可靠性不是问题时,要在专用服务器集群上进行测试,您可以利用MembershipTableGrain,这避免了依赖于Azure Table。您只需将其中一个节点指定为主节点。

在silo上:

var primarySiloEndpoint = new IPEndpoint(PRIMARY_SILO_IP_ADDRESS, 11111);
var silo = new SiloHostBuilder()
  .UseDevelopmentClustering(primarySiloEndpoint)
  .Configure<ClusterOptions>(options =>
  {
    options.ClusterId = "Cluster42";
    options.ServiceId = "MyAwesomeService";
  })
  .ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000)
  .ConfigureLogging(logging => logging.AddConsole())
  .Build();

在客户端:

var gateways = new IPEndPoint[]
{
    new IPEndPoint(PRIMARY_SILO_IP_ADDRESS, 30000),
    new IPEndPoint(OTHER_SILO__IP_ADDRESS_1, 30000),
    [...]
    new IPEndPoint(OTHER_SILO__IP_ADDRESS_N, 30000),
};
var client = new ClientBuilder()
    .UseStaticClustering(gateways)
    .Configure<ClusterOptions>(options =>
    {
        options.ClusterId = "dev";
        options.ServiceId = "AdventureApp";
    })
    .ConfigureLogging(logging => logging.AddConsole())
    .Build();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值