Upgrading older mongo database after unintentional mongo version upgrade - mongodb

Is there any way to upgrade a mongo database after the mongodb package was unintentionally upgraded (3.4.9 -> 3.6.1)?
According to the mongo docs, as a prerequisite of the upgrade, featureCompatibilityVersion has to be set from the mongo cli tool, which, however, needs a running mongod database daemon, which, however, won't run if mongodb package was already upgraded and the database was not set the featureCompatibilityVersion flag.
I'm on ArchLinux, I had mongodb in IgnorePkg but it's dependencies boost-libs and wiredtiger got upgraded anyways. Having pacman cache already wiped out, I compiled older versions of the packages myself, but running mongodb keeps failing with this error:
unsupported WiredTiger file version: this build only supports major/minor versions up to 1/0, and the file is version 2/0: WT_ERROR: non-specific WiredTiger error
I don't have a clue what the hell this means (the problematic version of wiredtiger is 2.9.3-1, version after the upgrade is 2.9.3.20171205-2).
Seems like I can neither downgrade nor upgrade...
Other cli tools (e.g. mongodump) also won't run without a running database, is there any other possibility (some wiredtiger related tool)? Deleting the database and starting afresh is not an option.

I solved the problem by installing the older version of mongodb on a system for which it wasn't a problem to get it pre-packaged (well, Windows 10, even though oficially it's stated the package is for Windows Server 2008), copying the database files (contents of /var/lib/mongodb) there, running it with --dbpath param (mongod --dbpath /path/to/dbfiles), setting the compatibility flag according to the docs and finally copying the db files back to the server.
Would like to know about a better option, but it's good to know the db files are easily transferable to another system, even another architecture (the db was relatively simple and small though).

Running mongod --repair worked for me.

here similar issue, unintentionally upgrade from 4.2.1 to 4.4.3, then mongodb can NOT started..
Final worked solution:
uninstall (latest, but not worked version: 4.4.3)
brew uninstall mongodb-community
reinstall, old but worked 4.2.1
brew install mongodb-community#4.2
run
for now: brew services run mongodb-community#4.2
for now and set bootable: brew services start mongodb-community#4.2
check status
brew services

Related

Can't start Mongodb shell on MacOS Mojave 10.14.2

Installed MongoDB Community Edition version 3.6 (because my work project requires that version). I am for some reason unable to run the MongoDB shell, so when trying to run mongo or mongod from the terminal I just get -bash: mongod: command not found. When checking which Brew services are running with brew services list, mongodb-community#3.6 is listed. The application I'm working on also utilises MongoDB succesfully. My main issue is that I can't access the MongoDB shell.
The solution to my problem was that I was supposed to install the shell separately with brew. This was not the case with previous MongoDB versions and it is not mentioned in the official MongoDB documentation.

Will Homebrew install of mongodb overwrite existing databases?

I want to reinstall mongodb on my mac using the following commands:
brew tap mongodb/brew
brew install mongodb-community
If I do this, will I lose the current databases in my existing mongodb install?
Edit
To clarify, the previous installation was done via HomeBrew as well.
It depends on where your existing database files are stored, whether mongo was installed via Homebrew previously, and if so, which version was installed.
Homebrew will install mongodb into /usr/local/Cellar/mongodb-community/{version} (4.4.0 as of this writing) and symlink the binaries into /usr/local/bin. It will not modify an installation performed by another means and any existing databases will be untouched as long as they're not in the same path as this installation. You would be able to load them with the Homebrew version with no issues.
You will need to consider your $PATH if you plan to leave both mongodb versions installed - if the Homebrew path (/usr/local/bin) is after the path of your current installation then the old binary will run. Homebrew usually takes care of this for you, but something to watch out for if you have any strange behaviour. Check the location of your current binaries by running which mongod.
To stay on the safe side, you should make a copy of your existing data files before you [re,un]install.

Mongodb Version mismatch Issue 3.6 to 4.0 upgrade

I have installed the latest version of MongoDB i.e 4.0.10. I am using Ubuntu 18.04.
When i run mongod --version in putty command line i get version 4.0.10
But When i run query in Studio3T db.version(); i get version 3.6.3
I ran dpkg -l | grep mongo and got following output.
Please help me in identifying what i am doing wrong here.
Looks like you have two MongoDBs installed, judging from 3.6.3-0ubuntu1 installed by apt, and 4.0.10 versions there.
The page Install MongoDB Community Edition on Ubuntu stated:
The mongodb package provided by Ubuntu is not maintained by MongoDB Inc. and conflicts with the mongodb-org package. To check if Ubuntu’s mongodb package is installed on the system, run sudo apt list --installed | grep mongodb. You can use sudo apt remove mongodb and sudo apt purge mongodb to remove and purge the mongodb package before attempting this procedure.
The older 3.6.3 appears to be still running in port 27017, thus that was the one connected to by Studio3T.
To ensure a clean installation, it's better to do a clean install by:
Follow the instructions in Uninstall MongoDB Community Edition
Remove 3.6.3 using apt as per the instruction above
Reinstall using the procedure in Install MongoDB Community Edition on Ubuntu.
It's probably not required to uninstall/reinstall everything again, but you don't want to have conflicting leftover files that will create problems down the road.
If you need the data in the old 3.6.3, please do mongodump before uninstalling it. You can subsequently restore it later.

Mongodb will automatically shut down even though permissions are correctly set

Read/Write permissions set
Mongodb still won't work
I used brew to install mongodb and updated it and everything.
I used this tutorial to download and install. I was able to do everything listed but when I tried mongod it didn't work. I've had mongodb downloaded and working previously on my laptop but had to factory reset recently and now it won't work.
I think mongod instance could not create the lock file or a lock file is already present in the location. Which means the current instance cannot get hold of it.
Remove the current lock file and restart your service.
sudo rm /data/db/mongod.lock
Restart
brew services stop mongodb
brew services start mongodb
Have you checked the version? I think when you can successfully check the version, it means your mongodb is ok and have been installed properly.
Here's how to check mongodb version "mongod --version".

MongoDB: Upgrade 2.4.10 to 2.6

I have a mongodb standalone instance in my ubuntu. According to official docs I replace mongod binary then I restarted mongodb using sudo service mongodb restart command, and restarted mongod binary also. Then when I check version using mongo --version. It's still 2.4.10. But when I check mongod version it's 2.6.1. Is it okay? I installed mongodb in my local machine using this guide. If it correct then I will upgrade my production server.
It sounds like you have upgraded your mongod server to 2.6.1 but still have an older version of the mongo shell in your path.
Technically that isn't a major issue for most usage as the older 2.4 shell can still connect and run common commands.
However, there are 2.6-specific shell helpers & features you'll be missing out on such as Bulk() operations and user management commands with user-defined roles.
If you have an open mongo shell, you can check the versions of both the mongo client and the mongod server you are connected to.
Ideally the major versions should match, eg:
> version() // Version of the `mongo` shell
2.6.1
> db.version() // Version of the `mongod` server this shell has connected to
2.6.1
The upgrade guide you have followed is assuming you are not using the packaged versions of MongoDB -- the guidance here could definitely be improved.
A better (and typical) approach for Ubuntu is to install MongoDB using the standard packages: Install MongoDB on Ubuntu. This would allow you to get software updates via the normal apt-get update process.
Yes. It's okay. The 2.6.1 version is a small update with bugfixes after version 2.6. But it's still the same major version.