运行Geode定位器进程
定位器是一个Geode进程,它告诉运行成员有新的连接成员,并为服务器使用提供负载平衡。
- 对等定位器将加入成员的连接信息提供给已在定位器集群中运行的成员。
- 服务器定位器为客户端的集群中运行的服务器提供连接信息。服务器定位器还监视服务器负载并将客户端发送到负载最少的服务器。
默认情况下,定位器作为对等和服务器定位器运行。
您可以独立运行定位器或嵌入另一个Geode过程。独立运行定位器可提供定位器服务的最高可靠性和可用性。
定位器配置和日志文件
定位器配置和日志文件具有以下属性:
- 使用启动独立定位器时
gfsh,gfsh会自动将所需的JAR文件加载lib/geode-dependencies.jar到JVM进程的CLASSPATH中。如果使用LocatorLauncherAPI 启动独立定位器,则必须在用于启动定位器进程的命令中指定此JAR文件。有关Geode中CLASSPATH设置的更多信息,请参阅设置CLASSPATH。您可以通过指定--classpath参数来修改CLASSPATH 。 -
定位器是群集的成员,就像任何其他成员一样。在以下方面
mcast-port和locators配置,定位器应当以相同的方式作为服务器进行配置。因此,如果集群中还有另外两个定位器,则每个定位器应引用其他定位器(就像服务器成员一样)。例如:gfsh> start locator --name=locator1 --port=9009 --mcast-port=0 \ --locators='host1[9001],host2[9003]' -
您可以在
gemfire.properties文件中配置定位器,也可以在命令行上指定启动参数。如果要在属性文件中指定定位器的配置,则定位器需要与gemfire.properties群集的其他成员相同的设置,并且gfsecurity.properties如果使用单独的受限访问安全设置文件,则需要相同的设置。例如,要配置定位器和多播端口
gemfire.properties:locators=host1[9001],host2[9003] mcast-port=0 -
没有特定于定位器的缓存配置。
-
对于日志记录输出,定位器在其当前工作目录中创建日志文件。日志文件输出默认为
locator_name.log定位器的工作目录。如果使用以前使用的定位器名称重新启动定位器,则会自动为您重命名现有的locator_name .log文件(例如,locator1-01-01.log或locator1-02-01.log)。您可以通过--log-level在启动定位器时在参数中指定级别来修改此文件中的日志记录详细信息的级别。 -
默认情况下,定位器将在
gfsh执行目录下的子目录(以定位器命名)中启动。该子目录被视为当前工作目录。您还可以在启动定位器时指定其他工作目录gfsh。 -
默认情况下,由于网络分区事件或成员无响应而已关闭和断开连接的定位器将自行重新启动并自动尝试重新连接到现有群集。当定位器处于重新连接状态时,它不为群集提供任何发现服务。有关更多详细信息,请参阅使用自动重新连接处理强制缓存断开连接。
定位器和群集配置服务
定位器使用群集配置服务来保存适用于所有群集成员或指定组成员的配置。配置保存在Locator的目录中,并传播到集群中的所有定位器。使用启动服务器时gfsh,服务器将从定位器接收组级别和群集级别配置。
请参阅群集配置服务概述。
启动定位器
使用以下准则启动定位器:
-
独立定位器。以下列方式之一启动独立定位器:
-
使用
gfsh命令行实用程序。有关gfsh使用的更多信息,请参阅gfsh。例如:gfsh>start locator --name=locator1 gfsh> start locator --name=locator2 --bind-address=192.0.2.0 --port=13489 -
使用类中的
main方法org.apache.geode.distributed.LocatorLauncher和Java可执行文件启动定位器。具体来说,您使用LocatorLauncher类API在您创建的Java应用程序进程中运行嵌入式Locator服务。执行java命令的目录成为定位器进程的工作目录。 -
启动多个定位器时,不要并行启动它们(换句话说,同时启动它们)。作为最佳实践,您应该等待大约30秒,以便第一个定位器在启动任何其他定位器之前完成启动。要检查定位器是否成功启动,请检查定位器日志文件。要查看正在运行的定位器的正常运行时间,可以使用该
gfsh status locator命令。
-
-
嵌入式(共置)定位器。在成员启动时或通过API管理共置定位器:
-
使用该
gemfire.propertiesstart-locator设置可在Geode成员中自动启动定位器。请参阅参考。当成员退出时,定位器会自动停止。该属性具有以下语法:#gemfire.properties start-locator=[address]port[,server={true|false},peer={true|false}]例:
#gemfire.properties start-locator=13489 -
使用
org.apache.geode.distributed.LocatorLauncherAPI启动代码中的定位器。使用LocatorLauncher.Builder该类构造一个实例LocatorLauncher,然后使用该start()方法启动嵌入在Java应用程序进程中的Locator服务。LocatorLauncher该类中的其他方法提供有关定位器的状态信息,并允许您停止定位器。import org.apache.geode.distributed.LocatorLauncher; public class MyEmbeddedLocator { public static void main(String[] args){ LocatorLauncher locatorLauncher = new LocatorLauncher.Builder() .setMemberName("locator1") .setPort(13489) .build(); locatorLauncher.start(); System.out.println("Locator successfully started"); } }这是另一个将定位器嵌入应用程序,启动它然后在允许其他成员访问它之前检查定位器状态的示例:
package example; import ... class MyApplication implements Runnable { private final LocatorLauncher locatorLauncher; public MyApplication(final String... args) { validateArgs(args); locatorLauncher = new LocatorLauncher.Builder() .setMemberName(args[0]) .setPort(Integer.parseInt(args[1]) .setRedirectOutput(true) .build(); } protected void args(final String[] args) { ... } public void run() { ... // start the Locator in-process locatorLauncher.start(); // wait for Locator to start and be ready to accept member (client) connections locatorLauncher.waitOnStatusResponse(30, 5, TimeUnit.SECONDS); ... } public static void main(final String... args) { new MyApplication(args).run(); } }然后执行应用程序,您将运行:
/working/directory/of/MyApplication$ java \ -server -classpath "path/to/installation/lib/geode-dependencies.jar:/path/to/application/classes.jar" \ example.MyApplication Locator1 11235执行java命令的目录成为定位器进程的工作目录。
-
检查定位器状态
如果已连接到群集gfsh,则可以通过提供定位器名称来检查正在运行的定位器的状态。例如:
gfsh>status locator --name=locator1
如果未连接到群集,则可以通过提供进程ID,定位器的主机名和端口或定位器的当前工作目录来检查本地定位器的状态。例如:
<span style="color:#333333"><code>gfsh>status locator --pid=2986
</code></span>
要么
gfsh>status locator --host=host1 --port=1035
要么
$ gfsh status locator --dir=<locator_working_directory>
其中< locator_working_directory >对应于运行定位器的本地工作目录。
如果成功,该命令将返回以下信息(使用启动时提供的JVM参数):
$ gfsh status locator --dir=locator1
Locator in /home/user/locator1 on ubuntu.local[10334] as locator1 is currently online.
Process ID: 2359
Uptime: 17 minutes 3 seconds
GemFire Version: 8.0.0
Java Version: 1.8.0_121
Log File: /home/user/locator1/locator1.log
JVM Arguments: -Dgemfire.enable-cluster-configuration=true -Dgemfire.load-cluster-configuration-from-dir=false
-Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
Class-Path: /Users/username/apache_geode/lib/geode-dependencies.jar
Cluster configuration service is up and running.
停止定位器
如果已连接到群集gfsh,则可以通过提供定位器名称来停止正在运行的定位器。例如:
gfsh>stop locator --name=locator1
如果未连接到群集,则可以通过指定定位器的进程ID或定位器的当前工作目录来停止本地定位器。例如:
gfsh>stop locator --pid=2986
要么
gfsh>stop locator --dir=<locator_working_directory>
其中< locator_working_directory >对应于运行定位器的本地工作目录。
定位器和多站点(WAN)部署
如果使用多站点(WAN)配置,则可以在启动定位器时将定位器连接到远程站点。
要将新定位器进程连接到WAN配置中的远程定位器,请在启动时指定以下内容:
gfsh> start locator --name=locator1 --port=9009 --mcast-port=0 \
--J='-Dgemfire.remote-locators=192.0.2.0[9009],198.51.100.0[9009]'
本文围绕Geode定位器进程展开,介绍其作用,可作为对等、服务器定位器或两者运行。阐述了定位器配置和日志文件属性,以及与集群配置服务的关系。还详细说明了启动、检查状态、停止定位器的方法,最后提及定位器在多站点(WAN)部署中的连接设置。
4112

被折叠的 条评论
为什么被折叠?



