Skip to content

Building CouchDB

linuxonz edited this page Jan 12, 2024 · 45 revisions

Building CouchDB

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

  • RHEL (7.8, 7.9)

On RHEL (8.x, 9.x) and Ubuntu (20.04, 22.04), binary packages for CouchDB version 3.3.3 are available and can be installed using steps given here

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 : Build 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.3.3/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>
sudo yum install -y libicu-devel libcurl-devel wget tar m4 pkgconfig make libtool which rh-git227-git.s390x gcc-c++ gcc openssl-devel patch js-devel java-11-openjdk-devel perl-devel gettext-devel unixODBC-devel python3-devel ncurses-devel procps-ng
#Enable git 2.27
source /opt/rh/rh-git227/enable

1.3) Install needed python packages

sudo pip3 install --upgrade wheel sphinx==5.3.0 sphinx_rtd_theme docutils==0.17 nose requests hypothesis virtualenv jinja2

1.4) Install Erlang

cd $SOURCE_ROOT
wget https://github.com/erlang/otp/releases/download/OTP-24.3.4.10/otp_src_24.3.4.10.tar.gz
tar zxf otp_src_24.3.4.10.tar.gz
cd otp_src_24.3.4.10
export ERL_TOP="${SOURCE_ROOT}/otp_src_24.3.4.10"
./configure --prefix=/usr
make
sudo make install

1.5) Install Elixir

cd $SOURCE_ROOT
git clone https://github.com/elixir-lang/elixir.git
cd elixir
git checkout v1.13.4
export LANG=en_US.UTF-8 
make
sudo make install
elixir -v

1.6) Install Node.js and NPM

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

1.7) Install chromedriver v105.0.0

cd $SOURCE_ROOT
git clone -b 105.0.0 https://github.com/giggio/node-chromedriver.git
cd node-chromedriver
sed -i "s#process.arch === 'arm64' || process.arch === 'x64'#process.arch === 'arm64' || process.arch === 's390x' || process.arch === 'x64'#g" install.js
npm ci
npm pack

1.8) Download the CouchDB source code

cd $SOURCE_ROOT
git clone -b 3.3.3 https://github.com/apache/couchdb.git

1.9) Build CouchDB

cd $SOURCE_ROOT/couchdb
export LD_LIBRARY_PATH=/usr/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
./configure
cd src/fauxton/
npm i $SOURCE_ROOT/node-chromedriver/chromedriver-105.0.0.tgz
cd ../../
make release

1.10) Add user to CouchDB group

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

1.11) Copy couchdb folder to default location

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

1.12) Add Permissions

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

1.13) 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

cd "${SOURCE_ROOT}"/couchdb
make check

All tests should pass.

2.2) Start the CouchDB server

/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.3.3","git_sha":"40afbcf","uuid":"27f2fbbab3e00326314af161c525677d","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
  • To load Fauxton web UI in your browser, visit http://127.0.0.1:5984/_utils/

Note: To connect to 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