Starting the Shell



Starting the Shell

0 0


gfsh-reveal

a gfsh session as revealjs slides

On Github eitansuez / gfsh-reveal

Starting the Shell

  $ gfsh

      _________________________     __
     / _____/ ______/ ______/ /____/ /
    / /  __/ /___  /_____  / _____  /
   / /__/ / ____/  _____/ / /    / /
  /______/_/      /______/_/    /_/    v8.2.0

  Monitor and Manage GemFire
  gfsh>

Context-sensitive help

  gfsh>start locator

          
  Parameter "name" is required. Use "help <command name>" for assistance.

          

Starting a locator

 gfsh>start locator --name=locator
          
  Starting a GemFire Locator in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/locator...
  .............................
  Locator in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/locator on eitans-mbp[10334] as locator is currently online.
  Process ID: 38488
  Uptime: 15 seconds
  GemFire Version: 8.2.0
  Java Version: 1.8.0_66
  Log File: /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/locator/locator.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: /usr/local/Cellar/gemfire/8.2.0/libexec/lib/gemfire.jar:/usr/local/Cellar/gemfire/8.2.0/libexec/lib/locator-dependencies.jar

  Successfully connected to: [host=eitans-mbp, port=1099]

  Cluster configuration service is up and running.
          

Listing Members

  gfsh>list members
          
  Member Count : 1
  Coordinator  : locator (Eitans-MBP(locator:38488:locator)<v0>:44761)

   Name   | Id
  ------- | -------------------------------------------
  locator | Eitans-MBP(locator:38488:locator)<v0>:44761
          

Start a Server

  gfsh>start server --name=server1 --server-port=0
          
  Starting a GemFire Server in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1...
  ....
  Server in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1 on eitans-mbp[52257] as server1 is currently online.
  Process ID: 38562
  Uptime: 2 seconds
  GemFire Version: 8.2.0
  Java Version: 1.8.0_66
  Log File: /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1/server1.log
  JVM Arguments: -Dgemfire.default.locators=192.168.1.71[10334] -Dgemfire.use-cluster-configuration=true -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
  Class-Path: /usr/local/Cellar/gemfire/8.2.0/libexec/lib/gemfire.jar:/usr/local/Cellar/gemfire/8.2.0/libexec/lib/server-dependencies.jar
          

Now we have two members

  gfsh>list members
          
  Member Count : 2
  Coordinator  : locator (Eitans-MBP(locator:38488:locator)<v0>:44761)

   Name   | Id
  ------- | -------------------------------------------
  server1 | Eitans-MBP(server1:38562)<v1>:26482
  locator | Eitans-MBP(locator:38488:locator)<v0>:44761
          

Another help example

  gfsh>create region
          
  Parameter "name" is required. Use "help <command name>" for assistance.
          
  gfsh>help create region
          
  NAME
      create region
  IS AVAILABLE
      true
  SYNOPSIS
      Create a region with the given path and configuration. Specifying a --key-constraint and --value-constraint makes object type information available during querying and
      indexing.
  SYNTAX
      create region --name=value [--type=value] [--template-region=value] [--group=value(,value)*] [--skip-if-exists(=value)?] [--key-constraint=value] [--value-constraint=value]
      [--enable-statistics=value] [--entry-idle-time-expiration=value] [--entry-idle-time-expiration-action=value] [--entry-time-to-live-expiration=value]
      [--entry-time-to-live-expiriation-action=value] [--region-idle-time-expiration=value] [--region-idle-time-expiration-action=value] [--region-time-to-live-expiration=value]
      [--region-time-to-live-expiration-action=value] [--disk-store=value] [--enable-synchronous-disk=value] [--enable-async-conflation=value]
      [--enable-subscription-conflation=value] [--cache-listener=value(,value)*] [--cache-loader=value] [--cache-writer=value] [--async-event-queue-id=value(,value)*]
      [--gateway-sender-id=value(,value)*] [--enable-concurrency-checks=value] [--enable-cloning=value] [--concurrency-level=value] [--colocated-with=value]
      [--local-max-memory=value] [--recovery-delay=value] [--redundant-copies=value] [--startup-recovery-delay=value] [--total-max-memory=value] [--total-num-buckets=value]
      [--compressor=value]
  PARAMETERS
      name
          Name/Path of the region to be created.
          Required: true
      type
          Type of region to create. Examples include: PARTITION, PARTITION_REDUNDANT, REPLICATE, LOCAL, etc.
          Required: false
      ...
          

