Mongo Cluster Setup and Configuration
If you plan to configure Mongo cluster/replication, provide the MongoDB hostnames and ports in the Configurator UI before starting Mongo cluster work.That is, you must notify PTC Arbortext Content Delivery that current Mongo is a Mongo triad. In the UI, primary hostname must be entered at Mongo hostname field and remaining two can be in backup hosts.
Update Configurator
Update Configurator to put in the Mongo cluster as follows:
Publish: Do not restart the server at this point unless, MongoDB configuration is successful.
Host1
Host2
Host3
Go to Publisher server
1. Mongo home folder: For example, /appl/Mongo Go to folder: /appl/Mongo/mongodb/bin
2. Create the file:mongod.cfg with the following content:
systemLog:
destination: file
path: '/appl/Mongo/log/mongopubl.log'
logAppend: true
storage:
dbPath: '/appl/Mongo/data/db'
security:
authorization: enabled
net:
bindIp: Host1, Host2, Host3
port: 27017,27017,27017
3. Stop MongoDB in Publisher cd /appl/ACD/SW/SW./MongoDBService.sh /appl/Mongo stopIf it does not work, stop the MongoDB process.
4. Go to folder: /appl/Mongo/data/db. Remove all files and folders ONLY from this folder.
5. Go to folder: /appl
6. Create a tar of Mongo folder and all subfolders under it. tar cvf mongo.tar ./Mongo/
7. Copy the tar to Host1 and Host2 machines.
8. Go to Host2 Server.
9. Extract the mongo tar that was copied from Publisher.
10. Extract to create Mongo folder structure similar to Publisher tar -
xvf mongo.tar
rm mongo.tar
11. Go to Host3 Server.
12. Extract the mongo tar that was copied from Publisher.
13. Extract to create Mongo folder structure similar to Publisher.
tar -xvf mongo.tar
rm mongo.tar
14. Go to Publisher server
cd /appl/Mongo/mongodb/bin
./mongod --replSet "MongoReplicaSet" --logpath "/appl/ArbortextContentDelivery/Mongo/log/mongo_replica1.log" --dbpath "/appl/ArbortextContentDelivery/Mongo/data/db" --port 27017 &
16. Go to Host2 server
cd /appl/Mongo/mongodb/bin
./mongod --replSet "MongoReplicaSet" --logpath "/appl/ArbortextContentDelivery/Mongo/log/mongo_replica1.log" --dbpath "/appl/ArbortextContentDelivery/Mongo/data/db" --port 27017 &
18. Go to Host3 server
cd /appl/Mongo/mongodb/bin
./mongod --replSet "MongoReplicaSet" --logpath "/appl/Mongo/log/mongo_replica1.log" --dbpath "/appl/ArbortextContentDelivery/Mongo/data/db" --port 27017 &
20. Go to Publisher server
cd /appl/Mongo/mongodb/bin
21. Go to mongo db.
./mongo
22. Execute the following configuration command in mongo shell:
config={_id:"MongoReplicaSet",members : [ {_id:0,host : "Host1:27017"}, {_id:1,host : "Host2:27017"}, {_id:2,host : "Host3:27017"}] };
23. Execute following initiate command in mongo shell: rs.initiate(config);
24. Check status in mongo cell:rs.status();
You should see three instances listed. One instance—Publisher should be Primary and the other two Hosts as Secondary.
25. Go to Host2 server
cd /appl/Mongo/mongodb/bin
26. Go to mongo db.
./mongo
27. Check status in mongo cell:rs.status();
You should see three instances listed. One instance—Publisher should be Primary and the other two Hosts as Secondary.
28. Go to Host3 server
cd /appl/Mongo/mongodb/bin
29. Go to mongo db.
./mongo
30. Check status in mongo shell:rs.status();
You should see three instances listed. One instance—Publisher should be Primary and the other two Hosts as Secondary.
There has to be at least 2 Mongo instances to be up for the replica set to work.
31. If Mongo dies in all three instances, then you have to run the replicaset command in all 3 instances and proceed as follows:
Go to Publisher server.
cd /appl/Mongo/mongodb/bin
32. Go to mongo db.
./mongo
33. Check status in mongo shell:rs.status();
You should see three instances listed. One instance—Publisher should be Primary and the other two Hosts as Secondary. Similarly you can check status in each Viewer.
34. Restart all Jboss, core processes in Publisher, Viewer1, Viewer2. Do not restart WindchillDS or Mongo processes. Restart everything else.
Create mongo users
Find out which one is the MongoDB Primary node. On that node ONLY:
1. Navigate to Mongo/mongodb/bin and create createMongoUsers.sh
2. Insert the following:
#!/bin/bash
if [ "$#" -ne 4 ]; then
echo "Illegal number of parameters passed Format should"
echo "1.Mongo Admin User Name"
echo "2.Mongo Admin Password"
echo "3.Mongo DB Application User Name"
echo "4.Mongo DB Application Password"
exit 1
fi

mongo << EOF
use admin
db.createUser(
{
user: "$1",
pwd: "$2",
roles: [ { role: "root", db: "admin" } ]
}
);
exit
EOF
mongo admin -u $1 -p $2<< EOF
use ACD
db.createUser(
{
user: "$3",
pwd: "$4",
roles: [
{ role: "readWrite", db: "ACD" }
]
}
);
exit
EOF
* 
Modify the user name, password, and DB name in above code according to your configuration.
3. Save the file.
4. ./createMongoUsers.sh mongoadmin <mongoadmin_name> mongouser <mongo_user>
5. On each mongo host, you can login to MongoDB with the created users.
6. Navigate to Mongo/mongodb/bin and run the following commands:
/appl/Mongo/mongodb/bin
./mongo -u mongouser -p mongouser ACD
./mongo -u mongoadmin -p mongoadmin admin
Restart Mongo and Jboss Processes
1. Kill mongo on all hosts.
2. Recreate mongo replication on each host.
ps -ef|grep -i mongo
kill -9 mongo pid>
./mongod --replSet "MongoReplicaSet" --logpath "/appl/Mongo/log/mongo_replica1.log" --dbpath "/appl/Mongo/data/db" --port 27017 &
3. Restart jboss on each server.
Load Basedata for Mongo
1. Navigate to Windchill shell.
2. Run following command in Windchill shell: windchill com.ptc.sc.loader.SCLoader baseset -u inservadmin -p inservadmin. Here, windchill admin userid/password are: inservadmin/inservadmin
3. Now you can bring up all servers.