Mongo DBのインストール

Cassandraに続いて,Mongo DBのインストールについて備忘録を取る。MongoはKey-Valueストア,NoSQLデータベースであり,ドキュメントデータベースとしての使用に特化している。

プラットフォームとしては,前回のCassandra 0.7.4と同じマシンを使用した。(Fedora 14 64bit)

Fedora向けに,yumリポジトリは用意されていないが,公開されていて,自分でリポジトリファイルを作ることによってYumによるインストールが可能になる。

まず,以下の内容を /etc/yum.repos.d/10gen.repo というファイルに作る。もちろん,root権限でやること。

$ cat /etc/yum.repos.d/10gen.repo
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0

なお,32bit OSの場合は,baseurlの最後のx86_64をi686(i386ではないので注意)に換えるだけでいい。

あとは,Mongoのパッケージをyumでインストールするだけだ。
パッケージは,サーバーと,クライアントで別々になっている。

Mongo DBサーバーのパッケージ名はmongo-10gen-server,クライアントはmongo-10genである。
サーバーの場合は,両方インストールしないとなにかと不便であろう。

# yum install mongo-10gen mongo-10gen-server

これでインストールはおしまい。非常に簡単である。
あとは,Mongo DBをサービスとして立ち上げればいい。サービス名はmongodである。

# service mongod start

これで,MongoDBは使用可能な状態になる。一般ユーザーにもどって,Mongoのshellである,mongoコマンドを使ってみる。

$ mongo
MongoDB shell version: 1.8.1
connecting to: test
> help
db.help() help on db methods
db.mycoll.help() help on collection methods
rs.help() help on replica set methods
help connect connecting to a db help
help admin administrative help
help misc misc things to know
help mr mapreduce help

show dbs show database names
show collections show collections in current database
show users show users in current database
show profile show most recent system.profile entries with time >= 1ms
use set current database
db.foo.find() list objects in collection foo
db.foo.find( { a : 1 } ) list objects in foo where a == 1
it result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x set default number of items to display on shell
exit quit the mongo shell
>

とりあえず,今回はインストールまで。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です