Skip to content

Building Apache Geode

aborkar-ibm edited this page Apr 7, 2020 · 44 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 Prerequisites

  • RHEL (7.6, 7.7, 7.8, 8.0, 8.1)

    sudo yum install -y wget unzip tar
  • SLES (12 SP4, 12 SP5, 15 SP1)

    sudo zypper install -y wget unzip which tar gzip
  • Ubuntu (16.04, 18.04, 19.10)

    sudo apt-get update
    sudo apt-get install -y wget unzip tar

Step 2: Install Java

  • RHEL (7.6, 7.7, 7.8, 8.0, 8.1)

    sudo yum install -y java-11-openjdk-devel
  • SLES (12 SP5, 15 SP1)

    sudo zypper install -y java-11-openjdk-devel
  • Ubuntu (18.04, 19.10)

    sudo apt-get update
    sudo apt-get install -y openjdk-11-jdk
  • SLES (12 SP4) and Ubuntu (16.04)

    cd /<source_root>/
    wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.6_10.tar.gz
    tar zxvf OpenJDK11U-jdk_s390x_linux_hotspot_11.0.6_10.tar.gz
    sudo mv jdk-11.0.6+10 /usr/local
    export JAVA_HOME=/usr/local/jdk-11.0.6+10
    export PATH=$PATH:$JAVA_HOME/bin

Step 3: Set Environment Variables

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

Step 4: 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 5: 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.5-bin.zip
    unzip gradle-5.5-bin.zip
    export JAVA_HOME=<path to java>
    export PATH=$JAVA_HOME/bin:$PATH:$SOURCE_ROOT/gradle-5.5/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.12.0/README.md

Clone this wiki locally