Skip to content

Building CouchDB

aborkar-ibm edited this page Dec 18, 2018 · 45 revisions

Building CouchDB

Below versions of CouchDB are available in respective distributions at the time of creation of these build instructions.

  • Ubuntu 16.04 have 1.6.0

The instructions provided below specify the steps to build CouchDB version 2.3.0 on Linux on IBM Z for following distributions:

  • RHEL (6.10, 7.4, 7.5, 7.6)
  • SLES (12 SP3, 15)
  • Ubuntu (16.04, 18.04)

General Note:

  • 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.

Step 1 : Building CouchDB

1.1) Install dependencies

  • RHEL 6.10

    sudo yum install -y libicu-devel wget tar m4 make patch perl-devel xz libtool which curl java-1.8.0-ibm-devel openssl-devel ncurses-devel unixODBC-devel gettext-devel cvs zip gcc-c++ glib2-devel gtk2-devel fontconfig-devel libnotify-devel libIDL-devel alsa-lib-devel libXt-devel freetype-devel pkgconfig dbus-glib-devel curl-devel autoconf213 xorg-x11-proto-devel libX11-devel libXau-devel libXext-devel wireless-tools-devel glibc-static libstdc++ libatomic_ops-devel
    • Install Python 3.x : Instructions for building Python 3.x can be found here.
  • RHEL (7.4, 7.5, 7.6)

    sudo yum install -y libicu-devel libcurl-devel wget tar m4 pkgconfig make libtool which gcc-c++ gcc openssl openssl-devel patch js-devel java-1.8.0-openjdk-devel perl-devel gettext-devel unixODBC-devel
    • Install Python 3.x : Instructions for building Python 3.x can be found here.
  • SLES 12 SP3

    sudo zypper install -y java-1_8_0-openjdk-devel autoconf213 curl wget git tar make patch perl m4 which python python3 gcc gcc gcc-c++ libopenssl-devel ncurses-devel libicu-devel unixODBC-devel libtool cvs mercurial zip gtk2-devel libXt-devel libidl-devel freetype2-devel fontconfig-devel pkg-config dbus-1-glib-devel Mesa-devel libcurl-devel libnotify-devel alsa-devel libiw-devel  yasm
    sudo easy_install pip
  • SLES 15

    sudo zypper install -y java-1_8_0-openjdk-devel curl wget git tar make patch perl m4 which python2 python3 python3-pip gcc gcc-c++ libopenssl-devel ncurses-devel libicu-devel unixODBC-devel libtool cvs mercurial zip gtk2-devel libXt-devel libidl-devel freetype2-devel fontconfig-devel pkg-config dbus-1-glib-devel Mesa-devel libcurl-devel libnotify-devel alsa-devel libiw-devel yasm
    • Install gcc 4.9.4
      cd /<source_root>/
      wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-4.9.4/gcc-4.9.4.tar.gz  
      tar -xvzf gcc-4.9.4.tar.gz 
      cd gcc-4.9.4/
      ./contrib/download_prerequisites
      cd /<source_root>/
      mkdir gccbuild
      cd gccbuild/
      ../gcc-4.9.4/configure --prefix=$HOME/install/gcc-4.9.4 --enable-checking=release --enable-languages=c,c++ --disable-multilib
      make
      sudo make install
      export PATH=$HOME/install/gcc-4.9.4/bin:$PATH
      gcc --version
    • Install autoconf 2.13
      cd /<source_root>/
      wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz
      tar -xvzf autoconf-2.13.tar.gz
      cd autoconf-2.13/
      ./configure --prefix=/usr --program-suffix=2.13
      make
      sudo make install
  • Ubuntu 16.04

    sudo apt-get update
    sudo apt-get install -y build-essential pkg-config erlang erlang-dev erlang-reltool gcc python3 python3-pip python3-venv curl git patch wget tar make autoconf automake autoconf g++ libmozjs185-dev libicu-dev libcurl4-openssl-dev
  • Ubuntu 18.04

    sudo apt-get update
    sudo apt-get install -y build-essential pkg-config erlang erlang-dev erlang-reltool ncurses-base g++-5 gcc-5 python python3 python3-pip python3-venv curl git patch wget tar make zip autoconf2.13 automake libicu-dev libcurl4-openssl-dev libncurses5-dev
    
    sudo rm -rf /usr/bin/gcc /usr/bin/g++ /usr/bin/cc
    sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc
    sudo ln -s /usr/bin/g++-5 /usr/bin/g++
    sudo ln -s /usr/bin/gcc /usr/bin/cc

1.2) Install git 2.16.0 (Only for RHEL)

cd /<source_root>/
wget https://github.com/git/git/archive/v2.16.0.tar.gz
tar -zxf v2.16.0.tar.gz
cd git-2.16.0
make configure
./configure --prefix=/usr
make
sudo make install

1.3) Install Erlang 21.0 (Only for RHEL and SLES)

cd /<source_root>/
wget http://www.erlang.org/download/otp_src_21.0.tar.gz
tar zxf otp_src_21.0.tar.gz
cd otp_src_21.0
export ERL_TOP=/<source_root>/otp_src_21.0
./configure --prefix=/usr
make
sudo make install

1.4) Install SpiderMonkey 1.8.5 (Only for RHEL 6.10, SLES and Ubuntu 18.04)

  • Obtain the SpiderMonkey and extract the source

    cd /<source_root>/
    wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
    tar zxf js185-1.0.0.tar.gz
    cd js-1.8.5
  • Create a patch file patch_jsval.diff with the following contents:

--- js/src/jsval.h.oldfile       2018-10-26 05:48:18.070870770 +0000
+++ js/src/jsval.h.newfile       2018-10-26 06:15:34.480870770 +0000
@@ -306,11 +306,11 @@
             int32          i32;
             uint32         u32;
             JSWhyMagic     why;
-            jsuword        word;
         } payload;
     } s;
     double asDouble;
     void *asPtr;
+    jsuword asWord;
 } jsval_layout;
 # endif  /* JS_BITS_PER_WORD */
 #else   /* defined(IS_LITTLE_ENDIAN) */
@@ -320,6 +320,7 @@
     uint64 asBits;
     struct {
         JSValueTag tag;
+        uint32 padding;
         union {
             int32          i32;
             uint32         u32;
@@ -343,6 +344,7 @@
         uint64             payload47 : 47;
     } debugView;
     struct {
+        uint32 padding;
         union {
             int32          i32;
             uint32         u32;
@@ -351,6 +353,7 @@
     } s;
     double asDouble;
     void *asPtr;
+    jsuword asWord;
 } jsval_layout;
 # endif /* JS_BITS_PER_WORD */
 #endif  /* defined(IS_LITTLE_ENDIAN) */

Apply patch using command mention below:

patch js/src/jsval.h < patch_jsval.diff
  • Create a patch file patch_jsvalue.diff with the following contents:
--- js/src/jsvalue.h.oldfile    2018-10-26 06:17:11.940870770 +0000
+++ js/src/jsvalue.h.newfile    2018-10-26 06:31:01.660870770 +0000
@@ -291,7 +291,6 @@
 }

 #ifdef __cplusplus
-JS_STATIC_ASSERT(offsetof(jsval_layout, s.payload) == 0);
 JS_STATIC_ASSERT((JSVAL_TYPE_NONFUNOBJ & 0xF) == JSVAL_TYPE_OBJECT);
 JS_STATIC_ASSERT((JSVAL_TYPE_FUNOBJ & 0xF) == JSVAL_TYPE_OBJECT);
 #endif
