CMDBuild 3.1.1 on Centos 7

This is not so different from the previous article:

Only real difference is that this is not going to work if you deploy the webapp as webaps/ROOT.war. You have instead, to deploy it as /webapps/cmdbuild.

Install Postgresql first.

The following is the installation script for postgresql and it has to be installed before running the tomcat/cmdbuild install script.

As you can see, at the beginnning of the script there are some variables to set. Just keep in mind that usernames and password used in this first script, must then match the ones in the second script: basically the postgresql accounts that are used by cmdbuild.
The user cmdbuild_super_user will be used during the installation to create the database and perform other operations on it, while the other user (cmdbuild_user_name) is used by tomcat and the webapp for regular db usage.

#!/usr/bin/env bash

install_folder="/usr/share/"       #  C
cmdbuild_user_name="cmdbuild"      #  O
cmdbuild_user_pass="cmdbuild"      #  N
cmdbuild_super_user="scmdbuild"    #  F
cmdbuild_super_pass="scmdbuild"    #  I
sql_queries_path="/var/tmp/"       #  G
cmdbuild_sql_file="cmdbuild.sql"   #  !
scmdbuild_sql_file="scmdbuild.sql" #  @
cmdbuild_db_name="cmdbuild"        #  @
postgresql_version="96"            #

#cd ${sql_queries_path}

yum -y install centos-release-scl
yum -y install rh-postgresql${postgresql_version}-postgresql-server rh-postgresql${postgresql_version}-postgresql
#yum -y install rh-postgresql${postgresql_version}-syspaths.x86_64

su - postgres --command ". /opt/rh/rh-postgresql96/enable;  postgresql-setup --initdb"
systemctl enable rh-postgresql${postgresql_version}-postgresql.service
systemctl start rh-postgresql${postgresql_version}-postgresql.service

firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --reload

echo -e "CREATE DATABASE ${cmdbuild_db_name};" > ${sql_queries_path}/${cmdbuild_sql_file}
echo -e "CREATE USER ${cmdbuild_user_name} WITH encrypted password '"${cmdbuild_user_pass}"';" >> ${sql_queries_path}/${cmdbuild_sql_file}
echo -e "GRANT ALL PRIVILEGES ON DATABASE ${cmdbuild_db_name} TO ${cmdbuild_user_name};" >> ${sql_queries_path}/${cmdbuild_sql_file}
echo -e "DROP DATABASE ${cmdbuild_db_name};" >> ${sql_queries_path}/${cmdbuild_sql_file}
echo -e "CREATE USER ${cmdbuild_super_user} WITH encrypted password '"${cmdbuild_super_pass}"';" > ${sql_queries_path}/${scmdbuild_sql_file}
echo -e "ALTER USER ${cmdbuild_super_user} WITH SUPERUSER;" >> ${sql_queries_path}/${scmdbuild_sql_file}

su - postgres --command ". /opt/rh/rh-postgresql96/enable; psql --file=${sql_queries_path}/${cmdbuild_sql_file}"
su - postgres --command ". /opt/rh/rh-postgresql96/enable; psql --file=${sql_queries_path}/${scmdbuild_sql_file}"

#rm -rf ${sql_queries_path}/${cmdbuild_sql_file}
#rm -rf ${sql_queries_path}/${scmdbuild_sql_file}

# Backup original config files
cp -pr /var/opt/rh/rh-postgresql${postgresql_version}/lib/pgsql/data/pg_hba.conf /var/opt/rh/rh-postgresql${postgresql_version}/lib/pgsql/data/pg_hba.conf.orig
cp -pr /var/opt/rh/rh-postgresql${postgresql_version}/lib/pgsql/data/postgresql.conf /var/opt/rh/rh-postgresql${postgresql_version}/lib/pgsql/data/postgresql.conf.orig

sed -i 's/# IPv4 local connections:/# IPv4 local connections:\n host         all         all\/0       md5/g' /var/opt/rh/rh-postgresql${postgresql_version}/lib/pgsql/data/pg_hba.conf
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = ''/g" /var/opt/rh/rh-postgresql${postgresql_version}/lib/pgsql/data/postgresql.conf

#ln -s /opt/rh/rh-postgresql${postgresql_version}/root/usr/lib64/${postgresql_version}-5.9 /opt/rh/rh-postgresql${postgresql_version}/root/usr/lib64/
#ln -s /opt/rh/rh-postgresql${postgresql_version}/root/usr/lib64/ /usr/lib64/

systemctl restart rh-postgresql${postgresql_version}-postgresql.service

Here it goes the latest version of the install script, both for postgres and for cmdbuild/tomcat.

Script for tomcat/cmdbuild.

Please remember to check that the version of tomcat is available. For example try to open in your browser: and check the version available matches tha one in the configuration of this script: look for variable called: “tomcat_version”. This said you only need to chmod +x the script and run it.

#!/usr/bin/env bash
set -x

yum -y update
yum -y install nc wget centos-release-scl java-${java_version}-openjdk.x86_64 rh-postgresql${postgres_version}-postgresql rh-postgresql${postgres_version}-syspaths.x86_64

firewall-cmd --permanent --add-port=22/tcp
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --permanent --add-port=7800/tcp # <-- For Jgroup
firewall-cmd --permanent --add-port=8009/tcp # <-- For AJP
firewall-cmd --reload

# I think the following is a fix for some of the consequences of using software colection. IMHO you should use centos8 if you need centos8
# First remove crap from other versions (true story)
#rm -rfv /opt/rh/rh-postgresql${postgres_version}/root/usr/lib64/*
#rm -rfv /usr/lib64/*
ln -s /opt/rh/rh-postgresql${postgres_version}/root/usr/lib64/ /opt/rh/rh-postgresql${postgres_version}/root/usr/lib64/
ln -s /opt/rh/rh-postgresql${postgres_version}/root/usr/lib64/ /usr/lib64/

