Deployment

elDoc deployment steps on CentOS 8 Linux / RedHat 8 Linux



Contents:


General assumptions

It is assumed that installation will be performed in the directory /local.

The folder structure is the following:

\local
|–-elDoc
|–-mongo
|–-mongoData
|–-java
|--tessData
|–-solr
|–-solrData

|–-mongoConnector
|--ooDocServer


1. Java installation

Steps below assume that you have downloaded Azul Zulu Java archive named zulu8.50.0.21-ca-jre8.0.272-linux_x64.tar.gz

1) Create directory and un-tar archive

mkdir /local/java && tar -xvzf zulu8.50.0.21-ca-jre8.0.272-linux_x64.tar.gz -C /local/java

ln -sfn /local/java/zulu8.50.0.21-ca-jre8.0.272-linux_x64/ /local/java/java_active


2. MongoDB installation

The steps below are shown based on the latest available version 4.4 of MongoDB at time of writing this guide.

2.1. Installation using yum repository manager (recommended)

Reference to the MongoDB website: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/

1) Create a repository config

nano /etc/yum.repos.d/mongodb-org-4.4.repo

[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

2) Install MongoDB packages

dnf install -y mongodb-org

3) Start MongoDB

IMPORTANT: before launching MongoDB process - make sure you have crated & configured mongodb via configuration file first (see below)

In order to enable and launch MongoDB service - execute the following command:

systemctl enable mongod && systemctl start mongod


2.2. Installation using tarball

1) Obtain the MongoDB tarball and extract it contents

tar -xvf mongodb-linux-x86_64-rhel80-4.4.2.tgz -C /local/

mv /local/mongodb-linux-x86_64-rhel80-4.4.2/ /local/mongo

2) Adjust limits after manual installation

Please review the MongoDB recommendations on adjusting the limits: https://docs.mongodb.com/manual/reference/ulimit/

3) Start MongoDB

IMPORTANT: before launching MongoDB process - make sure you have crated & configured mongodb via configuration file first (see below)

In order to launch MongoDB process manually - launch the following executable file:

/local/mongo/bin/mongod


2.3. Create & edit MongoDB configuration file

MongoDB configuration file should look similar to the one provided below.

nano /local/mongo/mongod.conf

systemLog:
  destination: file
  path: \local\mongo\mongod.log
  logAppend: true

storage:
  dbPath: \local\mongoData
  journal:
    enabled: true

processManagement:
  fork: true

net:
  bindIp: 0.0.0.0
  port: 27017

#security:
#  authorization: enabled  


2.4. Post-installation steps


2.5. Users creation

1) Launch MongoDB shell

To launch MongoDB shell execute the following command:

mongo

In case of manually deployed MongoDB - you may need to download and extract MongoDB Database Tools. Assuming that Database Tools were extracted to the MongoDB bin directory, you may launch MongoDB Shell manually executing the following command:

/local/mongo/bin/mongo

2) Create root user in MongoDB

use admin

db.createUser( {user: "root", pwd: "XXXXXXX", roles: [{role: "root", db: "admin"}]} )

3) Create elDoc application user (follow the pattern of the db-name as shown below)

use eldoc_cidXXX 

db.createUser( {user: "cidXXX", pwd: "ZZZZZZZ", roles: [{role: "dbOwner", db: "eldoc_cidXXX"}]} )

Where cidXXX is an id of the elDoc DB user. Make sure that cidXXX used during DB creation is the same as the one stated in the elDoc config file (eldoc.conf)

4) Securely write down logins, db-names and passwords

5) Enable MongoDB authentication

Open MongoDB configuration file and uncomment the following lines:

security:
  authorization: enabled  

6) Restart MongoDB service

systemctl restart mongod


3. elDoc dependencies installation & configuration

3.1. Installation of the IDP dependencies

1) Download and install TessData

mkdir /local/elDoc/tessData && cd /local/elDoc/tessData

wget -O tessdata_best-4.0.0.zip https://github.com/tesseract-ocr/tessdata_best/archive/4.0.0.zip

unzip tessdata\*.zip

ln -sfn /local/tessData/tessdata_best-4.0.0 /local/tessData/tessData_active


3.2. Installation of the full-text search service

NOTE: This component provides full-text search functionality and is optional for deployment

1) Install prerequisites

dnf install lsof

2) Download and extract Apache Solr software

mkdir /local/solr && mkdir /local/solrData && mkdir /local/solrData/data
tar -zxvf solr-8.7.0.tgz -C /local/solr
ln -sfn /local/solr/solr-8.7.0/ /local/solr/solr
cp /local/solr/solr/server/solr/solr.xml /local/solrData/data && cp /local/solr/solr/server/solr/zoo.cfg /local/solrData/data

3) Deploy provided Solr Core configuration

Copy eldoc_cidXXX.zip to /local/solrData/data and unpack archive:

wget https://dms-solutions.co/downloads/eldoc_cidXXX_elDoc-v5.0_Solr-v8.7.0.zip
cd /local/solrData/data
unzip eldoc_cidXXX_elDoc-v5.0_Solr-v8.7.0.zip

