Skip to content

Instantly share code, notes, and snippets.

@CarlasHub
Created May 21, 2018 15:56
Show Gist options
  • Save CarlasHub/5528432aca589a19b8f820666cf9daf3 to your computer and use it in GitHub Desktop.
Save CarlasHub/5528432aca589a19b8f820666cf9daf3 to your computer and use it in GitHub Desktop.
Update Mongod
killall mongod
sudo apt-get purge -y mongodb-org*
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt-get update
sudo apt-get install -y mongodb-org
note: you may need to run these individually.
When that's done you can restart the terminal (close and open a new one) and run mongo --version it should be 3.6.2
Now you'll want to remove the mongod* file that you normally run with ./mongod and create a new one.
So go to the folder that you normally run ./mongod from and run the following:
rm -rf mongod
echo "mongod --dbpath=data --nojournal" > mongod
chmod a+x mongod
This assumes that the mongod* file you created and the data directory you created are in the same folder, this folder should be ~, but some students put it inside of ~/workspace which is fine too, just be sure mongod* and data are in the same folder.
Now try to run mongod with ./mongod from the folder with mongod* in it
Update: Please see additional issues/solutions below and make sure you check/try each of them before asking for help:
* If you are getting this message: ** IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details.
then you need to delete your data directory and create a new, empty, one (Please note: This will delete all existing data from your databases). Do this by changing directories into the folder where you have your data directory, this is most likely ~ (root ) or ~/workspace - Once inside of that folder run rm -rf data ; mkdir data now try to run ./mongod (make sure you're in the folder where the green/bolded mongod* file is).
------------------------------------------------------
* If your ./mongod won't start then you may be using the original configuration which uses: mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$@"
- To fix this, go to the directory where mongod* is and run: rm -rf mongod ; echo "mongod --dbpath=data --nojournal" > mongod ; chmod a+x mongod - Now try to run ./mongod
------------------------------------------------------
* If your mongo version is 3.6.1 or greater when running mongo --version and your mongoose version in your app/project's package.json file is 5.0.6 then the only thing left to check is your comments post route. Make sure you're not using the .populate('comments') workaround that was suggested somewhere in a thread on the Q&A boards. That code should only be in the campgrounds GET /:id (show) route.
------------------------------------------------------
* With the latest versions of mongo and mongoose you do not need useMongoClient: true or { usePushEach: true } or mongoose.Promise = global.Promise which were workarounds for previous warnings and errors from older versions
------------------------------------------------------
* If you entered sudo apt-key adv --keyserver hkp: from the instructions above then you didn't copy the entire line, the latter half of the code is hard to see because of the syntax highlighting, but the full command is: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
------------------------------------------------------
* If you're still unable to see comments in your campground, but you see them in the database, then delete all campgrounds and comments from the database using the mongo shell: db.campgrounds.remove({}); and db.comments.remove({}); and try running your app again
------------------------------------------------------
ANYONE STILL FACING PROBLEMS PLEASE READ THE NOTE BELOW:
I know this problem is annoying, I intend on making a video solution walking through all of the steps one by one, but until then you'll have to follow the instructions at the top of this thread. This is actually a really good real world scenario so take advantage of it, these are the kinds of problems you will run into in your code when working for a tech company or for yourself doing contract client work.
I promise you, if you read through this thread and follow the instructions to a T then you will be able to resolve your problem. Almost every person I've helped in this thread was simply missing a step from the instructions or had a typo or some extra code somewhere.
So to recap, here's a checklist to follow:
- Do you have mongodb 3.6.2? check with mongo --version
- Do you have mongoose 5.0.6? Check package.json
- Did you remove the extra .populate() code that you might have added to your comment post route from a thread where another student said that was a workaround (not his/her fault, they didn't know)?
- Did you delete any existing campgrounds and comments from the database and start fresh?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment