# What I had to do on an aws server. apt-get remove mongodb-org-mongos/now mongodb-org-server/now mongodb-org-shell/now mongodb-org-tools/now sudo apt-get install -y mongodb-org=3.4.2 # Then follow https://docs.mongodb.com/manual/tutorial/install-mongodb-on-linux/ # I am going to assume we are not using thetemporary # Mongo servers and they are not running. # This will delete them. # If restarting, kill the mogo processes and then do rm -rf mongo/d1 mongo/d2 mongo/d3 mongo/logs # Setup 3 directories: mkdir -p mongo/d1 mongo/d2 mongo/d3 mongo/logs # If not AWS, ignore or already did it. # sudo -s -- bash -c ' echo "127.0.0.1 localhost ">> /etc/hosts ' # Start the mongod mongod --dbpath mongo/d1 --smallfiles --oplogSize 50 --bind_ip 127.0.0.1 > mongo/logs/1.log 2>&1 & db.peopleSectors.drop(); db.createView("peopleSectors", "people", [ {$lookup: {from: "companies", localField: "company_id", foreignField: "_id", as: 's'} } , {$project: {_id:0, first_name:1, last_name: 1, job:1, company: "$s.name" } } , {$unwind: "$company"} ]); db.peopleSectors.findOne( ) db.peopleSectors.drop(); db.createView("peopleSectors", "people", [ {$lookup: {from: "companies", localField: "company_id", foreignField: "_id", as: 's'} } , {$project: {_id:0, first_name:1, last_name: 1, job:1, company: "$s.name", sector: "$s.sector"} } , {$unwind: "$company"} , {$unwind: "$sector"} ]); db.peopleSectors.findOne( ) db.peopleSectors.find().sort( {job: 1, sector: 1, last_name: 1, first_name: 1 } ).limit(1).pretty() db.peopleSectors.find().sort( {job: 1,sector: 1, last_name: 1, first_name: 1 } ) db.peopleSectors.find().sort( {last_name: 1, first_name: 1 } )