Create a region

  gfsh>create region --name=people --type=REPLICATE
          
  Member  | Status
  ------- | -------------------------------------
  server1 | Region "/people" created on "server1"
          

Verify we have a region

  gfsh>list regions
          
  List of regions
  ---------------
  people
          

Region is empty

  gfsh>query --query="select * from /people"
          
  Result     : true
  startCount : 0
  endCount   : 20
  Rows       : 0

  NEXT_STEP_NAME : END
          

How to insert a record?

  gfsh>help put
          
  NAME
      put
  IS AVAILABLE
      true
  SYNOPSIS
      Add/Update an entry in a region. If using a region whose key and value classes have been set, then specifying --key-class and --value-class is unnecessary.
  SYNTAX
      put --key=value --value=value --region=value [--key-class=value] [--value-class=value] [--skip-if-exists=value]
  PARAMETERS
      key
          String or JSON text from which to create the key.  Examples include: "James", "100L" and "('id': 'l34s')".
          Required: true
      value
          String or JSON text from which to create the value.  Examples include: "manager", "100L" and "('value': 'widget')".
          Required: true
      region
          Region into which the entry will be put.
          Required: true
      key-class
          Fully qualified class name of the key's type. The default is java.lang.String.
          Required: false
      value-class
          Fully qualified class name of the value's type. The default is java.lang.String.
          Required: false
      skip-if-exists
          Skip the put operation when an entry with the same key already exists. The default is to overwrite the entry (false).
          Required: false
          Default (if the parameter is not specified): false
          

Insert record

  gfsh>put --key="eitan" --value="eitan suez" --region="people"
          
  Result      : true
  Key Class   : java.lang.String
  Key         : eitan
  Value Class : java.lang.String
  Old Value   : <NULL>
          

Query

  gfsh>query --query="select * from /people"
          
  Result     : true
  startCount : 0
  endCount   : 20
  Rows       : 1

  Result
  ----------
  eitan suez

  NEXT_STEP_NAME : END
          

A second record

  gfsh>put --key="mark" --value="mark secrist" --region="people"
          
  Result      : true
  Key Class   : java.lang.String
  Key         : mark
  Value Class : java.lang.String
  Old Value   : <NULL>
          

Query again..

  gfsh>query --query="select * from /people"
          
  Result     : true
  startCount : 0
  endCount   : 20
  Rows       : 2

  Result
  ------------
  mark secrist
  eitan suez

  NEXT_STEP_NAME : END
          

Tab suggestion exampe

  gfsh>describe
          
  describe client     describe config     describe connection      describe disk-store
  describe member     describe offline-disk-store
  describe region
          

Describe a member

  gfsh>describe member --name=server1
          
  Name        : server1
  Id          : Eitans-MBP(server1:38562)<v1>:26482
  Host        : eitans-mbp
  Regions     : people
  PID         : 38562
  Groups      :
  Used Heap   : 29M
  Max Heap    : 3641M
  Working Dir : /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1
  Log file    : /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1/server1.log
  Locators    : 192.168.1.71[10334]

  Cache Server Information
  Server Bind              : null
  Server Port              : 52257
  Running                  : true
  Client Connections       : 0
          

Describe a region

  gfsh>describe region --name=people
          
  ..........................................................
  Name            : people
  Data Policy     : replicate
  Hosting Members : server1

  Non-Default Attributes Shared By Hosting Members

   Type  | Name | Value
  ------ | ---- | -----
  Region | size | 2
          

