Archive for 2011

Post

So You Have A JFRV ?

In Uncategorized on September 1, 2011 by Wenzi

I am posting this for those who cannot find this information in Chinese.  This is the law that says you can work if you are married to a Taiwanese person.

 

You can find the whole law here http://laws.cla.gov.tw/Chi/FLAW/FLAWDAT0201.asp

法規名稱 : 就業服務法 

Ok, go down to paragraph 48. It is the second line

第   48    條
雇主聘僱外國人工作,應檢具有關文件,向中央主管機關
申請許可。但有 下列情形之一,不須申請許可: 
一、各級政府及其所屬學術研究機構聘請外國人擔任顧問或研究工作者。 
二、外國人與在中華民國境內設有戶籍之國民結婚,且獲准居留者。 

Oh , I read Chinese too.

Comments Off

Post

Running MongoDB Completely in RAM

In sysadmin on August 11, 2011 by Wenzi Tagged: , ,

The project I am working on runs test cases constantly ( and you should too ) that are constantly creating and destroying MongooDB databases.

All those database allocations ( Mongo allocating the datafile ) was taking a lot of time on this not small project.

So with a need for speed, we put the database in RAM. This is how, if you need more speed , you can run Mongo completely in RAM.

/home/me# mkfs -q /dev/ram1 32768
/home/me# mkdir -p /ramcache
/home/me# mount /dev/ram1 /ramcache

[1] Make a filesystem in ram. mkfs makes a /dev in ram of the specified size. In this case 32M ( 32768 ), but you will have to make a bigger one for mongo, greater than 192M.

[2] Make a mount point. We need a directory to ‘attach’ the ram filesystyem so normal applications can access it as part of the file system.

[3] Mount the drive. Mount the ram drive on the mount point you just made.

To test it, we run mongodb with the ramcach as the datapath.

mongod –dbpath /ramcache/ –port 29019

 

Looking at the directory from another terminal window ( or tmux ) we can see that the lock file was created.

me@li132-23:~$ ls -la /ramcache/
total 18
drwxrwxrwx 3 root root 1024 Aug 11 04:36 .
drwxr-xr-x 22 root root 4096 Aug 11 04:31 ..
drwx------ 2 root root 12288 Aug 11 04:30 lost+found
-rwxr-xr-x 1 me me 6 Aug 11 04:37 mongod.lock

Now we can connect to the mongo server.

mongo --host localhost:29019

Now it just acts like a regular server, because it is, just running in RAM.

> use wenzi
switched to db wenzi
> doc = { author : 'wenzi', post : 'Water : the new Coke' }
> db.posts.insert(doc);

Comments Off

Post

Learning Xen With the Book Of Zen

In sysadmin on August 10, 2011 by Wenzi Tagged: , , ,



IF YOU ARE STARTING XEN
I do recommend this book. It is a little dated ( about two years ) but it is still a good read.

The book is put out by No Starch press which has an hippy/indie bookseller feel to it.it is also fifty bucks which is sort of pricy.

They mainly focus on the ‘free’ versions of Xen. If you bought Xen, this book will still help you get a better feeling about Xen.

WHAT I LIKE

There is good stuff in the book on using Xen and system administration. Written in a pretty plain style with an emphasis on the what and why of system administration.

In other words, it doesn’t suck.

WHAT I HATE

I hate the cover. Really. I have been trying to find some rhyme or reason for it, but I cannot except for one. One of the authors drew it.

I kept finding myself wanting to hate the book because of the cover & illustrations, but I didn’t. Like I said before, it is published by No Starch press. They seem to be really bad at cover design. I am sure they would say ‘creative’, ‘eccentric’, or ‘artistic’. I just think …. bad.

Comments Off

Post

Rotating MongoDB Log Files with Logrotate

In sysadmin on August 3, 2011 by Wenzi Tagged: , , , , ,

Rotating log files is something sys admins are all familiar with doing. There are a few ways to backup MongoDB, with the most common are the logRotate command and logrotate.

I prefer runCommand(“logRotate”) to rotate my log files. I administer a couple of MongoDB instalations and I check on them every day, and for those I prefer rotating them manually.

I do still have a mongoDB that is my little orphan server that runs logrotate. It just runs and I check on it every few weeks. For this one I use log rotate to make sure my disks do not fill up.

But theare are some people who prefer using logroatate, just because they are old school. I am one of those for everything but mongo.

So if you are used to logrotate, here is a script for you. You will have to change the parts for your own setup of course.

This server only ones one mongod ( yes, bad but this is not a critial machine ). If you are running more than one instnce the you will have to make changes obviously.

Place this in the file /etc/logrotate.d/mongodb

