TarsCloud / Tars

Tars is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule.
BSD 3-Clause "New" or "Revised" License
9.79k stars 2.08k forks source link

A question: I have a service A, online environment. I have deployment in multiple regions with different configurations. How can I do this? #741

Closed TARS-Question closed 4 years ago

TARS-Question commented 4 years ago

For example, Shenzhen and Shanghai have different DB configurations. How can I identify which configuration I use?

TARS-Answer commented 4 years ago

In your private template, specify the current - DENV = AreaA and - DENV = areab, which is OK. Because at startup, you can specify the configuration module for the current service.

Our approach is to configure independent configuration information in the private template, so that different configuration files can be loaded. (see note Figure)

CommunicatorFactory.getInstance ().getCommunicator().getCommunicatorConfig().getSetDivision()

If your configuration follows the environment, you can also partition your configuration information during setdivisioin. After obtaining the current setdivisioin, you can read your configuration. Through this API, you can get all the information of the current setdivisioin that has been configured on the platform. QQ图片20200722235624

TARS-Answer commented 4 years ago

在你的私有模板里面指定当前的-DENV=AREAA 和-DENV=AREAB,这样就可以了。因为在启动的时候,可以针对当前的服务指定配置模块的。 我们的做法是在私有模板这里配置独立的这一些配置的信息,这样加载就可以不同的配置文件了。(见备注图) CommunicatorFactory.getInstance().getCommunicator().getCommunicatorConfig().getSetDivision() 若是你的配置是跟着环境走,也可以在setDivisoin的时候,划分好你的配置信息,获取到当前的setDivisoin后,再去读取你的配置,这也是可以的。通过这个API就可以获取当前的已经配置在平台上面的setDivisoin的所有的信息了 QQ图片20200722235624

TARS-Question commented 4 years ago

This is to set the configuration of existing machine nodes in batch, and then when the capacity is expanded, will the configuration of this private template be automatically carried?

TARS-Question commented 4 years ago

这个是要批量设置已有机器节点的配置,然后扩容的时候,自动会把这个私有模板的配置携带上的吗?

TARS-Answer commented 4 years ago

When expanding, when the source IP node is specified, then copy is the private template of the IP node. (see note Figure) 2

TARS-Answer commented 4 years ago

扩容的时候,会指定源ip的节点的时候,那么copy的时候,就是这个ip节点的私有模板。(见备注图) 2

TARS-Question commented 4 years ago

Copy the configuration of the template here to the private template, right? And then change the different places here, OK?

#741(3)

Is it possible to build multiple templates (Shenzhen, Shanghai) without using private templates, and then select different templates for different nodes.

TARS-Question commented 4 years ago

是把这里模板的配置,全量拷贝到私有模板这里是吗?然后再这里修改下不同的地方,这样吗?

#741(3)

是不是也可以不用私有模板,我建多个模板(深圳,上海),然后不同的节点,选择不同的模板。

TARS-Answer commented 4 years ago

Yes, node configuration is also OK (see note Figure). However, we usually use private templates and get setdivisioin to handle it. In this way, we don't need to pay attention to the configuration of this part, and avoid some risks of online when publishing. 4

TARS-Answer commented 4 years ago

是的,节点配置也是可以的(见备注图四)。不过我们这里一般用的是私有模板和获取setDivisoin来处理,这样发布就不用关心这一部分的配置了,在发布的时候,避免一些上线的风险。 4