Entering Dynamic Data (MongoDB) Database Information
Configuring the Mongo database is a one-step procedure, where you select the database setup option and based on your selection, you can provide the configuration details for that database for your environment.
* 
It is recommended that you configure the Mongo database outside of your PTC Arbortext Content Delivery installation directory. This ensures that the MongoDB installation is not accidently erased during the upgrade.
To achieve high availability of the software while using MongoDB, you can configure PTC Arbortext Content Delivery with an existing MongoDB instance (version 3.4) that is installed on a separate server (independent of the Publisher server).
You can install MongoDB on Viewer through the Viewer installation. When you want to install another Viewer on the same site, you can skip the MongoDB installation as it is already installed for the first Viewer on that server using the Skip MongoDB Configuration check box.
If you plan to deploy a cluster environment with two internal LDAPs, one for publisher and one for the runtime viewers, PTC recommends that you must use a separate MongoDB (or separate database name) for the publisher and the runtime viewers.
Create a new MongoDB installation and user
Create new user and connect to an existing MongoDB
Configure to existing users on an existing MongoDB
Option
Default
Description
MongoDB Configuration
Create a new MongoDB installation and user
Create new user and connect to an existing MongoDB
Configure to existing users on an existing MongoDB
Select whether or not to create a new user and a new installation, to create a new user and connect to an existing database, or allow the installation process to configure an existing user on an existing database.
Load base data
Selecting this option loads the base data into the existing database.
Mongo Loadpoint Location
Location where MongoDB must be installed.
This field is available only when creating a new database and user.
Mongo DNS Registered Host Name
<hostName>.<domain>
Provide the fully qualified machine name of the MongoDB server.
Mongo Database Name
ACD
Name of the dynamic data database.
* 
Following restrictions are observed while naming the Mongo database:
For Windows—the database name cannot contain any of the following characters: /\. "$*<>:|?
For Linux or Unix—the database name cannot contain any of the following characters: /\. "$
The database name cannot contain a null character.
Mongo Database Listener Port Number
27017 (default port)
Port number the MongoDB server listens on.
You can edit the default port.
Admin user for MongoDB
Provide a name for the administrator user for MongoDB.
Admin password for MongoDB
Provide a password for the MongoDB administrator user.
Confirm Admin password for MongoDB
Re-enter password provided for the MongoDB administrator user to confirm.
This field is available only when creating a new database and user.
User Name
ptcuser
Name of thePTC Arbortext Content Delivery user.
Password
Provide a password for the PTC Arbortext Content Delivery user.
Confirm Password
Re-enter password provided for the PTC Arbortext Content Delivery user to confirm.
This field is available only when creating a new database and user.
* 
In case of Create new user and connect to an existingMongoDB and Configure to existing users on an existingMongoDB configuration options, you can have multiple database accounts of PTC Arbortext Content Delivery using the same MongoDB instance with different database names. That is, you can create a new MongoDB regardless of the existing instance of MongoDB on same machine.
You can skip the MongoDB setup by clicking Next without entering any details, if it is already configured as part of another Viewer or Publisher setup. MongoDB must be installed only once. All other viewers or publishers are configured with MongoDB.
The MongoDB service on Linux machines is not automatically started when you restart the machine. To start or stop the MongoDB service on a Linux machine, open a Linux terminal, go to <HOME>/SW, and run the following command:
./MongoDBService.sh <Mongo_DBHOME> start/stop
For example:
./MongoDBService.sh /data/Mongo start
./MongoDBService.sh /data/Mongo stop
To achieve high availability of the software while using MongoDB, you can configure PTC Arbortext Content Delivery with an existing MongoDB instance that is installed on a separate server (independent of the Publisher server).
MongoDB Data Backup
To backup your Mongo data, perform any one of the following two best practices:
Keep the periodic back up (cp/rsync) of contents inside {Mongo_installation_dir}Mongo\data\db, where db is the directory of out-of-the-box installation on the remote server. In case of DB or machine crash, point the new DBinstance to the backup directory with the help of mongod.conf file. Update the dbpath property in this file.
Schedule dump of the data from out-of-the-box mongo instance using the mongodump/mongorestore commands as cron jobs. In case of crash or faiure, the dump can be later used to reload data into other instance.
To dump the data,
1. Navigate to the out-of-the-box mongo installation directory, for example, {Mongo_installation_dir}\mongodb\bin
2. Run the mongodump command. It stores the data in the dump directory inside {Installation_dir}\mongodb\bin\dump.
3. Provide the port, DB name, normal DB username, and password that was provided during PTC Arbortext Content Delivery (Mongo) installation.For example, mongodump --host localhost --port 27017 --db ACD --username dev --password dev. Instead, you can specify the output directory of the dumps to dump it at other location.For example, mongodump --host mongodb1.example.net --port 27017 --username user --password "pass" --out /opt/backup/mongodump-2011-10-24
To restore the data,
1. Navigate to the new DB instance {Mongo_installation_dir}\mongodb\bin new instance
2. Run the mongorestore command.For example, mongorestore --host localhost --port 27017 --db ACD --username dev --password dev /opt/mongodump/ACD. Here, /opt/mongodump/ACD is the folder where the dumps are kept.
MongoDB Logging
MongoDB does not have any built-in activity log rotator due to which the log file size grows to a huge file as you interact with the DB and becomes difficult to manage.
The MongoDB logs are disabled out-of-the-box and if you want to enable the logs, perform the following steps:
1. Open the mongod.conf file from MongoDB install Directory.
2. Add an entry verbose = true
3. Save the file and restart the MongoDB service.
MongoDB Log Rotate
To enable MongoDB logging with log rotation in Windows and Linux environments, after enabling the verbose, perform the following steps:
For Windows,
1. Create a bat file, for example, logRotate.bat and add the following script to it:
@ECHO off
if "%1" == "" goto usage
setlocal
set file=%2
set maxbytesize=%5