Rename eldoc_cidXXX folder according to the environment setup.

Adjust Solr Core config
nano /local/solrData/data/eldoc_cidXXX/core.properties

#Written by CorePropertiesLocator
name=eldoc_cidXXX

4) Create user for Solr service

groupadd solr
useradd -gsolr -s/bin/bash -M solr
chown -R solr:solr /local/solrData

5) Install Solr service

nano /etc/systemd/system/solr.service

solr.service
[Unit]
Description=Apache Solr
After=syslog.target network.target

[Service]
Type=forking
User=solr
Restart=on-failure
LimitNOFILE=65000
LimitNPROC=65000
Environment="SOLR_INSTALL_DIR=/local/solr/solr"
Environment="SOLR_PID_DIR=/local/solrData"
Environment="SOLR_HOME=/local/solrData/data"
Environment="LOG4J_PROPS=/local/solrData/log4j.properties"
Environment="SOLR_LOGS_DIR=/local/solrData/logs"
Environment="SOLR_PORT=8983"
PIDFile=/local/solrData/solr-8983.pid
WorkingDirectory=/local/solrData
ExecStart=/local/solr/solr/bin/solr start
ExecReload=/local/solr/solr/bin/solr restart
ExecStop=/local/solr/solr/bin/solr stop

[Install]
WantedBy=multi-user.target

6) Enable and launch Solr service

systemctl daemon-reload && systemctl enable solr.service && systemctl start solr.service


3.3. Installation of the sync-service

NOTE: This component provides data synchronization capabilities between MongoDB and full-text search service and required to be installed only in case full-text search service was installed.

1) Install Python

dnf install python3

2) mongo-connector and solr-doc-manager

Download latest available versions from the provided source.

wget https://dms-solutions.co/downloads/mongo-connector-3.2.0.zip

cd mongo-connector-X.Y.Z

pip3 install .

wget https://dms-solutions.co/downloads/solr-doc-manager-0.1.3.zip

cd solr-doc-manager-X.Y.Z

pip3 install .

3) Create user and group for running synch service

groupadd moncon

useradd -gmoncon -s/bin/bash -M moncon

4) Enable MongoDB replication

nano /etc/mongod.conf

replication
  replSetName: rs0

Restart MongoDB after adjusting configuration, then login to the MongoDB shell and initialize replication and create user for synch service:

mongo
use admin
db.auth("root", "YYYYYYYYYYYY")
rs.initiate()
db.createUser( {user: "moncon", pwd: "XXXXXXXXXXX", roles: ["backup"]} )

Securely write down created user credentials

5) Create sync service base folder

mkdir /local/mongoConnector && mkdir /local/mongoConnector/eldoc_cidXXX

Edit sync service configuration:

nano /local/mongoConnector/eldoc_cidXXX/mongo-connector.json

mongo-connector.json
{
    "mainAddress": "localhost:27017",
    "oplogFile": "/local/mongoConnector/eldoc_cidXXX/oplog.timestamp",
    "noDump": false,
    "batchSize": -1,
    "verbosity": 0,
    "continueOnError": true,
    "logging": {
        "type": "file",
        "filename": "/local/mongoConnector/eldoc_cidXXX/mongo-connector.log",
        "__format": "%(asctime)s [%(levelname)s] %(name)s:%(lineno)d - %(message)s",
        "__rotationWhen": "D",
        "__rotationInterval": 1,
        "__rotationBackups": 10,
        "__type": "syslog",
        "__host": "localhost:514"
    },
    "authentication": {
        "adminUsername": "moncon",
        "password": "XXXXXXXXXXX",
        "__passwordFile": "mongo-connector.pwd"
    },
    "__comment__": "For more information about SSL with MongoDB, please see http://docs.mongodb.org/manual/tutorial/configure-ssl-clients/",
    "__ssl": {
        "__sslCertfile": "Path to certificate to identify the local connection against MongoDB",
        "__sslKeyfile": "Path to the private key for sslCertfile. Not necessary if already included in sslCertfile.",
        "__sslCACerts": "Path to concatenated set of certificate authority certificates to validate the other side of the connection",
        "__sslCertificatePolicy": "Policy for validating SSL certificates provided from the other end of the connection. Possible values are 'required' (require and validate certificates), 'optional' (validate but don't require a certificate), and 'ignored' (ignore certificates)."
    },
    "namespaces": {
    "eldoc_cidXXX.docForms": true,
    "eldoc_cidXXX.docFormsData": {
            "gridfs": true
        }
    },
    "docManagers": [
        {
            "docManager": "solr_doc_manager",
            "targetURL": "http://localhost:8983/solr/eldoc_cidXXX",
            "__bulkSize": 1000,
            "__uniqueKey": "_id",
            "autoCommitInterval": 0,
            "args": {
                "skipUpdateNsSuffixes": [".docFormsData"]
            }
        }
    ]
}

