|Configuring Discovery Mechanisms / Using Locators|
GemFire XD peers or servers must specify a list of locator addresses to connect to when they join the distributed system.
Use the -locators option when starting a GemFire XD server or peer to identify all locators that are used for member discovery in the distributed system. In the previous section, Start and Stop Locators, two locators were started using the -peer-discovery-address and -peer-discovery-port combinations of "locator1host:10101" and "locator2host:20202." In order to join the distributed system created by these locators, new GemFire XD servers must specify those peer connections at startup.
gfxd server start -locators=locator1host,locator2host \ -client-bind-address=server1host -client-port=1529 -dir=server1
Specify the -client-bind-address and -client-port options to configure the connection that clients should use to connect to this GemFire XD member. Note that while you can specify either a hostname or an IP address with -client-bind-address, clients that connect to the distributed system using a locator will by default receive a hostname to use for connecting to the member. You must ensure that the hostname correctly maps to the IP address for each server (for example, in the /etc/hosts file). As an alternative, for systems that use only IP addresses you can use the prefer-netserver-ipaddress system property when starting a locator to provide server IP addresses to client connections.
gfxd server start -locators=locator1host,locator2host \ -client-bind-address=server2host -client-port=1530 -dir=server2
As each server or peer joins the distributed system, running locators update their information with the new server's client connection information. Note that although each server defines a client bind address and port, individual clients should connect directly to one of the available locators rather than to an individual server. In this way, the locator can load balance client connections to available servers, and can manage the list of available servers as they leave and join the distributed system.