CentOS5.5にMongoDBをyumでインストールしてみる
10genのリポジトリを追加してyumでインストールしてみました。
/etc/init.d/mongodを見ると、起動ユーザ:mongod、
設定ファイル/etc/mongod.confになっています。
設定ファイルにログやDBのパスが記述されてます。
インストールログ
# vi /etc/yum.repos.d/10gen.repo # yum update Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * addons: ftp.riken.jp * base: ftp.riken.jp * extras: ftp.riken.jp * updates: ftp.riken.jp 10gen | 951 B 00:00 10gen/primary | 2.2 kB 00:00 10gen 9/9 Setting up Update Process No Packages marked for Update # yum install mongo-stable.x86_64 mongo-stable-debuginfo.x86_64 mongo-stable-server.x86_64 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * addons: ftp.riken.jp * base: ftp.riken.jp * extras: ftp.riken.jp * updates: ftp.riken.jp Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package mongo-stable.x86_64 0:20101028-mongodb_1 set to be updated ---> Package mongo-stable-debuginfo.x86_64 0:20101028-mongodb_1 set to be updated ---> Package mongo-stable-server.x86_64 0:20101028-mongodb_1 set to be updated --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================== Package Arch Version Repository Size ======================================================================================================================== Installing: mongo-stable x86_64 20101028-mongodb_1 10gen 19 M mongo-stable-debuginfo x86_64 20101028-mongodb_1 10gen 1.8 k mongo-stable-server x86_64 20101028-mongodb_1 10gen 4.3 M Transaction Summary ======================================================================================================================== Install 3 Package(s) Upgrade 0 Package(s) Total download size: 24 M Is this ok [y/N]: y Downloading Packages: (1/3): mongo-stable-debuginfo-20101028-mongodb_1.x86_64.rpm | 1.8 kB 00:00 (2/3): mongo-stable-server-20101028-mongodb_1.x86_64.rpm | 4.3 MB 00:03 (3/3): mongo-stable-20101028-mongodb_1.x86_64.rpm | 19 MB 00:13 ------------------------------------------------------------------------------------------------------------------------ Total 1.2 MB/s | 24 MB 00:19 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : mongo-stable 1/3 Installing : mongo-stable-debuginfo 2/3 Installing : mongo-stable-server 3/3 Installed: mongo-stable.x86_64 0:20101028-mongodb_1 mongo-stable-debuginfo.x86_64 0:20101028-mongodb_1 mongo-stable-server.x86_64 0:20101028-mongodb_1 Complete!
/etc/yum.repos.d/10gen.repo
インストール時に手動で作成、MongoDBのサイトに載っていたまま。
CentOS5.5の記述はエントリ作成時にはなかったので5.4のものを使用。
http://www.mongodb.org/display/DOCS/CentOS+and+Fedora+Packages
[10gen] name=10gen Repository baseurl=http://downloads.mongodb.org/distros/centos/5.4/os/x86_64/ gpgcheck=0
/etc/mongod.conf(インストールされたデフォルト)
# mongo.conf #where to log logpath=/var/log/mongo/mongod.log logappend=true # fork and run in background fork = true #port = 27017 dbpath=/var/lib/mongo # Enables periodic logging of CPU utilization and I/O wait #cpu = true # Turn on/off security. Off is currently the default #noauth = true #auth = true # Verbose logging output. #verbose = true # Inspect all client data for validity on receipt (useful for # developing drivers) #objcheck = true # Enable db quota management #quota = true # Set oplogging level where n is # 0=off (default) # 1=W # 2=R # 3=both # 7=W+some reads #oplog = 0 # Diagnostic/debugging option #nocursors = true # Ignore query hints #nohints = true # Disable the HTTP interface (Defaults to localhost:27018). #nohttpinterface = true # Turns off server-side scripting. This will result in greatly limited # functionality #noscripting = true # Turns off table scans. Any query that would do a table scan fails. #notablescan = true # Disable data file preallocation. #noprealloc = true # Specify .ns file size for new databases. # nssize = <size> # Accout token for Mongo monitoring server. #mms-token = <token> # Server name for Mongo monitoring server. #mms-name = <server-name> # Ping interval for Mongo monitoring server. #mms-interval = <seconds> # Replication Options # in replicated mongo databases, specify here whether this is a slave or master #slave = true #source = master.example.com # Slave only: specify a single database to replicate #only = master.example.com # or #master = true #source = slave.example.com # Address of a server to pair with. #pairwith = <server:port> # Address of arbiter server. #arbiter = <server:port> # Automatically resync if slave data is stale #autoresync # Custom size for replication operation log. #oplogSize = <MB> # Size limit for in-memory storage of op ids. #opIdMem = <bytes>
ではQuickstartしてみます。
参考URL:http://www.mongodb.org/display/DOCS/Quickstart+Unix
# /etc/init.d/mongod start Starting mongod: all output going to: /var/log/mongo/mongod.log forked process: 4033 [ OK ] # /usr/bin/mongo MongoDB shell version: 1.6.4 connecting to: test > db.foo.save( { a : 1 } ) > db.foo.find() { "_id" : ObjectId("4cd1a3723962dc1668ec271c"), "a" : 1 } > exit bye