@@ -729,7 +728,11 @@
     }

     const jsuword *payloadWord() const {
-        return &data.s.payload.word;
+         #if JS_BITS_PER_WORD == 32
+          return reinterpret_cast<const jsuword *>(&data.s.payload.word);
+         #elif JS_BITS_PER_WORD == 64
+          return reinterpret_cast<const jsuword *>(&data.asBits);
+         #endif
     }

   private:

Apply patch using command mention below:

patch js/src/jsvalue.h < patch_jsvalue.diff
  • Create a patch file patch_makein.diff with the following contents:
--- js/src/Makefile.in.oldfile  2018-10-29 03:18:23.360870770 -0400
+++ js/src/Makefile.in.newfile  2018-10-29 03:19:14.010870770 -0400
@@ -382,7 +382,7 @@
 # END enclude sources for V8 dtoa
 #############################################

-ifeq (,$(filter-out powerpc sparc,$(TARGET_CPU)))
+ifeq (,$(filter arm %86 x86_64,$(TARGET_CPU)))

 VPATH +=       $(srcdir)/assembler \
                $(srcdir)/assembler/wtf \

Apply patch using command mention below:

patch js/src/Makefile.in < patch_makein.diff
  • Prepare the source code

    cd /<source_root>/js-1.8.5/js/src
    autoconf-2.13                 # For RHEL 6.10 and SLES 12 SP3
    autoconf2.13                  # For SLES 15 and Ubuntu 18.04
  • Configure, build & install SpiderMonkey

    mkdir /<source_root>/js-1.8.5/js/src/build_OPT.OBJ
    cd /<source_root>/js-1.8.5/js/src/build_OPT.OBJ
    ../configure --prefix=/usr
    make
    sudo make install

1.6) Download the CouchDB source code

cd /<source_root>/
git clone https://github.com/apache/couchdb.git
cd couchdb
git checkout 2.3.0

1.7) Configure and build CouchDB

./configure -c --disable-docs --disable-fauxton
export LD_LIBRARY_PATH=/usr/lib
make

Step 2: Testing (Optional)

2.1) Run all test cases

make check

Notes:

  • Three test case failures from module test/couch_compress_tests.erl at Line 35,49 & 51 are observed, due to snappy behavior on Z System. Modify the file as shown below to pass the test cases:

    Create a patch file patch_couch.diff with the following contents:

    --- src/couch/test/couch_compress_tests.erl.oldfile     2018-10-26 06:39:25.730870770 +0000
    +++ src/couch/test/couch_compress_tests.erl.newfile     2018-10-26 06:41:26.500870770 +0000
    @@ -22,8 +22,8 @@
     -define(DEFLATE, <<131,80,0,0,0,48,120,218,203,96,204,97,96,
         96,96,205,96,74,97,96,76,76,100,4,211,73,137,76,96,58,57,
         145,25,76,167,36,178,128,233,212,68,214,44,0,212,169,9,51>>).
    --define(SNAPPY, <<1,49,64,131,104,1,108,0,0,0,5,104,2,100,0,
    -    1,97,97,1,104,1,8,8,98,97,2,5,8,8,99,97,3,5,8,44,100,97,
    +-define(SNAPPY, <<1,49,60,131,104,1,108,0,0,0,5,104,2,100,0,
    +    1,97,97,1,5,8,8,98,97,2,5,8,8,99,97,3,5,8,44,100,97,
         4,104,2,100,0,1,101,97,5,106>>).
     -define(CORRUPT, <<2,12,85,06>>).

    Apply patch using command mention below:

    patch src/couch/test/couch_compress_tests.erl < patch_couch.diff
    

2.2) Start the CouchDB server

sudo /<source_root>/couchdb/dev/run &

2.3) Verify the output of CouchDB server by using curl http://127.0.0.1:15984/ command. The output should be similar to the following:

{"couchdb":"Welcome","version":"2.3.0","git_sha":"07ea0c7","uuid":"fake_uuid_for_dev","features":["pluggable-storage-engines","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}

References:

CouchDB 2.3.0 Documentation

Clone this wiki locally