Skip to content

Instantly share code, notes, and snippets.

@knife0125
Last active December 15, 2015 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knife0125/5326490 to your computer and use it in GitHub Desktop.
Save knife0125/5326490 to your computer and use it in GitHub Desktop.

mongoDBのインストール

前提

  • CentOS6.4の64bitがインストールされていること
  • 以下の操作はrootで実行することを想定していること

mongoDB用のrepoファイルを作成

touch /etc/yum.repos.d/10gen.repo
vi /etc/yum.repos.d/10gen.repo

下記を10gen.repoファイルへ記載

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=0

10gen.repoを有効にするオプションを付けてmongoDBをインストール

yum --enablerepo=10gen install mongo-10gen mongo-10gen-server -y

バージョンを指定してインストール

yum --enablerepo=10gen install mongo-10gen-2.2.3 mongo-10gen-server-2.2.3 -y

yumでmongoDB関連がアップデートされないように設定

vi /etc/yum.conf
exclude=mongo-10gen,mongo-10gen-server

※上記で作成した10gen.repoファイルで、enable=0としているためyum update時にmongoDBまでも自動でアップデートされることはないように思われるが、万全を期するなら設定する。

mongoDBの起動

mongo-serverの起動

service mongod start

サーバ起動時にmongoDBも起動するように設定

chkconfig mongod on

mongo-clientの起動

mongo  
MongoDB shell version: 2.4.1
connecting to: test
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
>

mongoDBの設定

各種ディレクトリ

設定ファイル

/etc/mongod.conf

データ関連

mongoDBのプロセスを実行する権限によって、以下のディレクトリのパーミッションには注意が必要

データのストアディレクトリ

/var/lib/mongo

ログディレクトリ

/var/log/mongo
/var/log/mongo/mongod.log ----- mongo-serverプロセスの実行ログを参照可能
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment