The other day I was given a task to build Apache Cassandra 3.10 from source on an IBM LinuxONE instance. These instances aren’t like regular VPS hosted by other services. These VPS instances run on IBM’s S390X architecture. The instances I was using are running Red Hat 7.2. Unfortunately, I don’t have any licenses for RHEL, so I made due with the free packages available.
I was following some instructions found here. At first, cassandra would fail because of some
hotspot_compiler error. I originally thought it was because I was using
OpenJDK instead of
IBM JDK. This was a wrong assumption. Use
OpenJDK for this. The real problem was caused by
byteman-install-3.0.3 not being downloaded properly. I had to manually download it and include it in the Maven caches. This was shown in the before mentioned instructions. Once this was done, I could build cassandra, but when running
./bin/cassandra -f I was getting a
After some searching online, I was led to this site which hinted at changing the default JVM stack size from 256k to 512k. After doing this, cassandra worked no problem!
I hope this helps someone! I’ve included a script below that automates this whole process if you copy it into a shell script. It’s probably a little inefficient, but it gets the job done.
## Remove old JDK packages (if any) sudo yum -y remove java-1.8.0-openjdk.s390x java-1.8.0-openjdk-devel.s390x java-1.8.0-openjdk-headless.s390x java-1.8.0-ibm.s390x java-1.8.0-ibm-devel.s390x ## Install JDK packages sudo yum -y install git which java-1.8.0-openjdk-devel.s390x gcc-c++ make automake autoconf libtool libstdc++-static tar wget patch words libXt-devel libX11-devel texinfo ## Make /data/db directory mkdir /data/db cd /data/db ## Get latest version of ANT (1.10.1 as of 3/21/17) wget https://archive.apache.org/dist/ant/binaries/apache-ant-1.10.1-bin.tar.gz tar -xvf apache-ant-1.10.1-bin.tar.gz ## Set some environmental variables unset JAVA_TOOL_OPTIONS export LANG="en_US.UTF-8" export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8" export JAVA_HOME=/usr/lib/jvm/java #(for RHEL) export ANT_OPTS="-Xms4G -Xmx4G" export ANT_HOME=/data/db/apache-ant-1.10.1 export PATH=$PATH:$ANT_HOME/bin ## Get latest version of Snappy cd /data/db/ git clone https://github.com/xerial/snappy-java.git cd snappy-java git checkout develop ## Build Snappy make IBM_JDK_8=1 USE_GIT=1 GIT_SNAPPY_BRANCH=master GIT_REPO_URL=https://github.com/google/snappy.git ## Get latest version of JNA cd /data/db/ git clone https://github.com/java-native-access/jna.git ## Build JNA cd jna ant ## Get latest version of Cassandra (3.10 as of 3/21/17) cd /data/db/ git clone https://github.com/apache/cassandra.git cd cassandra git checkout cassandra-3.10 ## Build cassandra (this will fail but that's okay for now) cd /data/db/cassandra ant ## Move local builds of Snappy and JNA to our cassandra build folder rm /data/db/cassandra/lib/snappy-java-220.127.116.11.jar rm /data/db/cassandra/lib/jna-4.0.0.jar cp /data/db/snappy-java/target/snappy-java-1.1.3-SNAPSHOT.jar /data/db/cassandra/lib/snappy-java-1.1.3.jar cp /data/db/jna/build/jna.jar /data/db/cassandra/lib/jna.jar ## Get byteman-install-3.0.3 manually cd /tmp/ wget https://downloads.jboss.org/byteman/3.0.3/byteman-download-3.0.3-bin.zip unzip byteman-download-3.0.3-bin.zip -d /tmp ## Remove existing byteman rm -f /data/db/cassandra/build/lib/jars/byteman-install-3.0.3.jar ## Copy good version of byteman to cassandra directory and Maven repo cp /tmp/byteman-download-3.0.3/lib/byteman-install.jar /data/db/cassandra/build/lib/jars/byteman-install-3.0.3.jar cp /tmp/byteman-download-3.0.3/lib/byteman-install.jar /home/linux1/.m2/repository/org/jboss/byteman/byteman-install/3.0.3/byteman-install-3.0.3.jar ## Rebuild Cassandra with all the correct libraries ## Notice that we don't run 'ant realclean'. This would overwrite the manual binaries we just copied cd /data/db/cassandra ant ## Adjust JVM Option of Per-thread stack size from 256K to 512K to prevent StackOverflow (hint from https://blogs.oracle.com/partnertech/entry/how_to_build_and_run) sed -i 's/-Xss256k/-Xss512k/g' /data/db/cassandra/conf/jvm.options ## run Cassandra in foreground and watch for errors if any cd /data/db/cassandra/ ./bin/cassandra -f