LoginSignup
0
0

More than 5 years have passed since last update.

Homebrewで前のバージョンのmongodbをインストールしてみた

Last updated at Posted at 2019-02-22

業務でmongo_shellを使用することになった。
社内に導入手順はあったがWindows向けのみだったため、Homebrewでインストールすることにした。
こちらの記事を参考にさせてもらいました。

Homebrewのパッケージをアップデート

$ brew update

MongoDBをインストール

$ brew install mongodb
Warning: You are using macOS 10.11.
We (and Apple) do not provide support for this old version.
You will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Discourse, Twitter or IRC. You are responsible for resolving any issues you
experience, as you are running this old version.

mongodb: A full installation of Xcode.app 8.3.2 is required to compile this software.
Installing just the Command Line Tools is not sufficient.
Xcode 8.3.2 cannot be installed on macOS 10.11.
You must upgrade your version of macOS.
Error: An unsatisfied requirement failed this build.

ん?
OSのバージョンが古い?

そうだったーーー!!
環境作り直しの時間がないというのを理由(言い訳)に随分前からOSのバージョンを上げてなかった・・・。

バージョン確認

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.6
BuildVersion:   15G22010

はい、10.11.6(OS X El Capitan)でしたー
何世代前だ・・・・

素直にOSを最新にするか・・・・Mojave
ダークモードがなんとかって同僚も言ってたっけ?

いやいや、今はいち早くmongoからデータを抽出しなければならなかった
Homebrew使うのも久しぶりだから、思い出してみよう

インストールできるMongodbを確認

$ brew search mongodb
==> Formulae
mongodb                                            mongodb@3.0                                        mongodb@3.2                                        mongodb@3.4                                      mongodb@3.6                                        percona-server-mongodb

==> Casks
mongodb                                                      mongodb-compass-community                                    mongodb-compass-readonly                                     nosqlbooster-for-mongodb                                     homebrew/cask-versions/mongodb-compass-beta
mongodb-compass                                              mongodb-compass-isolated-edition                             mongodbpreferencepane                                        orelord-mongodb

おおお、前のバージョンがあるじゃん!
ひとまず3.6を入れてみよう!

$ brew install mongodb@3.6
:
:
Error: An unsatisfied requirement failed this build.

うん、ダメだ・・・さらに落とす

$ brew install mongodb@3.4
:
:
==> mongodb@3.4

インストール成功♪

一応確認

$ brew list
autoconf    git     go      grep        icu4c       mongodb@3.4     mysql       node        openssl     openssl@1.1 pcre        pkg-config  rbenv       readline    ruby-build  scons       wget

PATHに追加

$ echo 'export PATH="/usr/local/opt/mongodb@3.4/bin:$PATH"' >> ~/.bashrc
$ source ~/.bash_profile

動くか確認

$ mongo
MongoDB shell version v3.4.18
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.18
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
Server has startup warnings:
2019-02-06T12:50:07.069+0900 I CONTROL  [initandlisten]
2019-02-06T12:50:07.069+0900 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-02-06T12:50:07.069+0900 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-02-06T12:50:07.069+0900 I CONTROL  [initandlisten]
>

なんとか動いた!
業務で使ってみると

WARNING: shell and server versions do not match

とWARNINGは出るものの必要なデータの抽出はできた。
とりあえずは、これでやり過ごして早急にOSを上げよう

今回の教訓

  • 仕事にかまけて開発環境のメンテをおろそかにしていると痛い目を見る
  • 意外となんとかなる(こともある)のでやれることはやってみる
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0