Press "Enter" to skip to content

Installing the CMDBuild ITSM system in Centos 7

CMDBuild is open source software that manages database configuration. CMDBuild has been designed according to ITIL “best practice” for IT management services, responding to process oriented criteria.
Software used
CentOS 7.7 1908 Minimal
PostgreSQL 10.12
OpenJDK 13.0.2
Tomcat 9.0.31
CMDBuild 3.2

Training

Let’s update and install the EPEL repository and the necessary software

$ sudo yum update
$ sudo yum -y install epel-release
$ sudo yum -y install wget nano

Install PostgreSQL 10

Add the repository

$ sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Install PostgreSQL

$ sudo yum -y install postgresql10 postgresql10-server postgresql10-contrib postgresql10-libs
We initialize the database

$ sudo /usr/pgsql-10/bin/postgresql-10-setup initdb
Configuring access to the PostgreSQL database

$ sudo nano /var/lib/pgsql/10/data/pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
Add PostgreSQL to startup and start the service

$ sudo systemctl enable --now postgresql-10
Create base / users

$ sudo su - postgres
-bash-4.2$ psql
postgres=# CREATE DATABASE cmdbuild_db;
postgres=# CREATE USER cmdbuild_user WITH encrypted password 'password';
postgres=# GRANT ALL PRIVILEGES ON DATABASE cmdbuild_db TO cmdbuild_user;
postgres=# DROP DATABASE cmdbuild_db;
postgres=# CREATE USER cmdbuild_superuser WITH encrypted password 'password';
postgres=# ALTER USER cmdbuild_superuser WITH SUPERUSER;
postgres=# q
-bash-4.2$ exit

The base was removed on purpose, since later it will be created by the installation script

Installing OpenJDK 13 and Tomcat 9

tomcat一定不能以root用户启动,一定要用普通用户启动,不然会报错!!!

Install OpenJDK latest (13.0.2)

$ sudo yum -y install java-latest-openjdk java-latest-openjdk-devel
$ java --version
Create a Tomcat system user

$ sudo useradd -m -U -d /opt/tomcat -s /bin/false tomcat
Download the Tomcat 9.0.31 archive and unpack it

$ cd /tmp
$ wget http://apache-mirror.rbc.ru/pub/apache/tomcat/tomcat-9/v9.0.31/bin/apache-tomcat-9.0.31.tar.gz
$ tar -xf apache-tomcat-9.0.31.tar.gz
$ sudo mv apache-tomcat-9.0.31 /opt/tomcat/
Create a symlink, change the owner of directories and make bash scripts executable

$ sudo ln -s /opt/tomcat/apache-tomcat-9.0.31 /opt/tomcat/latest
$ sudo chown -R tomcat:tomcat /opt/tomcat
$ sudo sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh'
Create a systemd Unit

$ sudo nano /etc/systemd/system/tomcat.service
[Unit]
Description=Tomcat 9 servlet container
After=network.target

[Service]
Type=forking

User=tomcat
Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/jre"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"

Environment="CATALINA_BASE=/opt/tomcat/latest"
Environment="CATALINA_HOME=/opt/tomcat/latest"
Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

ExecStart=/opt/tomcat/latest/bin/startup.sh
ExecStop=/opt/tomcat/latest/bin/shutdown.sh

[Install]
WantedBy=multi-user.target
Add Tomcat to startup and start the service

$ sudo systemctl daemon-reload
$ sudo systemctl enable --now tomcat
$ sudo systemctl status tomcat

Configuring Firewall

Opening port 8080

$ sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp
$ sudo firewall-cmd --reload

Configuring access to Tomcat Web Management Interface

Editing the file conf / tomcat-users.xml, set the login / password

$ sudo nano /opt/tomcat/latest/conf/tomcat-users.xml
...
   <role rolename="admin-gui"/>
   <role rolename="manager-gui"/>
   <user username="admin" password="admin_password" roles="admin-gui,manager-gui"/>
</tomcat-users>
Editing the file manager / META-INF / context.xml, add IP

$ sudo nano /opt/tomcat/latest/webapps/manager/META-INF/context.xml
...
<Context antiResourceLocking="false" privileged="true" >
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127.d+.d+.d+|::1|0:0:0:0:0:0:0:1|10.0.2.2" />
</Context>
Editing the file host-manager / META-INF / context.xml, add IP

$ sudo nano /opt/tomcat/latest/webapps/host-manager/META-INF/context.xml
...
<Context antiResourceLocking="false" privileged="true" >
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127.d+.d+.d+|::1|0:0:0:0:0:0:0:1|10.0.2.2" />
</Context>
where 10.0.2.2 is the allowed IP (virtualbox host)

Or in these 2 files context.xml (manager / host-manager) comment out the line

<!--
<Valve className="org.apache.catalina.valves.RemoteAddrValve" ... />
-->
You can also remove the default applications, but I left them

$ sudo rm -rf /opt/tomcat/latest/webapps/*

Installing CMDBuild 3.2

Download the cmdbuild.war file and copy it to the Tomcat directory

$ cd /tmp
$ wget -O cmdbuild-3.2.war https://sourceforge.net/projects/cmdbuild/files/3.2/cmdbuild-3.2.war/download?use_mirror=netcologne#
$ sudo cp /tmp/cmdbuild-3.2.war /opt/tomcat/latest/webapps/cmdbuild.war
$ sudo chown tomcat:tomcat /opt/tomcat/latest/webapps/cmdbuild.war
Configuring a connection to the PostgreSQL database

$ sudo mkdir -p /opt/tomcat/latest/conf/cmdbuild
$ sudo nano /opt/tomcat/latest/conf/cmdbuild/database.conf
db.url=jdbc:postgresql://localhost:5432/cmdbuild_db
db.username=cmdbuild_user
db.password=password
db.admin.username=cmdbuild_superuser
db.admin.password=password
Change owner

$ sudo chown -R tomcat:tomcat /opt/tomcat/latest/conf/cmdbuild
Downloading add. libraries, copy them to the Tomcat directory, change the owner

$ cd /tmp
$ wget -O cmdbuild-3.2-resources.tar.gz https://sourceforge.net/projects/cmdbuild/files/3.2/cmdbuild-3.2-resources.tar.gz/download#
$ tar -xzf /tmp/cmdbuild-3.2-resources.tar.gz
$ sudo cp /tmp/tomcat-libs/postgresql-*.jar /opt/tomcat/latest/lib/
$ sudo chown -R tomcat:tomcat /opt/tomcat/latest/lib
We create the base structure

$ sudo systemctl stop tomcat
$ sudo chmod +x /opt/tomcat/latest/webapps/cmdbuild/cmdbuild.sh
$ sudo bash /opt/tomcat/latest/webapps/cmdbuild/cmdbuild.sh dbconfig create empty -configfile /opt/tomcat/latest/conf/cmdbuild/database.conf
$ sudo systemctl restart tomcat
If you need to download demo data:

$ sudo bash /opt/tomcat/latest/webapps/cmdbuild/cmdbuild.sh dbconfig create demo -configfile /opt/tomcat/latest/conf/cmdbuild/database.conf
after removing the base

postgres=# DROP DATABASE cmdbuild_db;
We check:

http://localhost:8080/cmdbuild
User: admin 
Password: admin

注:本文转自https://codepre.com/installing-the-cmdbuild-itsm-system-in-centos-7.html

Be First to Comment

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注