User Tools

Site Tools


tnt2:setup:systeminstallation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
tnt2:setup:systeminstallation [2019/10/30 08:47]
hubbe
tnt2:setup:systeminstallation [2019/10/30 09:24] (current)
hubbe
Line 1: Line 1:
 +===== System installation =====
 +
 +This chapter will describe the process of installing the system on a new server. The steps in this document will require that the user has knowledge of the chosen linux distribution and has some sense of NodeJS and MongoDB administration.
 +
 +
 +==== Prerequisites ====
 +
 +Track and Trace 2.0 can be installed on any Linux system able to run MongoDB, Nginx HTTP server and the NodeJS framework. This document will show the installation process on Ubuntu LTS 16.04 and the installation procedure will differ on different Linux distributions.
 +
 +There is no obvious reason why TnT2.0 would not run on a Windows server, but this has not yet been tested and verified.
 +
 +
 +==== Installation of requirements ====
 +
 +=== MongoDB 3.6 ===
 +
 +First, enable the repository for Mongo 3.6 to be used, since Ubuntu 16.04 uses an older repo by default:
 +<code bash>
 +sudo apt-key adv --keyserver hkp://​keyserver.ubuntu.com:​80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
 +echo "deb [ arch=amd64,​arm64 ] https://​repo.mongodb.org/​apt/​ubuntu xenial/​mongodb-org/​3.6 multiverse"​ | sudo tee /​etc/​apt/​sources.list.d/​mongodb-org-3.6.list
 +</​code>​
 +
 +Update and install MongoDB 3.6
 +<code bash>
 +sudo apt-get update
 +sudo apt-get install -y mongodb-org
 +</​code>​
 +
 +Now you should be able to start the mongod daemon.
 +<code bash>
 +sudo service mongod start
 +</​code>​
 +
 +And after that you should be able to verify the installation by connecting to the mongodb database.
 +<code bash>
 +mongo
 +</​code>​
 +
 +** IMPORTANT **
 +To ensure that the mongo database starts on system reboot make sure to enable the service:
 +<code bash>
 +  sudo systemctl enable mongod.service
 +</​code>​
 +
 +=== Nginx HTTP ===
 +
 +Installation of the Nginx web server on Ubuntu 16.04 is straightforward:​
 +<code bash>
 +sudo apt-get update
 +sudo apt-get install nginx
 +sudo ufw allow 'Nginx HTTP'
 +systemctl status nginx
 +</​code>​
 +
 +To enable our webapp and TnT2 Client web pages edit the nginx configuration for the default site.
 +<code bash>
 +vi /​etc/​nginx/​sites-enabled/​default
 +</​code>​
 +
 +Add the following under the //location / // tag:
 +<​code>​
 +location /app {
 +  alias /​opt/​node/​TrackAndTrace2/​apps/​scanner;​
 +}
 +location /client {
 +  alias /​opt/​node/​TrackAndTrace2/​client;​
 +}
 +</​code>​
 +
 +Change /​opt/​node/​TrackAndTrace2 to whatever your install location is.
 +
 +After this, simply reload the nginx service and we're done.
 +<code bash>
 +systemctl reload nginx
 +</​code>​
 +
 +
 +==== Install the Track and Trace 2.0 system ====
 +
 +We need NodeJS and the npm package manager:
 +<code bash>
 +sudo apt-get install curl
 +curl -sL https://​deb.nodesource.com/​setup_10.x | sudo -E bash -
 +sudo apt-get install nodejs
 +</​code>​
 +
 +Now we create the installation directory and set the permissions to full access:
 +<code bash>
 +sudo mkdir /opt/node
 +cd /opt/node
 +sudo chmod a+rwx .
 +mkdir tnt2_[site]_[version]
 +ln -s tnt2_[site]_[version] TrackAndTrace2
 +cd TrackAndTrace2
 +</​code>​
 +
 +Download and install the Track and Trace 2.0 system:
 +<code bash>
 +git clone -b [version] [gitrepo]
 +</​code>​
 +
 +Install the required NPM-packages:​
 +<code bash>
 +npm install
 +</​code>​
 +
 +Substitute the configuration with the right one. If none exists, edit the configuration file.
 +<code bash>
 +cd config
 +rm tntconfig.js
 +ln -s tntconfig_[SITE].js tntconfig.js
 +cd ..
 +</​code>​
 +
 +Install the PM2 process manager:
 +<code bash>
 +sudo npm install pm2 -g
 +pm2 startup
 +</​code>​
 +Follow the instructions.
 +
 +Create the manifest archive directory:
 +<code bash>
 +mkdir manifestArchive
 +</​code>​
 +
 +Add the proper configuration to the //​manifestsources//​ collection of the MongoDB database pointed to by the configuration file.
 +<code bash>
 +mongo
 +use [database]
 +  db.manifestsources.insert( {
 +    "​type"​ : "​ftp",​
 +    "​host"​ : "​[FTPHOST]",​
 +    "​port"​ : 21,
 +    "​user"​ : "​[FTPUSER]",​
 +    "​password"​ : "​[FTPPASSWORD]",​
 +    "​description"​ : "​[DESCRIPTION OF SOURCE]",​
 +    "​sendercode"​ : "​[SENDERCODE ON MANIFEST]",​
 +    "​path"​ : "[PATH ON REMOTE SERVER]",​
 +    "​archiveto"​ : "[PATH TO ARCHIVE TO ON THE REMOTE SERVER]",​
 +    "​localarchiveto"​ : "/​opt/​node/​TrackAndTrace2/​manifestsArchive",​
 +    "​active"​ : true,
 +    "​filter"​ : [
 +      [ADD REGULAR EXPRESSIONS TO MATCH MANIFEST HERE]
 +    ]
 +  } );
 +  exit;
 +</​code>​
 +
 +Start the services for the TnT2 system:
 +<code bash>
 +cd /​opt/​node/​TrackAndTrace2
 +npm run manifestimporter
 +npm run manifestpoimporter
 +npm run manifestvalidator
 +npm run manifestbuilder
 +npm run mappingimporter
 +npm run storeroomimporter
 +npm run userimporter
 +npm run restservice
 +npm run worker
 +npm run integration
 +pm2 save
 +</​code>​
 +
 +Verify that all services are running:
 +<code bash>
 +pm2 list
 +</​code>​
 +
 +Check that there are no errors in the logs:
 +<code bash>
 +pm2 logs
 +</​code>​
 +
 +Add the needed indexes to the database collections:​
 +<code bash>
 +mongo
 +use [DATABASE]
 +  db.manifests.createIndex( {"​parser.parsed":​-1});​
 +  db.transactions.createIndex( {"​timestamp":​-1});​
 +  db.MQdata.createIndex( {q:1} );
 +  db.items.createIndex( {parent_id:​1} );
 +  db.packs.createIndex( {parent_id:​1} );
 +  db.transactions.createIndex( {timestamp:​1} );
 +exit
 +</​code>​
 +
 +There, the system is now installed and running. Make sure to log in to the client and set the active-flag on the active stores prior to importing manifests, otherwise the manifest import process will fail as there are no active stores.
  
tnt2/setup/systeminstallation.txt ยท Last modified: 2019/10/30 09:24 by hubbe