#start shardsrv
mongod --shardsvr --dbpath ./data/db --port 27018 --smallfiles --logappend
#start configsrv
with --configsvr specified the default port for listening becomes 27019 and the default data directory /data/configdb. Wherever your data directory is, it is suggested that you verify that the directory is empty before you begin.
mongod --configsvr --dbpath ./data/configdb --smallfiles --logappend
#start mongos
mongos --configdb localhost:27019
#connect mongos
mongo
sh.addShard("a/localhost:27018")
to shard a collection, you must have an index on the shard key, so you will need to create the index first
db.trades.ensureIndex( { ticker:1, time:1 } )
sh.enableSharding("week6")
sh.shardCollection("week6.trades",{ticker:1,time:1},false)
use config
db.chunks.find()
db.chunks.find({}, {min:1,max:1,shard:1,_id:0,ns:1})
#start new monogd
mkdir ./data/db2
mongod --shardsvr --dbpath ./data/db2 --port 27020 --smallfiles --logappend
#add Shard in mongos prompt
sh.addShard("a/localhost:27020")
Now wait for the balancer to move data among the two shards more evenly. Periodically run: use config
db.chunks.find( { ns:"week6.trades" }, {min:1,max:1,shard:1,_id:0} ).sort({min:1})
db.chunks.aggregate( [
{ $match : { ns : "week6.trades" } } ,
{ $group : { _id : "$shard", n : { $sum : 1 } } }
] )
Tuesday, November 5, 2013
Build MongoDB Replica Set
Prepare DB Directories
mkdir -p /data/rs1 /data/rs2 /data/rs3Configure Replica Set
Now start three mongo instances as follows. Note that are three commands. The browser is probably wrapping them visually../mongod --replSet ing --logpath "1.log" --dbpath /data/rs1 --port 27017 --smallfiles --fork
./mongod --replSet ing --logpath "2.log" --dbpath /data/rs2 --port 27018 --smallfiles --fork
./mongod --replSet ing --logpath "3.log" --dbpath /data/rs3 --port 27019 --smallfiles --fork
Now connect to a mongo shell and make sure it comes up
./mongo --port 27017
Now you will create the replica set. Type the following commands into the mongo shell:
config = { _id: "ing", members:[
{ _id : 0, host : "localhost:27017"},
{ _id : 1, host : "localhost:27018"},
{ _id : 2, host : "localhost:27019"} ]
};
rs.initiate(config);
At this point, the replica set should be coming up. You can type
rs.status()
to see the state of replication.
config = { _id: "ing", members:[
{ _id : 0, host : "localhost:27001"}
]
};
rs.initiate(config);
Other Replicaset Operation
rs.add("localhost:27002")
rs.add("localhost:27003")
rs.remove("localhost:27001")
Friday, November 1, 2013
Subversion Configuratioin Sample
Add below entries into /etc/apache2/conf.d/subversion.conf
<IfModule mod_dav_svn.c>
<Location /test>
DAV svn
SVNPath /srv/svn/test
AuthType Basic
AuthName "Test Repository"
AuthzLDAPAuthoritative Off
AuthBasicProvider ldap
AuthLDAPURL "ldap://ldap.goweekend.ca/dc=goweekend,dc=ca?uid?sub?(ldappermission=svntest)"
REQUIRE valid-user
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
<Location /training>
DAV svn
SVNPath /srv/svn/training/
Require valid-user
<LimitExcept GET PROPFIND OPTIONS REPORT>
AuthType Basic
AuthName "SVN Training"
AuthUserFile /srv/svn/training/conf/svnpasswd
AuthzSVNAccessFile /srv/svn/training/conf/authz
</LimitExcept>
</Location>
</IfModule>
<IfModule mod_dav_svn.c>
<Location /test>
DAV svn
SVNPath /srv/svn/test
AuthType Basic
AuthName "Test Repository"
AuthzLDAPAuthoritative Off
AuthBasicProvider ldap
AuthLDAPURL "ldap://ldap.goweekend.ca/dc=goweekend,dc=ca?uid?sub?(ldappermission=svntest)"
REQUIRE valid-user
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
<Location /training>
DAV svn
SVNPath /srv/svn/training/
Require valid-user
<LimitExcept GET PROPFIND OPTIONS REPORT>
AuthType Basic
AuthName "SVN Training"
AuthUserFile /srv/svn/training/conf/svnpasswd
AuthzSVNAccessFile /srv/svn/training/conf/authz
</LimitExcept>
</Location>
</IfModule>
Subscribe to:
Posts (Atom)