Skip to content

Building CouchDB

aborkar-ibm edited this page Nov 17, 2021 · 45 revisions

Building CouchDB

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

  • RHEL (7.8, 7.9, 8.2, 8.4)
  • Ubuntu (18.04, 20.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) Build using script

If you'd like to build CouchDB using the manual steps, please go to STEP 1.2.

Use the following commands to build CouchDB using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/CouchDB/3.2.0/build_couchdb.sh

# Build CouchDB
bash build_couchdb.sh   [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 2.2. In case of any errors, check logs for more details or go to STEP 1.2 to follow the manual build steps.

1.2) Install dependencies

export SOURCE_ROOT=/<source_root>
  • RHEL (7.8, 7.9)

    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 fop bzip2-devel gdbm-devel libdb-devel libffi-devel libuuid-devel ncurses-devel readline-devel sqlite-devel tk-devel xz xz-devel zlib-devel
  • RHEL (8.2, 8.4)

    sudo yum install -y autoconf flex flex-devel gawk gzip hostname libxml2-devel libxslt libicu-devel libcurl-devel wget tar m4 pkgconfig make libtool which gcc-c++ gcc openssl openssl-devel patch mozjs60-devel java-1.8.0-openjdk-devel perl-devel gettext-devel unixODBC-devel python38 python38-devel git ncurses-devel glibc-common

    Note:

    • Make sure to install at least mozjs60-devel-60.9.0-4 otherwise some of the tests will fail due to some bugs on s390x in earlier releases.
  • Ubuntu 18.04

    sudo apt-get update
    sudo apt-get install -y build-essential pkg-config ncurses-base g++-5 gcc-5 python python3 python3-pip python3-venv python3-markupsafe hostname curl git patch wget tar make zip autoconf2.13 automake libicu-dev libcurl4-openssl-dev libncurses5-dev locales libncurses-dev libssl-dev unixodbc-dev libwxgtk3.0-dev openjdk-8-jdk xsltproc fop libxml2-utils
    
    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
  • Ubuntu 20.04

    sudo apt-get update
    sudo apt-get install -y build-essential pkg-config ncurses-base g++ gcc python python3 python3-pip python3-venv hostname curl git patch wget tar make zip libicu-dev libcurl4-openssl-dev libncurses5-dev locales libncurses-dev libssl-dev unixodbc-dev libwxgtk3.0-gtk3-dev openjdk-8-jdk xsltproc fop libxml2-utils libmozjs-68-dev

1.3) Install git 2.16.0 (Only for RHEL 7.x)

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.4) Install python 3.8 (Only for RHEL 7.X)

wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
tar -xzf Python-3.8.2.tgz
cd Python-3.8.2
./configure --prefix=/usr --exec-prefix=/usr
make
sudo make install

1.5) Install needed python packages

sudo pip3 install --upgrade wheel sphinx==3.5.4 sphinx_rtd_theme docutils==0.16 nose requests hypothesis virtualenv

1.6) Install Erlang

cd $SOURCE_ROOT
wget http://www.erlang.org/download/otp_src_22.2.tar.gz
tar zxf otp_src_22.2.tar.gz
cd otp_src_22.2
export ERL_TOP=$SOURCE_ROOT/otp_src_22.2
./configure --prefix=/usr
make
sudo make install

1.7) Install elixir

cd $SOURCE_ROOT
git clone https://github.com/elixir-lang/elixir.git
cd elixir
git checkout v1.10.2
export LANG=en_US.UTF-8 
sudo locale-gen en_US.UTF-8  # for Ubuntu
make
sudo make install
elixir -v

1.8) Install node and npm

