MongoDB Setup - acmeair-svt/acmeair-mainservice-java GitHub Wiki
Newest Version: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
Version 4.2: https://docs.mongodb.com/v4.2/tutorial/install-mongodb-on-red-hat/
- This setup assumes the use of a VM (https://vlaunch.rtp.raleigh.ibm.com/)
- We used RHEL 7 successfully
- Must login to VM with root account
- We used MongoDB 4.2 with our application (the newest version of MongoDB at the time of running our application)
- Create a /etc/yum.repos.d/mongodb-org-4.2.repo file so that you can install MongoDB directly using yum:
- This step is slightly different with the newest version (see link on top)
[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
- Install MongoDB 4.2:
sudo yum install -y mongodb-org-4.2.8 mongodb-org-server-4.2.8 mongodb-org-shell-4.2.8 mongodb-org-mongos-4.2.8 mongodb-org-tools-4.2.8
- OR Install newest version of MongoDB:
sudo yum install -y mongodb-org
- (Optional) To prevent MongoDB from upgrading to a newer version automatically, add the following exclude directive to /etc/yum.conf:
exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools
- Ensure that the following MongoDB directories exist:
/var/lib/mongo
/var/log/mongodb
- If not, run for each of the above directories:
sudo mkdir -p <directory>
sudo chown -R mongod:mongod <directory>
- Bind all ips:
mongod --dbpath /var/lib/mongo --logpath /var/log/mongodb/mongod.log --bind_ip_all &
- Hit enter to return to terminal
- Verify that 27017 is established:
netstat -a | grep 27017
- If so, there should be a similar output as below.
- The VM can safely be exited now with mongodb continuing to run
- Update the MONGO_HOST field of app-deploy.yaml with the VM host in the following services:
- Booking
- Customer
- Flight
- ex: acmeairmongovmrh.rtp.raleigh.ibm.com
- NOTE: The USERNAME and PASSWORD fields above MONGO_HOST do not correspond to the username and password for MongoDB. If you are using a different setup than the one specified in these instructions, see next bullet to add username, password, and port. If you are using a VM created with these instructions, then you can skip the next bullet.
- If using something other than the VM, it is possible to update these values in the same section of MONGO_HOST in app-deploy.yaml of the above services (if needed):
- MONGO_HOST
- MONGO_PORT
- MONGO_USERNAME
- MONGO_PASSWORD
- See here for additional fields
- Note: MONGO_DBNAME does not need to be changed, even if the specified database table does not currently exist. This application will automatically set this up for each relevant service.
- Go to the configure environment page of AcmeAir
- If the database is connected, there should be numbers beside each category as in the picture below (they may all currently be 0 since the db is not loaded with data yet)
- Try loading the database (click Load the database, then (Re)Load the Database)
- Should see messages ensuring that booking, customer, and flight are reloaded
- Troubleshooting: Flight loader from website may show a timeout error, but will keep adding flights regardless. Keeping refreshing config page until the number of flights stops increasing. All flights should be loaded at this point.