Skip to content

Building Apache Geode

aborkar-ibm edited this page Jul 10, 2019 · 45 revisions

Building Apache Geode

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Apache Geode binaries are available and can be downloaded from here. To use these binaries, Java needs to be installed on mentioned distributions.

Step 1: Install dependencies

  • RHEL (7.4, 7.5, 7.6)

     sudo yum install -y java-1.8.0-openjdk wget unzip
  • RHEL (8.0)

     sudo yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel wget unzip
  • SLES (12 SP4, 15)

     sudo zypper install -y java-1_8_0-openjdk wget unzip which 
  • Ubuntu (16.04, 18.04, 19.04)

     sudo apt-get update
     sudo apt-get install -y openjdk-8-jdk wget unzip

Step 2: Set Environment Variables

   export JAVA_HOME=<path to java>
   export PATH=$JAVA_HOME/bin:$PATH

Step 3: Start a locator, server and create a region

Extract binary tar to /<source_root>/ and follow steps given below

  export SOURCE_ROOT=/<source_root>/
  export PATH=$SOURCE_ROOT/<apache_geode_binary_directory>/bin:$PATH
  • Check installed Apache Geode version

      gfsh version
  • To start locator and server, run following commands :

      gfsh
      gfsh> start locator
      gfsh> start server
  • Create a region

      gfsh> create region --name=hello --type=REPLICATE

Step 4: Verification (Optional)

Write a client application using gradle in different terminal.

  • Install Gradle
  export SOURCE_ROOT=/<source_root>/
  cd $SOURCE_ROOT
  wget https://services.gradle.org/distributions/gradle-5.2.1-bin.zip
  unzip gradle-5.2.1-bin.zip
  export JAVA_HOME=<path to java>
  export PATH=$JAVA_HOME/bin:$PATH:$SOURCE_ROOT/gradle-5.2.1/bin
  • Create $SOURCE_ROOT/build.gradle file with following contents

    apply plugin: 'java'
    apply plugin: 'application'
    
    mainClassName = 'HelloWorld'
    
    repositories { mavenCentral() }
    dependencies {
      compile 'org.apache.geode:geode-core:1.4.0'
      runtime 'org.slf4j:slf4j-log4j12:1.7.24'
    }
  • Create directory $SOURCE_ROOT/src/main/java and create a file at $SOURCE_ROOT/src/main/java/HelloWorld.java with following contents

    import java.util.Map;
    import org.apache.geode.cache.Region;
    import org.apache.geode.cache.client.*;
    
    public class HelloWorld {
      public static void main(String[] args) throws Exception {
    	ClientCache cache = new ClientCacheFactory()
    	  .addPoolLocator("localhost", 10334)
    	  .create();
    	Region<String, String> region = cache
    	  .<String, String>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
    	  .create("hello");
    
    	region.put("1", "Hello");
    	region.put("2", "World");
    
    	for (Map.Entry<String, String>  entry : region.entrySet()) {
    	  System.out.format("key = %s, value = %s\n", entry.getKey(), entry.getValue());
    	}
    	cache.close();
      }
    }
  • Build and run the HelloWorld example:

  gradle run

Gradle build is successfull as the application will connect to the running cluster, create a local cache, put data in the cache, and print the cached data to the console:

  key = 1, value = Hello
  key = 2, value = World
  • Shutdown the Geode server and locator in earlier terminal:
  gfsh> shutdown --include-locators=true

References:

https://geode.apache.org

https://github.com/apache/geode/blob/rel/v1.9.0/README.md

Clone this wiki locally