cd $SOURCE_ROOT
sudo mkdir -p /usr/local/lib/nodejs
wget https://nodejs.org/dist/v14.2.0/node-v14.2.0-linux-s390x.tar.gz
sudo tar xzvf node-v14.2.0-linux-s390x.tar.gz -C /usr/local/lib/nodejs
sudo ln -s /usr/local/lib/nodejs/node-v14.2.0-linux-s390x/bin/* /usr/bin/
node -v
npm -v

1.9) Install SpiderMonkey 1.8.5 from source (Only for Ubuntu 18.04)

  • Get the source, extract it, and patch with needed changes.

    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
    export PATCH_URL="https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/CouchDB/3.2.0/patch"
    curl -o jsval.h.diff $PATCH_URL/jsval.h.diff
    patch "$SOURCE_ROOT/js-1.8.5/js/src/jsval.h" jsval.h.diff
    curl -o jsvalue.h.diff $PATCH_URL/jsvalue.h.diff
    patch "$SOURCE_ROOT/js-1.8.5/js/src/jsvalue.h" jsvalue.h.diff
    curl -o Makefile.in.diff $PATCH_URL/Makefile.in.diff
    patch "$SOURCE_ROOT/js-1.8.5/js/src/Makefile.in" Makefile.in.diff
  • Prepare the source code

    cd $SOURCE_ROOT/js-1.8.5/js/src
    autoconf2.13
  • 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.10) Download the CouchDB source code

cd $SOURCE_ROOT
git clone https://github.com/apache/couchdb.git
cd couchdb
git checkout 3.2.0

1.11) Build CouchDB

cd $SOURCE_ROOT/couchdb
export LD_LIBRARY_PATH=/usr/lib
  • Ubuntu 20.04

    ./configure  --spidermonkey-version 68
    make release
  • RHEL (8.2, 8.4)

    ./configure  --spidermonkey-version 60
    make release
  • Everything else

    ./configure 
    make release

1.12) Add user to CouchDB group

sudo groupadd couchdb 
sudo usermod -aG couchdb $(whoami)

1.13) Copy couchdb folder to default location

sudo cp -r "${SOURCE_ROOT}/couchdb/rel/couchdb" /opt/

1.14) Add Permissions

sudo chown "$(whoami)":couchdb -R /opt/couchdb
sudo find /opt/couchdb -type d -exec chmod 0770 {} \;
chmod 0644 /opt/couchdb/etc/*

1.15) Create Admin user

sed -i 's/;admin = mysecretpassword/admin = mysecretpassword/' /opt/couchdb/etc/local.ini

Step 2: Testing (Optional)

2.1) Run all test cases

  • Reconfigure for testing. Make sure to append the correct spidermonkey version flag as well if needed.
cd $SOURCE_ROOT/couchdb
  • Ubuntu 20.04
./configure -c  --prefix=/usr --with-js-lib=/usr/lib --with-js-include=/usr/include/mozjs-68  --spidermonkey-version 68 
make check |& tee couchdb_test_results.log
  • RHEL (8.2, 8.4)
./configure -c  --prefix=/usr --with-js-lib=/usr/lib --with-js-include=/usr/include/mozjs-60  --spidermonkey-version 60
make check |& tee couchdb_test_results.log
  • Everything else
./configure -c
make check |& tee couchdb_test_results.log

2.2) Start the CouchDB server

/opt/couchdb/bin/couchdb &

Note: In case of an error /usr/bin/env: python3: No such file or directory on RHEL run command as sudo env PATH=$PATH /opt/couchdb/bin/couchdb &

2.3) Make sure it's up and running

  • Verify that the server is up and running by using the curl http://127.0.0.1:5984/ command. The output should be similar to the following:
{"couchdb":"Welcome","version":"3.2.0","git_sha":"efb409b","uuid":"af6ddeaed4faa405eb35b95a5abb0cb6","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
  • To load Fauxton in your browser, visit:http://127.0.0.1:5984/_utils/ and log in with temporary credentials user:admin password:mysecretpassword.

Note: To Connect CouchDB From A Different Machine Stop your CouchDB server and edit the /opt/couchdb/etc/local.ini file. Change the bind_address from 127.0.0.1 to 0.0.0.0

References:

Clone this wiki locally