/var/log/mongodb/*.log {
	rotate 52
	size 50M
	compress
	weekly
	dateext
	missingok
	notifempty
	sharedscripts
	postrotate
		/bin/kill -SIGUSR1 `cat /var/lib/mongo/mongod.lock 2> /dev/null` 2> /dev/null || true
	endscript
}

Cheers

Comments Off

Post

Mongo Clusters are Like Driving a Big Boat

In Uncategorized on July 28, 2011 by Wenzi Tagged: , ,

Mongo Clusters are Like Driving a Big Boat.

CLUSTERS CAN BE BIG

The things about clusters, any clusters, is that a lot of things go any to do anything. That is the nature of clusters. They are like turning a big boat in the ocean as compared to a jet ski.

A change is communicated among the nodes in a cluster, passing through different servers. Now the smaller the cluster, the less things have to talk to each other.

A cluster of one ( as in a single machine ) is instantaneous. A cluster of a thousand may take a lot more time for what ever you are doing to propagate through the cluster.

This brings us to mongo. When you are dealing with a cluster , it is a conversation. You tell / ask a mongo cluster to do something, and it goes off and does it. It will let you know when it is done.

SHARDING AGAIN

Think about a sharding mongo DB cluster. You make a change it will take time for whatever you are doing.

Your change may cause the balancer to start moving data from shard to shard, or refreshing a stale node or whatever.

There are tons of things that a mongo cluster could be doing when you issue commands. So here is the takeaway

Let mongo take it’s time and do what it is going to do

if you issue a command to a mongo cluster, realize that it will take time to complete. Let mongo DB do what it is going to do. It may take time, but something is probably happening and jumping to conclusions will not help.

Comments Off

Post

tload for OSX

In Uncategorized on July 25, 2011 by Wenzi

I have been running tload forever on a mac. It it one of my favorite system management tools. I can throw it on a screen halfway across the room and glance how a server is doing. Old school ASCII graphics remind me of the old days when computers looked like computers.

I was making a GeoIP lib package and I thought I might as well package up something I had had laying around just to get a feel for the new Xcode.

Comments Off

Post

MongoDB is the new MySql

In Uncategorized on July 24, 2011 by Wenzi Tagged: ,

I think this article is a little biased, but he is a Red Sox fan and you know how they are.

MongoDB is the new MySql

Comments Off

Post

MongoDB : Making a Specific Node Primary in a Replica Set

In sysadmin on July 24, 2011 by Wenzi Tagged: , , , ,

MongoDB is funny in that you are having a conversation with the cluster than sending commands.

Making a PARTICULAR machine primary is one of those times. Now I will separate the blog into three parts. Pre  Mongo 1.7.2, Mongo 1.7.2 to Mongo 1.9.1 and after Mongo 1.9.1

PRE MONGO 1.7.2

I have no idea, never tried it. If you are still using a pre 1.7.2 version, stop it. Unless you have some reason for sticking to an old version, just move to a newer version.

MONGO 1.7.2 to MONGO 1.9.1

Mongo 1.7.2 introduced ReplFreeze. That is the ability to stop a machine from becoming primary for a certain period of time. For example,

rs.freeze(120)

would stop the node from becoming the primary server for 120 seconds.

You would freeze all the nodes you did not want to become primary and then tell the current primary to step down as primary.  A new election would be held, and all the frozen nodes would decline to be elected to be primary, leaving the one you did not freeze to be primary.

POST MONGO 1.9.1

This is the easiest case. 1.9.1 introduced a variable priority.

You would set the priority of the server you want to become primary higher. If the server you want to become primary is within 10 seconds of the current primary, the current primary will step-down. If it is too far behind, an election would be held when it came within 10 seconds. Or if you cannot wait, you could force the primary to step  down.

db.adminCommand({replSetStepDown:1000000, force:1})

You will be primary less until the higher priority node catches up.

Comments Off

Post

Lion 10.7 – Dropping FTP File Sharing

In sysadmin on July 24, 2011 by Wenzi Tagged: , , , ,

I just installed 10.7 on a laptop I am using. No surprise, I like 10.7 except for the crazy scrolling direction which I promptly changed back to normal.  Then I went to ftp some tar archives to it and ftp did not work. Ok, clicked into Settings, Sharing and then File Sharing.

NO FTP

This really sucks, and my first thought was , “I they are not going to include an ftp server i will install one my self”. I , like most people, have been using ftp forever. My favorite client was ncftp.

Then I thought. I had actually been trying to get away from ftp. It was insecure after all. The thing that was holding me back was ncftp.

So I bit the bullet and started using sftp …. and I hate it. just missing so many nice feature of ncftp.

Anyway, my search goes on for a new sftp client. One with things like bookmarks and filename completion.

Comments Off

Post

Please Move Along….nothing to see…yet.

In Uncategorized on July 24, 2011 by Wenzi

I will start bloggin ( again )

Comments Off