分布式配置数据在哪里\如何存储

发布于 2024-07-29 23:41:56 字数 445 浏览 9 评论 0原文

我们产品的一次安装将其配置存储在一组数据库表中。

所有安装都不“了解”任何其他安装。

客户在地理位置相距较远的不同数据中心安装我们产品的多个副本一直是很常见的情况。 这意味着配置信息需要创建一次,然后导出到其他系统。 然后修改一些配置以适应当地条件。 例如更改 IP 地址等。这是一种笨拙且容易出错的方法。

我们现在收到要求能够制定更无缝的全球数据共享策略的请求,但仍允许本地修改。

如果没有本地修改位,那么我们可以使用 Oracle 的数据复制功能。

由于 HA 要求,将所有配置都放在一个数据库中不是一种选择。

有其他人遇到过这个问题吗?您是否为此找到了一个好的编程解决方案? 知道任何可能描述部分或完整解决方案的好论文吗?

我们基于 *nix,并使用 Oracle。 更改应该很快(一秒或两秒)复制到所有节点。

A single installation of our product stores it's configuration in a set of database tables.

None of the installations 'know' about any other installation.

It's always been common for customers to install multiple copies of our product in different datacentres, which are geographically far apart. This means that the configuration information needs to be created once, then exported to other systems. Some of the config is then modified to suit local conditions. e.g. changing IP addresses, etc. This is a clunky, error prone approach.

We're now getting requests for the ability to have a more seamless strategy for sharing of global data, but still allowing local modifications.

If it weren't for the local modifications bit then we could use Oracle's data replication features.

Due to HA requirements having all the configuration in the one database isn't an option.

Has anyone else encountered this problem and have you ever figured out a good programmatic solution for this? Know of any good papers that might describe a partial or full solution?

We're *nix based, and use Oracle. Changes should be replicated to all nodes pretty quickly (a second or 2).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

杀お生予夺 2024-08-05 23:41:57

我不确定您有多大可能改变处理配置的方式,但我们通过使用本地覆盖的想法实现了类似的东西。 具体来说,您有两个相同的配置表(称为 CentralConfig 和 LocalConfig)。 CentralConfig 在中央位置维护,并复制到您的卫星位置,在该位置它是只读的。 LocalConfig可以在本地站点设置。 查询配置数据的过程首先在 LocalConfig 表中查找数据,如果未找到,则从 CentralConfig 表中检索数据。

例如,如果您尝试使用 v$parameter 表中的值执行此操作,则可以使用 SQL 分析中的 FIRST_VALUE 函数查询您的配置:

  SELECT DISTINCT
         NAME
       , FIRST_VALUE(VALUE) OVER(PARTITION BY NAME 
                                     ORDER BY localsort
                                ) VALUE
    FROM (SELECT t.*
               , 0 localsort
            FROM local_parameter t
           UNION
          SELECT t.*
               , 1 localsort
            FROM v$parameter t
         )
ORDER BY NAME;

联合中的 localsort 列只是为了确保 local_parameter 值采用优先于 v$ 参数值。

在我们的系统中,它实际上比这复杂得多。 除了您要查找的参数的“名称”之外,我们还有一个“上下文”列,用于描述我们正在查找的上下文。 例如,我们可能有一个集中设置的参数“超时”,但即使在本地,我们也有多个组件使用该值。 它们可能都是相同的,但我们也可能希望对它们进行不同的配置。 因此,当该工具查找“超时”值时,它也会受到范围的限制。 在配置本身中,当我们定义我们想要的范围时,我们可以使用通配符,例如:

CONTEXT       NAME    VALUE
------------- ------- -----
Comp Engine A timeout    15
Comp Engine B timeout    10
Comp Engine % timeout     5
%             timeout    30

上面的配置表示,对于所有组件,使用超时 30,但对于任何类型的 Comp Engine,使用超时 5,但是对于 Comp Engines A 和 B、使用15& 分别为 10 个。 最后两个配置可以在 CentralConfig 中维护,但其他两个配置可以在 LocalConfig 中维护,您可以这样解决设置:

  SELECT DISTINCT
         NAME
       , FIRST_VALUE(VALUE) OVER(PARTITION BY NAME 
                                     ORDER BY (TRANSLATE(Context
                                                        , '%_'
                                                        , CHR(1) || CHR(2)
                                              ) DESC
                                            , localsort
                                ) VALUE
    FROM (SELECT t.*
               , 0 localsort
            FROM LocalConfig t
           WHERE 'Comp Engine A' LIKE Context
           UNION
          SELECT t.*
               , 1 localsort
            FROM CentralConfig t
           WHERE 'Comp Engine A' LIKE Context
         )
ORDER BY NAME;

它基本上是相同的查询,除了我在 localsort 和 I' 之前插入 TRANSLATE 表达式m 限制上下文。 它所做的是将 % 和 _ 字符转换为 chr(1) & chr(2),这将使它们按降序排列在字母数字字符之后。 这样,显式定义的“Comp Engine A”将出现在“Comp Engine %”之前,而“Comp Engine %”又会出现在“%”之前。 在上下文定义相同的情况下,本地配置优先于中央配置; 如果您希望 local 始终胜过central,即使在central 范围更紧密的情况下,您只需颠倒两个排序项的位置即可。

I'm not sure how possible it is for you to change the way you handle your configuration, but we implemented something similar to this by using the idea of local overrides. Specifically, you have two configuration tables that are identical (call them CentralConfig and LocalConfig). CentralConfig is maintained at the central location, and is replicated out to your satellite locations, where it is read-only. LocalConfig can be set up at the local site. Your procedure which queries configuration data first looks for the data in the LocalConfig table, and if not found, retrieves it from the CentralConfig table.

For example, if you were trying to do this with the values in the v$parameter table, you could query your configuration using the FIRST_VALUE function in SQL analytics:

  SELECT DISTINCT
         NAME
       , FIRST_VALUE(VALUE) OVER(PARTITION BY NAME 
                                     ORDER BY localsort
                                ) VALUE
    FROM (SELECT t.*
               , 0 localsort
            FROM local_parameter t
           UNION
          SELECT t.*
               , 1 localsort
            FROM v$parameter t
         )
ORDER BY NAME;

The localsort column in the unions is there just to make sure that the local_parameter values take precedence over the v$parameter values.

In our system, it's actually much more sophisticated than this. In addition to the "name" for the parameter you're looking up, we also have a "context" column that describes the context we are looking for. For example, we might have a parameter "timeout" that is set centrally, but even locally, we have multiple components that use this value. They may all be the same, but we may also want to configure them differently. So when the tool looks up the "timeout" value, it also constrains by scope. In the configuration itself, we may use wildcards when we define what we want for scope, such as:

CONTEXT       NAME    VALUE
------------- ------- -----
Comp Engine A timeout    15
Comp Engine B timeout    10
Comp Engine % timeout     5
%             timeout    30

The configuration above says, for all components, use a timeout of 30, but for Comp Engines of any type, use a timeout of 5, however for Comp Engines A & B, use 15 & 10 respectively. The last two configurations may be maintained in CentralConfig, but the other two may be maintained in LocalConfig, and you would resolve the settings this way:

  SELECT DISTINCT
         NAME
       , FIRST_VALUE(VALUE) OVER(PARTITION BY NAME 
                                     ORDER BY (TRANSLATE(Context
                                                        , '%_'
                                                        , CHR(1) || CHR(2)
                                              ) DESC
                                            , localsort
                                ) VALUE
    FROM (SELECT t.*
               , 0 localsort
            FROM LocalConfig t
           WHERE 'Comp Engine A' LIKE Context
           UNION
          SELECT t.*
               , 1 localsort
            FROM CentralConfig t
           WHERE 'Comp Engine A' LIKE Context
         )
ORDER BY NAME;

It's basically the same query, except that I'm inserting that TRANSLATE expression before my localsort and I'm constraining on Context. What it's doing is converting the % and _ characters to chr(1) & chr(2), which will make them sort after alphanumeric characters in the descending sort. In this way, the explicitly defined "Comp Engine A" will come before "Comp Engine %", which in turn will come before "%". In cases where the contexts are defined identically, local config takes precedence over central ones; if you wanted local to always trump central, even in cases when central was scoped more tightly, you'd just reverse the positions of the two sort terms.

¢蛋碎的人ぎ生 2024-08-05 23:41:57

我们这样做的方式与史蒂夫的类似。
首先,您需要一个中央配置服务来保存要应用于分布式环境的所有配置。 每次要修改配置时,请在中央配置服务中进行修改。 在每个生产主机中,您可以编写一个循环脚本来更新配置。
对于更复杂的解决方案,您需要设置一些策略来避免错误的配置批次进入所有服务器,这将是一场灾难。 也许你需要一个简单的锁定或灰色释放过程。

The way we're doing this is similar with Steve's.
First you need a Central Configure Service to save all the configure you want to apply to the distributed environment. Every time you want to modify the config, modify it in the Central Configure Service. In each production host you can write a loop script to update the configure.
For a more sophisticated solution, you need to set up some strategy to avoid a wrong configure batch into all servers, that would be a disaster. Maybe you need a simple lock or a grey release process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文