Skip to content

Instantly share code, notes, and snippets.

View greglu's full-sized avatar

Greg Lu greglu

  • Swoop.com
  • San Diego, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am greglu on github.
  • I am greglu (https://keybase.io/greglu) on keybase.
  • I have a public key ASBaRgaAT9eF6KW0mv92UiBOxWVKMLOB_lTT5AHZpirAZgo

To claim this, I am signing this object:

@greglu
greglu / check-reserved-instances
Created July 3, 2015 07:06
Checks reserved instance utilization of an EC2 account
#!/bin/bash
# Checks active, non-spot, EC2 instances against the list reserved instances
# in order to determine which availability-zone/instance-type combinations
# are paying for on-demand prices (that could benefit from reserved instance
# purchase), or current reservations that aren't being used.
#
# Dependencies:
# * awscli (http://aws.amazon.com/cli/)
# * jq (http://stedolan.github.io/jq/)
Mon Dec 20 14:55:36 [conn10] building new index on { _id: 1 } for test.shard_test2
Mon Dec 20 14:55:36 [conn10] done for 0 records 0.039secs
Mon Dec 20 14:55:36 [conn10] info: creating collection test.shard_test2 on add index
building new index on { num: 1.0 } for test.shard_test2
Mon Dec 20 14:55:36 [conn10] done for 0 records 0secs
Mon Dec 20 14:55:53 [conn36] got movechunk: { moveChunk: "test.shard_test2", from: "node02/node02.lab.mtl:27020,node03.lab.mtl:27020", to: "node14/node14.lab.mtl:27020,node15.lab.mtl:27020", min: { num: MinKey }, max: { num: 1.0 }, shardId: "test.shard_test2-num_MinKey", configdb: "node01.lab.mtl:27018,node09.lab.mtl:27018,node18.lab.mtl:27018" }
Mon Dec 20 14:55:54 [conn36] _recvChunkStatus : { active: true, ns: "test.shard_test2", from: "node02/node02.lab.mtl:27020,node03.lab.mtl:27020", min: { num: MinKey }, max: { num: 1.0 }, state: "steady", counts: { cloned: 0, catchup: 0, steady: 0 }, ok: 1.0 }
Mon Dec 20 14:55:54 [conn36] moveChunk locking myself to: 2|0
Mon Dec 20 14:55
Mon Dec 20 14:54:57 connection accepted from 127.0.0.1:43476 #80
Mon Dec 20 14:55:35 [conn80] CMD: shardcollection: { shardcollection: "test.shard_test2", key: { num: 1.0 } }
Mon Dec 20 14:55:35 [conn80] enable sharding on: test.shard_test2 with shard key: { num: 1.0 }
Mon Dec 20 14:55:35 [conn80] no chunks for:test.shard_test2 so creating first: ns:test.shard_test2 at: node02:node02/node02.lab.mtl:27020,node03.lab.mtl:27020 lastmod: 1|0 min: { num: MinKey } max: { num: MaxKey }
Mon Dec 20 14:55:38 [conn80] end connection 127.0.0.1:43476
Mon Dec 20 14:55:50 connection accepted from 127.0.0.1:43477 #81
Mon Dec 20 14:55:51 [conn81] autosplitting test.shard_test2 size: 47362436 shard: ns:test.shard_test2 at: node02:node02/node02.lab.mtl:27020,node03.lab.mtl:27020 lastmod: 1|0 min: { num: MinKey } max: { num: MaxKey } on: { num: 1.0 }(splitThreshold 47185920)
Mon Dec 20 14:55:52 [conn81] config change: { _id: "node01.lab.mtl-2010-12-20T19:55:52-21", server: "node01.lab.mtl", time: new Date(1292874952628), what:
// shard_test.js
// we want a lot of data, so lets make a ~50k string to cheat :)
bigString = "";
while ( bigString.length < 50000 )
bigString += "this is a big string. ";
print( "my big string is: " + bigString.length + " characters long" );
// ok, now lets insert a some data
var num = 1;
> db.runCommand( { listshards : 1 } );
{
"shards" : [
{
"_id" : "node02",
"host" : "node02/node02.lab.mtl:27020,node03.lab.mtl:27020"
},
{
"_id" : "node04",
"host" : "node04/node04.lab.mtl:27020,node05.lab.mtl:27020"
development:
adapter: cassandra
keyspace: development
servers: localhost:9160
test:
adapter: cassandra
keyspace: test
servers: localhost:9160
production:
adapter: cassandra
-- This was for a DB class. Don't judge me.
mysql> SELECT * FROM Project;
+-----+-----------+------+
| pid | startyear | cid |
+-----+-----------+------+
| 1 | 2007 | 5 |
| 2 | 2004 | 29 |
| 3 | 2004 | 1 |
| 4 | 2003 | 14 |
09/12/22 14:58:27 INFO ipc.HBaseServer: IPC Server handler 39 on 60020: starting
09/12/22 14:58:27 INFO regionserver.HRegionServer: HRegionServer started at: 192.168.1.122:60020
09/12/22 14:58:27 INFO regionserver.StoreFile: Allocating LruBlockCache with maximum size 408.3m
09/12/22 14:58:27 INFO regionserver.HRegionServer: MSG_CALL_SERVER_STARTUP
09/12/22 14:58:27 INFO regionserver.HLog: HLog configuration: blocksize=67108864, rollsize=63753420, enabled=true, flushlogentries
=100, optionallogflushinternal=10000ms
09/12/22 14:58:27 INFO regionserver.HLog: New hlog /hbase/amsterdam_factory/.logs/factory22.local,60020,1261511907495/hlog.dat.126
1511907500
09/12/22 14:58:27 INFO regionserver.HRegionServer: Telling master at 192.168.1.101:62000 that we are up
09/12/22 14:58:27 FATAL regionserver.HRegionServer: Unhandled exception. Aborting...