nc -z ${postgresql_server} 5432 > /dev/null
if [ $? -eq 0 ]; then
    echo -e "Test tcp connection to the db suceeded"
    echo -e "The connection to the database ${database_name} to the server ${postgresql_server} didn't work, please check the config."
    exit 1

groupadd ${tomcat_group}
useradd -M -s /sbin/nologin -g ${tomcat_group} -d ${install_folder}/tomcat ${tomcat_user}

cd ~
wget -O /var/tmp/apache-tomcat-${tomcat_version}.tar.gz${tomcat_version}/bin/apache-tomcat-${tomcat_version}.tar.gz
mkdir -p ${install_folder}/tomcat
tar -xzf /var/tmp/apache-tomcat-${tomcat_version}.tar.gz -C ${install_folder}/tomcat --strip-components=1
chgrp -R ${tomcat_user} ${install_folder}/tomcat
chmod -R g+r ${install_folder}/tomcat/conf/*
chmod g+rx ${install_folder}/tomcat/conf
chown -R ${tomcat_user} ${install_folder}/tomcat/logs/
chmod -R g+w ${install_folder}/tomcat/work
chmod -R g+w ${install_folder}/tomcat/temp
chmod -R g+w ${install_folder}/tomcat/logs
chmod -R g+r ${install_folder}/tomcat/conf
chmod -R g+w ${install_folder}/tomcat/webapps

# Systemd
cat > /etc/systemd/system/tomcat.service <<EOF
# Systemd unit file for tomcat
Description=Apache Tomcat Web Application Container
Environment='CATALINA_OPTS=-Xms512M -Xmx1536M -XX:MaxPermSize=256M -server -XX:+UseParallelGC -Dfile.encoding=UTF8'
ExecStop=/bin/kill -15 \$MAINPID
systemctl daemon-reload
systemctl start tomcat
systemctl enable tomcat
systemctl stop tomcat

rm -rf ${install_folder}/tomcat/webapps/*

#Download cmdbuild
mkdir -p /var/tmp/f
mkdir -p ${install_folder}/tomcat/webapps
chmod g+w ${install_folder}/tomcat/webapps
cd /var/tmp/f
if ! [[ -f /var/tmp/cmdbuild-${cmdbuild_version}.war ]]; then
    wget -O /var/tmp/cmdbuild-${cmdbuild_version}.war${cmdbuild_version}/cmdbuild-${cmdbuild_version}.war/download?use_mirror=netcologne#
if ! [[ -f /var/tmp/f/cmdbuild-${cmdbuild_version}-resources.tar.gz ]]; then
  wget -O /var/tmp/f/cmdbuild-${cmdbuild_version}-resources.tar.gz${cmdbuild_version}/cmdbuild-${cmdbuild_version}-resources.tar.gz/download#
cp /var/tmp/cmdbuild-${cmdbuild_version}.war ${install_folder}/tomcat/webapps/cmdbuild.war
systemctl start tomcat
sleep 20
systemctl stop tomcat

mkdir -p ${install_folder}/tomcat/conf/cmdbuild

cat <<EOF > "${install_folder}"/tomcat/conf/cmdbuild/database.conf

chown ${tomcat_user}. ${install_folder}/tomcat/conf/cmdbuild/database.conf

cd /var/tmp/f
tar -xzf /var/tmp/f/cmdbuild-${cmdbuild_version}-resources.tar.gz
cp /var/tmp/f/tomcat-libs/postgresql-*.jar ${install_folder}/tomcat/lib/
chown ${tomcat_user}. ${install_folder}/tomcat/lib/postgresql-*.jar

systemctl stop tomcat
chmod +x ${install_folder}/tomcat/webapps/cmdbuild/
bash ${install_folder}/tomcat/webapps/cmdbuild/ dbconfig create empty -configfile ${install_folder}/tomcat/conf/cmdbuild/database.conf
systemctl start tomcat

Let me know how it goes.

(Visited 145 times, 1 visits today)

Author: Giuseppe Urso

Giuseppe lives in Haarlem now with his shiny dog, Filippa In 1982 received his first home computer, a Commodore 64, followed by Datasette and a 1541 Floppy Disk Drive. In 1999 he installed his first Linux distro (LRH6). In 2006 he switched to Debian as favourite OS. Giuseppe Urso actively sustains the Free Software Fundation and his founder Richard Mattew Stallman, he speaks to people trying to convince them to join the fight now, and about how important is to use Free Software only. He has a job as Infra Specialist at Hippo Enterprise Java Cms an Open Source Enterprise class Content Management System, one of the coolest company ever, in Amsterdam. He's always ready to install Debian on other people computers for free.

2 thoughts on “CMDBuild 3.1.1 on Centos 7”

  1. Hi, I followed your script and proceeded it step by step. at last step, I got a serial of errors. begin with ‘create database cmdbuild empty
    Exception in thread “main” org.cmdbuild.dao.DaoException; Error while configuring the database
    I started the tomcat service, but when i filled and execute. http://localhost:8080/cmdbuild will re-routed to http://localhost:8080/cmdbuild/ui/#patches. then I saw many patches listed in the page. i clicked ‘apply’. then loading and another error shows up, begin with ‘org.cmdbuild.dao.DaoException: error processing patch = Patch{version=1.0.3-01,category=core,applied=false}……, i can’t proceed.
    Would you please help?

    1. Hi, could you share more info about the error?
      I would check the credentials and permissions on the db for cmdbuild_super_user.
      Can you actually log in to Postgresql and create a db with the credentials you are using?


Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.