# This is an config file for MongoDB master daemon mongod
# it is passed to mongod as --config parameter
logpath = /var/log/mongodb/mongod.log
dbpath = /var/lib/mongodb/
# use 'true' for options that don't take an argument
logappend = true
bind_ip = 127.0.0.1
#noauth = true
> help
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 <db name> set curent database to <db name>
db.help() help on DB methods
db.foo.help() help on collection methods
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
めぼしいものをちょっと叩いてみる。show dbsしてみる。
1234
> show dbs
admin
local
test
show collectionsしてみる。スキーマレスなだけあってmysqlみたいに事前にcollectionを
つくらなくても値を入れるとcollectionが出来るのかexampleがある。
123
> show collections
example
system.indexes
show usersしても何もでない。db.example.find({a:1})してみる
12
> db.example.find({a:1})
{ "_id" : ObjectId("4f50783e7dcfb0a8e8fc8a32"), "a" : 1 }
> db.example.help
function () {
print("DBCollection help");
print("\tdb.foo.count()");
print("\tdb.foo.dataSize()");
print("\tdb.foo.distinct( key ) - eg. db.foo.distinct( 'x' )");
print("\tdb.foo.drop() drop the collection");
print("\tdb.foo.dropIndex(name)");
print("\tdb.foo.dropIndexes()");
print("\tdb.foo.ensureIndex(keypattern,options) - options should be an object with these possible fields: name, unique, dropDups");
print("\tdb.foo.find( [query] , [fields]) - first parameter is an optional query filter. second parameter is optional set of fields to return.");
print("\t e.g. db.foo.find( { x : 77 } , { name : 1 , x : 1 } )");
print("\tdb.foo.find(...).count()");
print("\tdb.foo.find(...).limit(n)");
print("\tdb.foo.find(...).skip(n)");
print("\tdb.foo.find(...).sort(...)");
print("\tdb.foo.findOne([query])");
print("\tdb.foo.getDB() get DB object associated with collection");
print("\tdb.foo.getIndexes()");
print("\tdb.foo.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )");
print("\tdb.foo.mapReduce( mapFunction , reduceFunction , <optional params> )");
print("\tdb.foo.remove(query)");
print("\tdb.foo.renameCollection( newName ) renames the collection");
print("\tdb.foo.save(obj)");
print("\tdb.foo.stats()");
print("\tdb.foo.storageSize() - includes free space allocated to this collection");
print("\tdb.foo.totalIndexSize() - size in bytes of all the indexes");
print("\tdb.foo.totalSize() - storage allocated for all data and indexes");
print("\tdb.foo.update(query, object[, upsert_bool])");
print("\tdb.foo.validate() - SLOW");
print("\tdb.foo.getShardVersion() - only for use with sharding");
cd /usr/local/src
git clone git://github.com/sstephenson/ruby-build.git
cd ruby-build
./install.sh
ruby-build 1.9.3-p125 /usr/local/ruby-1.9.3-p125
for i in `ls /usr/local/ruby-1.9.3-p125/bin/`; do ln -s /usr/local/ruby-1.9.3-p125/bin/$i /usr/local/bin/$i; done