如何在 HA 模式下配置 gemfire
how to configure gemfire in a HA mode
如何在 ha 模式下配置 gemfire
在 cache.xml
<?xml version="1.0" encoding="UTF-8"?><cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://geode.apache.org/schema/cache" xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd" version="1.0" lock-lease="120" lock-timeout="60" search-timeout="300" is-server="false" copy-on-read="false"/>
<!-- Run one secondary server -->
<cache>
<pool name="red1" subscription-enabled="true" subscription-redundancy="1">
<locator host="node5" port="41111"/>
<locator host="node6" port="41111"/>
</pool>
</cache>
要获得 HA,您需要有多个 GemFire/Geode 定位器和服务器 运行。
gfsh>start locator --name=loc1 --port=10334
gfsh>start locator --name=loc2 --port=10335
gfsh>start server --name=serv1 --server-port=40404
gfsh>start server --name=serv2 --server-port=40405
gfsh>start server --name=serv3 --server-port=40406
然后您需要确保您所在的地区有冗余副本。对于分区区域,这可以定义如下:
gfsh>create region --name=myPR --type=PARTITION_REDUNDANT
这将保证您能够容忍丢失一台 Geode 服务器。您可以为一个 Partition Region 配置最多 3 个冗余副本,确保这些冗余副本位于不同的机架等。请参阅 docs 了解如何完成此操作。复制区域在所有服务器上具有相同的数据,因此它始终具有高可用性。
配置服务器端后,需要将客户端连接池指向定位器。客户端池将建立与可用服务器的连接,如果服务器出现故障,该池将自动尝试 re-execute 另一台服务器上的操作。要配置池,只需指向定位器,然后在区域定义中使用池。
<client-cache>
<pool name="publisher" subscription-enabled="true">
<locator host="lucy" port="41111"/>
<locator host="lucy" port="41111"/>
</pool>
...
<region name="clientRegion" ...
<region-attributes pool-name="publisher" ...
详情请参考docs
如何在 ha 模式下配置 gemfire 在 cache.xml
<?xml version="1.0" encoding="UTF-8"?><cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://geode.apache.org/schema/cache" xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd" version="1.0" lock-lease="120" lock-timeout="60" search-timeout="300" is-server="false" copy-on-read="false"/>
<!-- Run one secondary server -->
<cache>
<pool name="red1" subscription-enabled="true" subscription-redundancy="1">
<locator host="node5" port="41111"/>
<locator host="node6" port="41111"/>
</pool>
</cache>
要获得 HA,您需要有多个 GemFire/Geode 定位器和服务器 运行。
gfsh>start locator --name=loc1 --port=10334
gfsh>start locator --name=loc2 --port=10335
gfsh>start server --name=serv1 --server-port=40404
gfsh>start server --name=serv2 --server-port=40405
gfsh>start server --name=serv3 --server-port=40406
然后您需要确保您所在的地区有冗余副本。对于分区区域,这可以定义如下:
gfsh>create region --name=myPR --type=PARTITION_REDUNDANT
这将保证您能够容忍丢失一台 Geode 服务器。您可以为一个 Partition Region 配置最多 3 个冗余副本,确保这些冗余副本位于不同的机架等。请参阅 docs 了解如何完成此操作。复制区域在所有服务器上具有相同的数据,因此它始终具有高可用性。
配置服务器端后,需要将客户端连接池指向定位器。客户端池将建立与可用服务器的连接,如果服务器出现故障,该池将自动尝试 re-execute 另一台服务器上的操作。要配置池,只需指向定位器,然后在区域定义中使用池。
<client-cache>
<pool name="publisher" subscription-enabled="true">
<locator host="lucy" port="41111"/>
<locator host="lucy" port="41111"/>
</pool>
...
<region name="clientRegion" ...
<region-attributes pool-name="publisher" ...
详情请参考docs