MacにMongoDBをインストール

liquidfunc2010-10-07

仕事で使う機会に恵まれたので、さっそくインストール!!

MacPortsでインストールしようかな?

MacPortsのインストールや各種アクションについては、以前にエントリーで書いてあるので興味があれば覗いてみてください。具体的なMacPortsの説明 - Liquidfuncの日記

AIR: ~$port search mongodb
mongodb @1.6.3 (databases)
    High-performance, schema-free document-oriented database

py25-pymongo @0.15.2 (python, databases)
    Python access to mongodb

py26-pymongo @1.9 (python, databases)
    Python access to mongodb

Found 3 ports.

mongodb @1.6.3がインストールできるようですね。続いて、依存関係を見てみます。

AIR: ~$port deps mongodb
Build Dependencies:   scons
Library Dependencies: boost, pcre, spidermonkey, libpcap, readline
AIR: ~$port deps scons
Library Dependencies: python26
AIR: ~$port deps python26
Library Dependencies: gettext, zlib, openssl, sqlite3, db46, ncurses, gdbm,
                      bzip2, readline
AIR: ~$port deps boost
Build Dependencies:   boost-jam
Library Dependencies: zlib, expat, bzip2
AIR: ~$port deps pcre
Library Dependencies: readline, zlib, bzip2
AIR: ~$port deps spidermonkey
Build Dependencies:   readline
Library Dependencies: nspr
AIR: ~$port deps libpcap
libpcap @1.1.1_0 has no dependencies.
AIR: ~$port deps nspr
nspr @4.8.6_0 has no dependencies.
AIR: ~$port deps readline
Library Dependencies: ncurses
AIR: ~$port deps ncurses
Runtime Dependencies: ncursesw
AIR: ~$port deps ncursesw
ncursesw @5.7_0 has no dependencies.

依存関係大杉ですね。時間かかりそうだし、これら依存関係全部の更新作業とか面倒なので、MacPorts経由のインストールはあきらめました。

普通にインストールすることに

ダウンロードする

MongoDB Download Center | MongoDB

/usr/local へコピー
AIR: Downloads$sudo cp mongodb-osx-x86_64-1.6.3.tgz /usr/local
展開・解凍
AIR: local$sudo tar -xzvf mongodb-osx-x86_64-1.6.3.tgz 
mongodb-osx-x86_64-1.6.3/
mongodb-osx-x86_64-1.6.3/bin/
mongodb-osx-x86_64-1.6.3/bin/bsondump
mongodb-osx-x86_64-1.6.3/bin/mongo
mongodb-osx-x86_64-1.6.3/bin/mongod
mongodb-osx-x86_64-1.6.3/bin/mongodump
mongodb-osx-x86_64-1.6.3/bin/mongoexport
mongodb-osx-x86_64-1.6.3/bin/mongofiles
mongodb-osx-x86_64-1.6.3/bin/mongoimport
mongodb-osx-x86_64-1.6.3/bin/mongorestore
mongodb-osx-x86_64-1.6.3/bin/mongos
mongodb-osx-x86_64-1.6.3/bin/mongosniff
mongodb-osx-x86_64-1.6.3/bin/mongostat
mongodb-osx-x86_64-1.6.3/GNU-AGPL-3.0
mongodb-osx-x86_64-1.6.3/README
mongodb-osx-x86_64-1.6.3/THIRD-PARTY-NOTICES
ディレクトリ名をシンプルに mongodb へと変更
AIR: local$sudo mv mongodb-osx-x86_64-1.6.3/ mongodb
不要になったtgzファイル削除
AIR: local$sudo rm mongodb-osx-x86_64-1.6.3.tgz 

起動してみる

データ格納用ディレクトリを作っておく
mkdir /Users/electronica/mongodb_data
起動する
AIR: bin$pwd
/usr/local/mongodb/bin
AIR: bin$./mongod --dbpath=/Users/electronica/mongodb_data &

動いていることを確認

AIR: bin$./mongo
MongoDB shell version: 1.6.3
connecting to: test
Thu Oct  7 03:46:23 [initandlisten] connection accepted from 127.0.0.1:49480 #1
>


とりあえずインストールまで完了。あとはhttp://www.mongodb.org/pages/viewpage.action?pageId=5079135やって、Javaのドライバのソース(GitHub - mongodb/mongo-java-driver: The Java driver for MongoDB)読んでおくのと、http://ursm.jp/mongoとか、ECサイトでPHP×MongoDBを使ってみた - ECサイト運営開発記を参考にサンプルアプリケーションをJavaScalaで作るあたりまでやっておきたい。
いろいろ調べてみて気づいたのは、日本語の情報が多いということ。注目度高いんですね。

洋書だけど書籍もあるみたい。

MongoDB: The Definitive Guide

MongoDB: The Definitive Guide

The Definitive Guide to MongoDB: The NoSQL Database for Cloud and Desktop Computing (Expert's Voice in Open Source)

The Definitive Guide to MongoDB: The NoSQL Database for Cloud and Desktop Computing (Expert's Voice in Open Source)

MongoDB for Web Development (Developer's Library)

MongoDB for Web Development (Developer's Library)