I first ran brew install mongodb, which successfully completed and installed version 3.4.4. I was then able to start the server using brew services start mongodb, and access the shell via running mongo.
Then I discovered I need mongodb version 3.2.0. I uninstalled mongo v3.4.4 via brew uninstall mongodb and verified service was gone and bin files removed.
I then ran brew search mongodb and found mongodb#3.2 in the list, and so ran brew install mongodb#3.2. This completed successfully, and I was able to start the server using brew services start mongodb#3.2, which is successful. I then go to access the shell via 'mongo', or 'mongo#3.2' or 'mongo32' and none of these exist.
What should this bin file be named and why can't I find it? with v3.4.4 shell bin executable was /usr/local/bin/mongo - this file doesn't exist after installing 'mongodb#3.2'.
I see it in /usr/local/Cellar/mongodb#3.2/3.2.11/bin/ along with all the other binaries.
I don't know why it isn't symlinked to /usr/local/bin/ like most other programs.
Related
I run a MongoDB replica set in a containerization environment orchestrated by Rancher.
After rolling out the latest update, MongoDB as been upgraded from 3.6.x to 4.0.x (latest).
No upgrade path has been followed and, as a result, when trying to bind the volume holding the database storage, the service fails to start, exiting with the following exception:
STORAGE [initandlisten] exception in initAndListen: MustDowngrade: Collection does not have UUID in KVCatalog. Collection: admin.system.version, terminating
I get the same outcome even attempting to launch mongod with the --repair option.
I have also tried to rollback the container to MongoDB 3.6.16, but the journal version is now incompatible.
We don't have snapshots of the volume, hence restoring the data is not an option (this is not a production environment). The only solution I've found online is not applicable, since it suggests to leverage mongodump and mongorestore, requiring a running database with the data storage attached.
I'm running out of ideas, any advice about how to fix this?
A bug report on this issue recommended following the full upgrade path and that worked for me. I was able to go back to my old version when I ran into this error, and then upgrade properly.
Specifically: upgrade just one major version at a time and check the prerequisites and upgrade steps carefully. The most important part of this is checking your compatibility with db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) and make sure it matches the current version before upgrading to the next version. Update it with command like db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
Read the full docs at pages like https://docs.mongodb.com/manual/release-notes/3.6/#upgrade-procedures https://docs.mongodb.com/manual/release-notes/4.0/#upgrade-procedures etc
I was updating MongoDB from 3.6 to 4.2 with Homebrew on Mac OS, and ran into this similar situation.
Since formula mongodb was removed from homebrew-core, the team of mongodb maintained a custom Homebrew tap.
Following steps is my solution for upgrading MongoDB from 3.6 to 4.2 with Homebrew:
Uninstall old version mongodb from Homebrew
# If you run mongodb in background service, stop it first.
brew services stop mongodb
# If you have multiple version of mongodb, you might need to add `--force` option for deleting all of them at once.
brew uninstall mongodb
Install new mongodb from custom Homebrew tap
brew tap mongodb/brew
brew install mongodb-community#3.6
Add mongodb-community#3.6 to your PATH
echo 'export PATH="/usr/local/opt/mongodb-community#3.6/bin:$PATH"' >> ~/.bash_profile
Restart your terminal, and run mongod
Open another tab or terminal windows to run mongodump
Terminate mongod
Uninstall mongodb-community#3.6 and reinstall mongodb-community
brew uninstall mongodb-community#3.6
brew install mongodb-community
Delete old data with old mongo data structure
rm -rf /data/db/*
Run mongod
Open another tab or terminal windows to run mongorestore dump/
Once mongorestore completed, mongod will be terminated.
And you can run mongodb as a background service or just run mongod again. Open MongoDB with mongo or Robo 3T(formerly Robomongo), you will see your data is good as usual.
Hope it helps.
Alright after about 3hours of trying to fix exactly what you are describing, here are the steps I took. Here I will show how to retain the data while downgrading to 3.6 and also how to update it 4.0 with the retained data.
The reason this happens for mac users is because there was an update for people using brew can no longer download Mongodb directly from brew. Then people tend to download the newer community edition instead from brew which then gets in conflict the old version of 3.6 db folder still present in the directory. Instead you would need to download it from the actual mongodb website:
https://www.mongodb.com/download-center/community
Here what you would want to do, is download everything manually. Follow these instructions here, but do this with the 3.6 version:
https://medium.com/#saurabhkumar_4718/install-mongodb-without-homebrew-on-mac-os-2a98b68ab09c
NOTE: when you copy .bash_profile please make sure export commands are not
Once you have successfully installed 3.6 manually you can mongodump to be safe, and or export all your mongo data into json with mongoexport for any data that you must really really save.
After that you can fresh install 4.0 manually again by following exactly the same steps as previously done for 3.6
This worked for me without having to do any 'mongorestore' as the 'db' folder was left alone and all my data was there, but maybe extra steps might be needed to restore the data. Worst comes to worst you have .jsons that needs to be rewritten. 'mongo --version' also showed the right version :) Hope it helps
Backing-up all the databases (using mongodump)
Removing every file in /data/db, due to their incompatibility with the newer version: rm -rf /data/db/*
Restarting the MongoDB service by mongod
Restoring all the databases (using mongorestore)
https://dba.stackexchange.com/a/252393
For Docker:
I had this issue when I was upgrading a project that used Docker from 3.6 to 4.2 (and 4.4).
The way the project is set up means I don't have a physical /data/db directory to purge.
However, there is a volume defined that acts as the /data/db directory.
In this case all you need to do is backup any data you need and remove the associated volume.
If using vs code with the docker extension, you can simply open your docker tab in the sidebar, expand the volumes section, locate the volume in question (for me it was called mongo-4-2-upgrade-test_mongo-data which depends on how your various containers are named for your project), right-click and remove.
Ensure that the containers that use this volume have been properly shut down or you'll get a 409 conflict error. I did the same as above but found my mongo container (in the containers section of the docker tab) instead. then when I restarted my docker-compose file the new version of mongo was installed and ran as expected.
After upgrading Postgres via Homebrew and running brew postgresql-upgrade-database to migrate the database, the output shows Running this script will delete the old cluster's data files: ./delete_old_cluster.sh
Where can the script delete_old_cluster.sh be found? It's not in the current working directory.
found mine in /usr/local/var/log along with the other installation logs
used this command to find it:
find / -name delete_old_cluster.sh
I installed MongoDB manually on the MongoDB website. https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
I followed the instructions under "Install MongoDB Community Edition Manually".
How do I uninstall MongoDB completely? I have searched around and only found how to uninstall using Homebrew. I did not install MongoDB using Homebrew.
Any help is greatly appreciated.
Just follow the manual install steps in reverse order:
shutdown mongod
remove your data directory (if you no longer want this)
remove the directory with the MongoDB binaries
remove the directory with the MongoDB binaries from your shell PATH
Other files that might have been created depending on how you ran MongoDB:
there may be old log files to remove if you specified a --logpath outside your data directory
there may be a launchctl script and configuration file to remove if you configured mongod to run as a service
I am getting the following error when I run create extension postgis;
ERROR: could not open extension control file "/Library/PostgreSQL/9.6/share/postgresql/extension/postgis.control": No such file or directory
I am using Postgres 9.6.3 and PostGIS 2.3.2 installed using Homebrew on OS X El Capitan.
mdfind -name postgis.control shows:
/usr/local/Cellar/postgis/2.3.2/share/postgresql/extension/postgis.control
brew info postgis shows:
PostGIS extension modules installed to:
/usr/local/share/postgresql/extension
When I start the Postgres console I see:
psql (9.6.3, server 9.6.1)
I read a similar question, PostGIS Homebrew installation referencing an old path?, and tried to reload postgresql using the commands given in the top answer, but I am still seeing psql (9.6.3, server 9.6.1). Also, I believe my issue is different because it's looking for the extension control file in /Library and not /usr/local/Cellar.
Any help would be appreciated.
When you try to install postgis it install latest version of postgresql along with it as dependency.
So if you installed postgres#V (where V is user desired version )
brew install postgresql#V
later you run this command
brew install postgis
it will install postgres10.1 or whatever is latest.
So after that if run
create extension postgis;
In postgresql#V it will try to check its extension directory and it won't find postgis.control in extension directory as this postgis is installed in extension folder of postgresql version that is installed with that.
To solve this problem, you have to create a symlink from given installation of postgis to the desired postgresql#V
This example for postgresql#9.6
ln -s /usr/local/share/postgresql/extension/postgis* /usr/local/Cellar/postgresql#9.6/9.6.6/share/postgresql#9.6/extension/
ln -s /usr/local/lib/postgresql/postgis-2.3.so /usr/local/Cellar/postgresql#9.6/9.6.6/lib/postgis-2.3
ln -s /usr/local/lib/postgresql/rtpostgis-2.3.so /usr/local/Cellar/postgresql#9.6/9.6.6/lib/
before running these commands, please check postgresql version and file path in your system
Thanks this gist for help.
I had a similar problem with full details here. When the server is mentioned in your Postgres console, it means that you're referencing an older codebase. Stop that server and launch the correct server with the following commands.
$ brew services list
That will give you a list of database servers that are running.
$ brew services stop postgresql#<older-version>
$ brew services start postgresql
As mentioned above, I need to install only the mongo shell on a RHEL instance (machine A).
I have a mongodb server on a separate instance (machine B) and need to connect to that from A to run mongodump and mongorestore commands.
I tried looking it up on the web but all I got was instructions to install the complete mongodb package.
Any help appreciated.
Official documentation says that you should be fine installing mongodb-org-shell only.
Create a repository file at sudo vim /etc/yum.repos.d/mongodb.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
gpgcheck=1
enabled=1
sudo yum clean all
sudo yum install mongodb-org-shell-4.0.2
mongo <mongo-server-ip> Note: Step 4 will not work in all cases. You need to check proper command to connect to remote mongo server.
Source: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
You can follow the official tutorial on installing mongodb, and instead of installing the main package that will install all the packages, just install the package containing mongoshell
Please follow below steps.
Create a file /etc/yum.repos.d/mongodb.repo
Update the above file to contain:
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
sudo yum install -y mongodb-org-shell-2.6.9
mongo mongo-db_server_IP:27017/database_name -u username -p password
You might want to install mongosh (MongoDB Shell) instead. The legacy mongo shell has been deprecated since MongoDB v5.0 and replaced by mongosh. From the mongosh docs:
The new MongoDB Shell, mongosh, offers numerous advantages over the
legacy mongo shell, such as:
Improved syntax highlighting.
Improved command history.
Improved logging.
Currently mongosh supports a subset of the mongo shell
methods. Achieving feature parity between mongosh and the mongo shell
is an ongoing effort.
To maintain backwards compatibility, the methods that mongosh supports
use the same syntax as the corresponding methods in the mongo shell.
To see the complete list of methods supported by mongosh, see MongoDB
Shell Methods.
Further reference: Compatibility Changes with Legacy mongo Shell
Head to Mongo download page; download your required package regarding your operating system. Finally follow the instruction of your operating system to install the package.
Especially to install mongo or mongosh:
download .tgz file and untar the file into /usr/local/
add /usr/local/mongo/ into the shell profile (e.g. ~/.bashrc) and restart your terminal
For more information read the docs.
P.S.: mongo in the path should be vary based on the version of the downloaded package.