Add Servers to the Cluster and Stop Servers

GemFire XD manages data in a flexible way that enables you to expand or contract your cluster at runtime to support different loads. To dynamically add more capacity to a cluster, you add new server members and specify the -rebalance option.

  1. Open a new terminal or command prompt window, and create a directory for the new server:
    $ cd ~
    $ mkdir server3
  2. When you add a new server to the cluster, you can specify the -rebalance option to move partitioned table data buckets between host members as needed to establish the best balance of data across the distributed system. (See Rebalancing Partitioned Data on GemFire XD Members for more information.) Start the new server to see rebalancing in action:
    $ gfxd server start -dir=$HOME/server3 -locators=localhost[10101] -client-port=1530 -enable-network-partition-detection=true -rebalance
    Starting GemFireXD Server using locators for peer discovery: localhost[10101]
    Starting network server for GemFireXD Server at address localhost/[1530]
    Logs generated in /home/gpadmin/server3/gfxdserver.log
    GemFireXD Server pid: 41165 status: running
      Distributed system now has 4 members.
      Other members:<v0>:50344,<v5>:11337,<v6>:31019
  3. View the contents of the new GemFire XD directory:
    $ ls server3
    BACKUPGFXD-DEFAULT-DISKSTORE_1.drf  gfxdserver.log
    BACKUPGFXD-DEFAULT-DISKSTORE.if     start_gfxdserver.log

    Notice that the new GemFire XD server also persists the available table data, and contains the same disk store files as the other two servers.

  4. You can view all members of the distributed system using gfxd. Return to the gfxd session window and execute the query:
    gfxd> select id from sys.members;
    -------------------------------------------------------------------------------<v5>:11337                                          <v0>:50344                                          <v6>:31019                                          <v7>:35662                                               
    4 rows selected
  5. Verify that all servers now host the data:
    gfxd> select distinct dsid() as id from flights;
    -------------------------------------------------------------------------------<v5>:11337                                          <v6>:31019                                          <v7>:35662                                               
    3 rows selected
  6. Examine the table data that each server hosts:
    gfxd> select count(*) memberRowCount, dsid() from flights group by dsid();
    150           |<v5>:11337                                
    114           |<v6>:31019                                
    278           |<v7>:35662                                
    3 rows selected
  7. Exit the gfxd session:
    gfxd> exit;
  8. You can stop an individual GemFire XD server by using the gfxd server stop command and specifying the server directory. To shut down all data stores at once, use the gfxd shut-down-all command:
    $ gfxd shut-down-all -locators=localhost[10101]
    Connecting to distributed system: locators=localhost[10101]
    Successfully shut down 3 members
  9. After all data stores have stopped, shut down the locator as well:
    $ gfxd locator stop -dir=$HOME/locator
    The GemFireXD Locator has stopped.