FOR /F "usebackq" %%A IN ('%file%') DO set size=%%~zA

if %size% LSS %maxbytesize% (
goto :eof
) ELSE (
ECHO.File is ^>= %maxbytesize% bytes creating backup.
)

cd %1
mongo --authenticationDatabase admin admin -u %3 -p %4 --eval "db.runCommand( { logRotate : 1 } );"
goto :eof

:usage
echo %0 MongoDBBinPath MongoDBLogPath adminUserName adminPassword fileSize
echo ---------------------------------------------------------------------------
echo MongoDBBinPath : MongoDB Bin Path (For eg. : C:\Mongo\mongodb\bin)
echo MongoDBLogPath : MongoDB Log File Path (For eg. : C:\Mongo\log\MongoDBLog.log)
echo adminUserName : Username of admin databse
echo adminPassword : Password of admin databse
echo fileSize : File size it is in Bytes, specified after this script will create new log file (For eg. : 1000)
echo ----------------------------------------------------------------------------
2. Perform any of the following:
Open the command prompt and run this bat file with all the required parameters.
For example, logRotate.bat <MongoDB Bin Path> <MongoDB Log Path> <Username of admin database> <Password of admin database> <File Size>It will create the new log file and a backup of the old file.
If you do not want to run the bat file manually, schedule it on Windows event scheduler according to your time frame. It will run automatically and create a new log file and a backup of the old file.
Now you can delete the backup file.
3. If you do not want to delete the backup log files manually, then use the following script:
@echo off
setlocal enableextensions enabledelayedexpansion
if "%1" == "" goto usage
set dirPath=%1
pushd !dirPath!
:: Loop through all files in this directory
for %%a in (*) do (
set fileName=%%a
if "!fileName!"=="MongoDbLog-20191125133010.342000+330.log" (
echo FOUND: !fileName!
) else (
echo OTHER: !fileName!
del "!fileName!"
echo deleted
)
)

:usage
echo %0 MongoDB Log Path
echo -----------------------------------------------------------------
echo MongoDBLogPath : MongoDB Log File Path (For eg. : C:\Mongo\log\MongoDBLog.log)
echo ------------------------------------------------------------------
4. Perform any of the following:
Open command prompt and run this bat file with all the required parameters.
For example, deleteLogFile.bat <MongoDB Bin Path>. It will delete the all backup log files.
If you do not want to delete the bat file manually, schedule it on Windows event scheduler according to your time frame. It will run automatically and delete the backup files.
For Linux,
1. Add the following entry in mongod.conf file at location /etc/ under the section systemLog.
logRotate: reopen
2. Replace the script in mongod.conf with the following script:
/var/log/mongodb/mongod.log {
daily
size 100M
rotate 20
missingok
compress
delaycompress
notifempty
create 0640 mongod mongod
sharedscripts
postrotate
/bin/kill -SIGUSR1 $(cat /var/run/mongodb/mongod.pid)
endscript
}
3. Restart the mongo service by running the command:
sudo service mongod restart
* 
The parameters in the script /etc/logrotate.d/ mongod.conf are configurable. The description of the parameters is as follows:
rotate: number of files to rotate
compress: to compress the rotated log file
postrotate: creates new log file to write
daily: frequency of log rotation
size: size of file defining log rotation
By default, the mongo log rotation is executed daily. However, you can alter the frequency by changing the cron files.For example, to rotate the logs hourly:
1. Navigate to location /etc/
2. Move the script logrotate from cron.daily to cron.hourly
3. Copy null in cron.daily (so that the default is not considered) using the command:
cp /dev/null /etc/cron.daily
4. Edit the file /etc/logrotate.conf, remove weekly from it, and comment out the dateext
5. Replace the above mentioned script mongod.conf at location /etc/logrotate.d/, commenting out daily.
6. Clean the /var/log/mongodb/
7. Restart the mongo service.
* 
Grant permissions as and when required.