Adjust access rights for the sync service configuration

chown -R moncon:moncon /local/mongoConnector/

chmod 600 /local/mongoConnector/eldoc_cidXXX/mongo-connector.json

6) Install and enable sync system service

Make necessary adjustments where required

nano /etc/systemd/system/mc_eldoc_cidXXX.service

mc_eldoc_cidXXX.service
[Unit]
Description=Mongo Connector Service
After=syslog.target network.target mongod.service solr.service
Requires=mongod.service solr.service

[Service]
User=moncon
Type=simple
ExecStart=/bin/python3 -m mongo_connector.connector -c /local/mongoConnector/eldoc_cidXXX/mongo-connector.json
ExecStop=/bin/kill -s TERM $MAINPID
WorkingDirectory=/local/mongoConnector/eldoc_cidXXX/
StandardError=file:/local/mongoConnector/eldoc_cidXXX/mongo-connector.err

[Install]
WantedBy=multi-user.target

Once sync service configured you may launch it by executing the following command:

systemctl daemon-reload && systemctl enable mc_eldoc_cidXXX.service && systemctl start mc_eldoc_cidXXX


3.4. Installation of the online editing service

NOTE: This component is optional and provides online editing capabilities for the office documents.

1) Installation of prerequisites

Online editing service is installed using container image. For this you need to install container manager software

dnf install podman

2) Create folders for the online editing service and environment settings file

mkdir /local/ooDocServer && mkdir /local/ooDocServer/cache && mkdir /local/ooDocServer/logs && mkdir /local/ooDocServer/data

nano /local/ooDocServer/ooDocServer.env

ooDocServer.env
JWT_ENABLED=true
JWT_SECRET=[256bit key to be placed here, can be retrieved from: Administration -> Configuration -> Cipher keys generator -> Random 256bit cipher key (Hex-encoded)]

NOTE: Write down JWT_SECRET key value and add it to the elDoc configuration file (eldoc.conf) in the respective parameters.

3) Create self-signed cert to be used by online editing service container

mkdir /local/ooDocServer/data/certs/ && cd /local/ooDocServer/data/certs/

openssl genrsa -out onlyoffice.key 2048

openssl req -new -key onlyoffice.key -out onlyoffice.csr

openssl x509 -req -days 3650 -in onlyoffice.csr -signkey onlyoffice.key -out onlyoffice.crt

openssl dhparam -out dhparam.pem 2048

4) Install and launch online editing service container

podman run -i -t -d -p 18443:443 --name=ooDocServer --env-file /local/ooDocServer/ooDocServer.env \
    -v /local/ooDocServer/cache:/var/lib/onlyoffice/documentserver/App_Data/cache/files \
    -v /local/ooDocServer/logs:/var/log/onlyoffice -v /local/ooDocServer/data:/var/www/onlyoffice/Data \
    onlyoffice/documentserver

After command successfully executed - stop the online editing service by executing command:

podman stop ooDocServer

5) Install online editing service as system service

nano /etc/systemd/system/ooDocServer.service

ooDocServer.service
[Unit]
Description=Document Server (for elDoc)
After=eldoc.service mongod.service

[Service]
Restart=always
ExecStart=/bin/podman start -a ooDocServer
ExecStop=/bin/podman stop ooDocServer

[Install]
WantedBy=default.target

Once service configuration is created - execute the following command:

systemctl enable ooDocServer && systemctl start ooDocServer


3.5. Installation of the office conversion service

NOTE: This component is optional and provides online preview and document auto-filling functionality.

1) Office conversion service installed using standard Linux package manager

dnf install libreoffice-base libreoffice-writer libreoffice-math libreoffice-calc libreoffice-core libreoffice-draw libreoffice-emailmerge libreoffice-graphicfilter libreoffice-impress libreoffice-opensymbol-fonts libreoffice-data libreoffice-ure libreoffice-ure-common libreoffice-pyuno libreoffice-filters libreoffice-ogltrans libreoffice-pdfimport libreoffice-xsltfilter libreoffice-langpack-en libreoffice-langpack-ru libreoffice-langpack-uk libreofficekit libreoffice-headless

After executing the command above required packages will be installed in the system and automatically picked-up by the elDoc system.


4. elDoc installation & configuration

1) Extract obtained elDoc distribution archive

Extract elDoc archive into /local/elDoc folder

2) Edit elDoc configuration file in order to configure the elDoc system

nano /local/elDoc/eldoc.conf

3) Edit elDoc system service file and replace respective parameters (e.g.: User=cidXXX) where required

nano /local/elDoc/eldoc.service 

4) Install elDoc as a linux service

systemctl enable /local/elDoc/eldoc.service

5) Start elDoc server

systemctl start eldoc

6) Initial login to the elDoc system and administrator user creation

In order to perform initial login to the elDoc system you need to enable "elDoc maintenance mode" via making the necessary adjustments in the eldoc.conf file. Once admin user is created in the elDoc system you need to disable the "elDoc maintenance mode".



Updated: 14.01.2021