How to install earlier version of mongodb with homebrew?
我在OSX6.8上,需要安装早期版本的MongoDB,如何使用自制安装早期版本?以下内容不起作用:(
1 2 3 4 5 | dream-2:app2 star$ brew install mongodb-2.6.10 Error: No available formula for mongodb-2.6.10 Searching formulae... Searching taps... dream-2:app2 star$ |
((**edit:我收到一条消息来解释这篇文章与另一篇文章相比是如何独特的,那么,另一个问题的答案是非常长和复杂的,它是针对PostgreSQL的,并没有真正回答我的问题。))
我安装了最新版本的Mongo,谢谢。
1 | brew install mongodb |
但有时我想换个旧版本。首先,安装它:
1 2 3 |
现在我想要3.2在我的路径上,而不是最新的:
1 2 3 |
(它需要
现在我有了3.2。我可以终止正在运行的数据库并启动测试数据库。
完成后,我可以切换回最新版本:
1 2 3 |
然后重新启动。
当尝试用自制软件安装旧版本时,通常从
因此,要安装该版本:
1 | brew install homebrew/versions/mongodb26 |
我可以使用以下说明安装它:
Installing MongoDB on OSX for local development
Over the last week, I’ve been building our MongoDB cluster on EC2 for
production. For development, however, we’ll still need to install
MongoDB locally. I’m running OSX 10.6.8, but these install
instructions should be the same on all modern OSX versions.Installing on OSX is much more pleasant than on EC2 (actually it’s just as easy on EC2, but since it’s a simpler setup there’s n real configuration or
head scratching).Download the latest binary:
curl -O http://fastdl.mongodb.org/osx/mongodb-osx-x86_64-2.0.2.tgz Note!: If
you don’t have wget installed, simply download the file above by
visiting the link in your web browser and move it into your home
directory.We’re going to install everything under /usr/local/mongodb
to keep things organized.Create the directories (switch 'youruser' with your home user name):
sudo mkdir /usr/local/mongodb
sudo mkdir /usr/local/mongodb/log
sudo mkdir/usr/local/mongodb/data
sudo chown youruser /usr/local/mongodb/log
sudo chown youruser /usr/local/mongodb/data
sudo chgrp staff /usr/local/mongodb/log
sudo chgrp staff /usr/local/mongodb/data Un-tar the binaries and move them into the correct folder:
tar -xvzf ~/mongodb-osx-x86_64-2.0.2.tgz
sudo mv ~/mongodb-osx-x86_64-2.0.2/* /usr/local/mongodb/ Create a config file for mongod:
sudo vi /usr/local/mongodb/mongod.conf Paste:
dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/log/mongod.log
logappend=false
bind_ip=127.0.0.1 Note: dbpath and logpath specify the path to their
respective files, logappend is set to overwrite the log file on each
start of the database server, bind_ip only allows local connections.Create an alias so that issuing mongod always read the config file:
vi ~/.profile Paste:
# MongoDB Alias'
alias mongod="/usr/local/mongodb/bin/mongod --config=/usr/local/mongodb/mongod.conf" All done, you should be able to simply type mongod after you reload the shell to start MongoDB. I
preferred not to start mongod on boot, but there are other who prefer
to and there’s plenty of documentation online to show you how to set
that up with launchd and creating a .plist.
http://alexanderwong.me/post/15259867190/installing-mongodb-on-osx-for-local-development
您可以使用Docker安装MongoDB的任意多个版本,而不是使用自制的。然后,每个MongoDB可以在单独的端口上运行。
用
验证它是否与
除了JoeyWiddle的优秀答案:
如果您不想链接,然后取消链接旧版本的软件,您可以从BREW安装的"地下室"(
1 | /usr/local/Cellar/[email protected]/3.6.7/bin/mongo |
1 2 3 4 5 6 7 8 | curl -O https://fastdl.mongodb.org/osx/mongodb-osx-x86_64-3.2.12.tgz tar -zxvf mongodb-osx-x86_64-3.2.12.tgz mkdir -p mongodb cp -R -n mongodb-osx-x86_64-3.2.12/ mongodb export PATH=<mongodb-install-directory>/bin:$PATH #path to the dir created in step 3 mkdir -p /data/db sudo chown -R $(whoami) /data/ mongod |