Postgres Conference Talk
Python JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
files
1
2
3
4
5
6
7
8
LICENSE
README
app.conf
app.py
commands

README

PostGres

-----

Main points: working set, indexing, infrastructure

-----

Me: KS, CTO, early-adopter.  Mongo by fire.  Python preso.
    %% emacs buffers > context switching
Agenda: GC, me, arch, mongo, terminal.
    %% live code, look, no net!  I'll write javascript before your eyes!
GC: 9p, 2y, i->o. MLB.com nerds, jobs@gc.io.  seriously.
Me: Langs, learning, history.  hacker->nuanced/manager hacker.  DisMath=runtimes, algs, structs!!!
Mongo: GC=(data + media), JSON, Mongo, completely insane.
    %% 10gen remains 1 feature release ahead.  Barely (sharding).
    %% urban dictionary
Arch: API, JSON, LAMP->LNMP?

Yay:

team = {"name": "NYC Jaguars", "sport": "baseball"}
mongo.datadb.team.save(team) # omg wow

Next: 1 year in 30 min.  Working sets.  Scaling in place.

nohup mongod --port 30000 --dbpath /data/0/ --replSet node1 --logpath ~/mongo.0.log --logappend 2>&1>> mongo.0.log &
killall -2 mongod

nohup mongod --port 30000 --dbpath /data/0/ --replSet node1 --logpath ~/mongo.0.log --logappend 2>&1>> mongo.0.log &
mongo localhost:30000
> show dbs
> db.stats()
> use data
> db.thingoes.save({a: 1, b: 2, x: true})
> db.thingoes.find()
> db.thingoes.stats()

nohup mongod --port 30001 --dbpath /data/1/ --replSet node1 --logpath ~/mongo.1.log --logappend 2>&1>> mongo.1.log &
nohup mongod --port 30002 --dbpath /data/2/ --replSet node1 --logpath ~/mongo.2.log --logappend 2>&1>> mongo.2.log &

mongo localhost:30000
> rs.initiate()
> rs.add("localhost:30001")
> rs.addArb("localhost:30002")
> use data
> db.thingoes.save({a: 7, x: true})
> db.thingoes.find()
> db.thingoes.stats()

mongo localhost:30001
> show dbs
> use data
> show collections
> db.getMongo().setSlaveOk()
> db.thingoes.find()
> db.thingoes.save({a: 5, x: false})

mongo localhost:30000
> rs.status()
> rs.stepDown()

mongo localhost:30001/data
> for ( var i = 0; i < 100000; i++ ) { db.thingoes.save({a: i, x: (i%11==0)}); }
> ""
> ""
> db.currentOp()
> db.thingoes.ensureIndex({x: 1}, {background: true, sparse: true})
> for ...
> db.thingoes.ensureIndex({a: 1})

nohup mongod --configsvr --logpath ~/mongo.config.log --logappend --cpu 2>&1>> ~/mongo.config.log &
nohup mongod --port 40000 --logpath ~/mongos.log --configdb AirKiril.local:27019 2>&1>> ~/mongos.log &

mongo localhost:40000/admin
> use admin
> db.runCommand({addshard: 'node1/AirKiril.local:30000'})
> db.printShardingStatus()
> show dbs
> use data
> show collections
> db.thingoes.count()

nohup mongod --port 30003 --dbpath /data/3/ --replSet node2 --logpath ~/mongo.3.log --logappend 2>&1>> mongo.3.log &

mongo localhost:40000/admin
> db.runCommand({addshard: 'node2/AirKiril.local:30003'})

mongo localhost:30003
> rs.initiate()
> rs.status()

mongo localhost:40000/admin
> db.runCommand({addshard: 'node2/AirKiril.local:30003'})
> db.printShardingStatus()
> db.runCommand({enablesharding: 'data'})
> db.printShardingStatus()
> db.runCommand({shardcollection: 'data.thingoes', key: {a: 1}})
> db.printShardingStatus()

mongo localhost:30001/data
> db.thingoes.count()

mongo localhost:30003/data
> db.thingoes.count()

mongo localhost:40000/admin
> db.printShardingStatus()
> db.runCommand({moveChunk: 'data.thingoes', find: {a: 1}, to: 'node2'})
> db.printShardingStatus()

mongo localhost:30001/data
> db.thingoes.count()

mongo localhost:30003/data
> db.thingoes.count()

mongo localhost:40000/data
> db.thingoes.save({x: true})
> db.thingoes.save({x: true, a: 777777})

nohup mongod --port 30004 --dbpath /data/4/ --replSet node2 --logpath ~/mongo.4.log --logappend --cpu 2>&1>> mongo.4.log &
nohup mongod --port 30005 --dbpath /data/5/ --replSet node2 --logpath ~/mongo.5.log --logappend --cpu 2>&1>> mongo.5.log &

mongo localhost:30003
> rs.add('AirKiril.local:30004')
> rs.addArb('AirKiril.local:30005')
> rs.status()
> rs.stepDown()