Start a second server

  gfsh>start server --name=server2
          
  Starting a GemFire Server in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server2...
  ....
  Server in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server2 on eitans-mbp[40404] as server2 is currently online.
  Process ID: 38615
  Uptime: 2 seconds
  GemFire Version: 8.2.0
  Java Version: 1.8.0_66
  Log File: /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server2/server2.log
  JVM Arguments: -Dgemfire.default.locators=192.168.1.71[10334] -Dgemfire.use-cluster-configuration=true -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
  Class-Path: /usr/local/Cellar/gemfire/8.2.0/libexec/lib/gemfire.jar:/usr/local/Cellar/gemfire/8.2.0/libexec/lib/server-dependencies.jar
          

Describe region again..

  gfsh>describe region --name=people
          
  ..........................................................
  Name            : people
  Data Policy     : replicate
  Hosting Members : server2
                    server1

  Non-Default Attributes Shared By Hosting Members

   Type  | Name | Value
  ------ | ---- | -----
  Region | size | 2
          

  gfsh>query --query="select * from /people"
          
  Result     : true
  startCount : 0
  endCount   : 20
  Rows       : 2

  Result
  ------------
  mark secrist
  eitan suez

  NEXT_STEP_NAME : END
          

Stop server1

  gfsh>stop server --name=server1
          
  Stopping Cache Server running in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1 on eitans-mbp[52257] as server1...
  Process ID: 38562
  Log File: /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1/server1.log
  ....
          

Query is not affected

  gfsh>query --query="select * from /people"
          

  Result     : true
  startCount : 0
  endCount   : 20
  Rows       : 2

  Result
  ------------
  mark secrist
  eitan suez

  NEXT_STEP_NAME : END
          

check status of server2

  gfsh>status server --name=server2
          
  Server in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server2 on eitans-mbp[40404] as server2 is currently online.
  Process ID: 38615
  Uptime: 48 seconds
  GemFire Version: 8.2.0
  Java Version: 1.8.0_66
  Log File: /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server2/server2.log
  JVM Arguments: -Dgemfire.default.locators=192.168.1.71[10334] -Dgemfire.use-cluster-configuration=true -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
  Class-Path: /usr/local/Cellar/gemfire/8.2.0/libexec/lib/gemfire.jar:/usr/local/Cellar/gemfire/8.2.0/libexec/lib/server-dependencies.jar
          

Two members left (locator and server)

  gfsh>list members
          
  Member Count : 2
  Coordinator  : locator (Eitans-MBP(locator:38488:locator)<v0>:44761)

   Name   | Id
  ------- | -------------------------------------------
  server2 | Eitans-MBP(server2:38615)<v2>:29779
  locator | Eitans-MBP(locator:38488:locator)<v0>:44761
          

Error example: start server, port taken

  gfsh>start server --name=server1
          
  Starting a GemFire Server in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1...
  The Cache Server process terminated unexpectedly with exit status 1. Please refer to the log file in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1 for full details.

  Exception in thread "main" java.lang.RuntimeException: An IO error occurred while starting a Server in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1 on eitans-mbp[40404]: Network is unreachable; port (40404) is not available on localhost.
      at com.gemstone.gemfire.distributed.ServerLauncher.start(ServerLauncher.java:720)
      at com.gemstone.gemfire.distributed.ServerLauncher.run(ServerLauncher.java:624)
      at com.gemstone.gemfire.distributed.ServerLauncher.main(ServerLauncher.java:194)
  Caused by: java.net.BindException: Network is unreachable; port (40404) is not available on localhost.
      at com.gemstone.gemfire.distributed.AbstractLauncher.assertPortAvailable(AbstractLauncher.java:128)
      at com.gemstone.gemfire.distributed.ServerLauncher.start(ServerLauncher.java:679)
      ... 2 more
          

Restart server1

  gfsh>start server --name=server1 --server-port=0
          
  Starting a GemFire Server in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1...
  ....
  Server in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1 on eitans-mbp[52338] as server1 is currently online.
  Process ID: 38633
  Uptime: 2 seconds
  GemFire Version: 8.2.0
  Java Version: 1.8.0_66
  Log File: /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1/server1.log
  JVM Arguments: -Dgemfire.default.locators=192.168.1.71[10334] -Dgemfire.use-cluster-configuration=true -XX:OnOutOfMemoryError=kill -KILL %p -Dgemfire.launcher.registerSignalHandlers=true -Djava.awt.headless=true -Dsun.rmi.dgc.server.gcInterval=9223372036854775806
  Class-Path: /usr/local/Cellar/gemfire/8.2.0/libexec/lib/gemfire.jar:/usr/local/Cellar/gemfire/8.2.0/libexec/lib/server-dependencies.jar
          

Back to three members

  gfsh>list members
          
  Member Count : 3
  Coordinator  : locator (Eitans-MBP(locator:38488:locator)<v0>:44761)

   Name   | Id
  ------- | -------------------------------------------
  server2 | Eitans-MBP(server2:38615)<v2>:29779
  server1 | Eitans-MBP(server1:38633)<v5>:37311
  locator | Eitans-MBP(locator:38488:locator)<v0>:44761
          

Can describe members..

  gfsh>describe member --name=server1
          
  Name        : server1
  Id          : Eitans-MBP(server1:38633)<v5>:37311
  Host        : eitans-mbp
  Regions     : people
  PID         : 38633
  Groups      :
  Used Heap   : 66M
  Max Heap    : 3641M
  Working Dir : /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1
  Log file    : /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server1/server1.log
  Locators    : 192.168.1.71[10334]

  Cache Server Information
  Server Bind              :
  Server Port              : 52338
  Running                  : true
  Client Connections       : 0
          

And server2..

  gfsh>describe member --name=server2
          
  Name        : server2
  Id          : Eitans-MBP(server2:38615)<v2>:29779
  Host        : eitans-mbp
  Regions     : people
  PID         : 38615
  Groups      :
  Used Heap   : 15M
  Max Heap    : 3641M
  Working Dir : /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server2
  Log file    : /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/server2/server2.log
  Locators    : 192.168.1.71[10334]

  Cache Server Information
  Server Bind              :
  Server Port              : 40404
  Running                  : true
  Client Connections       : 0
          

Exit shell

  gfsh>exit
          
  Exiting...

  esuez at Eitans-MBP in ~/Desktop/Courses/GemfireDeveloper/scratchpad/session1
          

Re-enter..

  $ gfsh
          
      _________________________     __
     / _____/ ______/ ______/ /____/ /
    / /  __/ /___  /_____  / _____  /
   / /__/ / ____/  _____/ / /    / /
  /______/_/      /______/_/    /_/    v8.2.0

  Monitor and Manage GemFire
          

Reconnect to cluster

  gfsh>connect --locator=localhost[10334]
          
  Connecting to Locator at [host=localhost, port=10334] ..
  Connecting to Manager at [host=eitans-mbp, port=1099] ..
  Successfully connected to: [host=eitans-mbp, port=1099]
          

List members once more..

  gfsh>list members
          
  Member Count : 3
  Coordinator  : locator (Eitans-MBP(locator:38488:locator)<v0>:44761)

   Name   | Id
  ------- | -------------------------------------------
  server2 | Eitans-MBP(server2:38615)<v2>:29779
  server1 | Eitans-MBP(server1:38633)<v5>:37311
  locator | Eitans-MBP(locator:38488:locator)<v0>:44761
          

Shutting down

  gfsh>shutdown
          
  As a lot of data in memory will be lost, including possibly events in queues, do you really want to shutdown the entire distributed system? (Y/n): Y
  Shutdown is triggered
          

Verify no servers

  gfsh>list members
          
  Member Count : 1
  Coordinator  : locator (Eitans-MBP(locator:38488:locator)<v0>:44761)

   Name   | Id
  ------- | -------------------------------------------
  locator | Eitans-MBP(locator:38488:locator)<v0>:44761
          

Stop locator

  gfsh>stop locator --name=locator
          
  Stopping Locator running in /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/locator on eitans-mbp[10334] as locator...
  Process ID: 38488
  Log File: /Users/esuez/Desktop/Courses/GemfireDeveloper/scratchpad/session1/locator/locator.log
  ...

  No longer connected to eitans-mbp[1099].
          
Starting the Shell $ gfsh _________________________ __ / _____/ ______/ ______/ /____/ / / / __/ /___ /_____ / _____ / / /__/ / ____/ _____/ / / / / /______/_/ /______/_/ /_/ v8.2.0 Monitor and Manage GemFire gfsh>