Archive for August, 2007

Bluetooth, Headsets, Ubuntu, and You!

Monday, August 13th, 2007

Tired of having my co-workers laughing at me for not having skype set up (yes, I am still trying to figure out the internal mic) I decided to look into pairing my Samsung WEP170. The solution is pretty quick and dirty.

You’ll need to install several tools, which you can do without I’m not sure but here’s what I have installed so far to pair both my phone and the headset:

bluez-btsco
bluez-pin
bluez-utils
gnome-bluetooth
kdebluetooth
libbluetooth
libbtcl4
libgnomebt0
nautilus-sendto
qobex

For this exercise, though, we’ll be making use of bluez-btsco, bluez-pin, and kdebluetoothd. So after installing the packages modprobe btsco:

$ sudo modprobe snd-bt-sco

Turn on the headset and grab the MAC address:

$ hcitool scan

Copy it and get set up to enter the devices pin number when pairing:

$ passkey-agent –default /usr/bin/bluez-pin

In another terminal type the following with that MAC address you copied:

$ btsco -v BL:UE:TO:OT:HM:AC

Turn on the headset for pairing, in the case of the Samsung it means holding the power down until the light goes solid. If all goes well the passkey-agent should pop looking for the pin of the headset and once that is entered the device should pair and the little KBluetoothD icon should be in your notification area. To use it with Skype I just needed to configure it to use the headset which showed up as a secondary ALSA device with the prefix of BT.

Now, there are two ways to get your headset connected quickly one is to create a little script that issues the btsco command sans the -v and launch it whenever you turn the headset on or you can use the GUI tool found here but that requires you run it as sudo (or gksudo for pure, unadulterated GUI-ness). Other than that this is pretty easy, quick, and dirty. ;-)

Gratefully cribbed from this post and that post on Ubuntu forms as well as the discussion at the tool’s website.

A Weekend

Monday, August 13th, 2007

Grape Leaf on Sunrise

 

Sentinel

 

The Weeks: Thirty

Doing Time

White Goat

Why I Am Not A Gamer Anymore or How I came to choose Vi over Emacs

Sunday, August 12th, 2007

A couple of weekends ago as Management and I slowly shuffled through a Target we passed by the videogames section only to be brought up short. For months I had been breezing by this section with the hope of spotting a Wii and on this day sat three in the display case. Three available for purchase. We stopped and stared.

“Just buy it!,” exclaimed Management with an edge of irritation in her voice, “For months you have bemoaned the lack of stock, extolled the virtues of its games, and basically acted like a whiny twelve-year old. So just buy the damn thing!”

Shifting from foot to foot I hesitated. I stepped forward only to rock back on my heel. Why did I want this again? When was the last time I actually played the consoles we already own? Making a quick calculation, scrunching my face up at Management I attempt to come up with the last time I fired up a game: fourteen months. Gaming has not happened in any shape or form in over a year. We have a Gamecube gathering dust, an Xbox which has been unplugged since before Gabriella was born, and a GBA which goes everywhere with me yet is never turned on and used.

So I stood there with my wife slowly rocking the baby in the carriage. I thought back on why I jumped into gaming in my late twenties and how it ended so abruptly. It was an escape when I needed it the most and like most escapist pursuits evaporates when the impetus moves on. Gaming kept my sanity during grad school but shortly after finishing I found myself playing less and for shorter periods of time. The first usurper was Linux when I decided to go full-time with Ubuntu 4.10, then it was the house, followed by the dog, the baby, then photography, and work. Life pressed in and squeezed things out leaving only the essentials, the people and things I love the most: family, reading, Linux, and learning.

The cliche is true: life presents choices but at times it forces the choice. My choice of Vi over Emacs is just that, a forced choice. Having been a longtime Nano user–its learning curve is like steep downward slope–I was never motivated to learn anything else as I could always pull it into something like Gedit or Bluefish to do something crazy like search and replace. My new job eschews a windowed environment and I found Nano’s quaint limitations to be powerful frustrations. My decision of Vi over Emacs was simple: crontab -e launches Vi. The decision was handed to me.

Like passing over Emacs not gaming doesn’t leave me wondering what I am missing. Standing in Gamestop with my brother-in-law yesterday while he bought a copy of Gears of War I pursued the collection of DS games. There were many that seemed fascinating and certianly looked fun but I found myself questioning when I would play them and how the cost of a DS and a handful of games would put a dent in my lens budget I walked back to wait in line with him.

When we got back to his house he hustled to the livingroom to play the game while I sat outside on his deck in the cooling evening. With my daughter on my knee I talked with my in-laws and the kid who lives next door about first jobs, first loves, and simple pleasures. My wife leaned over and asked I would rather go inside and play a few levels. No, I replied, I’m happy right here and now.

EC2, MySQL, Replication, and You!

Tuesday, August 7th, 2007

One week in and I’m just beginning to get my head around the EC2 way of doing things which is different than what I am used to doing in meatspace with a pile of hardware as well as being worlds away from my Microsoft background. So after tackling a couple of minor projects like Monit + Mongrel, and playing with Memcached, I decided tackle a simple replication setup to get my feet wet in preparation for building a cluster.

After hammering my head against the wall for a day or so things clicked after realizing that this exercise is so much easier if I use the private DNS for plumbing rather than laying ssh tunnels all over the place, which by the way sort-of-kind-of-not-really worked.

Prologue – Create Your World

Look, it is a well known fact that the 9 or so GB that Amazon gives you on the main partition isn’t going to cut it so you have to make some changes to your MySQL environment. The best place for bins and logs are on /mnt. So, since I am epically lazy, I created a mysql directory in /mnt, passed ownership to mysql:mysql, backed up /var/lib/mysql, created a symbolic link to mysql, and then cp -a the contents of the old /var/lib/mysql into /mnt/mysql. Why the backup? Well, if your MySQL instance ever goes down it’ll take the contents of /mnt with it and having a copy of it helps with a speedy recovery.

Step One – Be The Master

Add or edit the following line in /etc/mysql/my.cnf
log=/mnt/mysql/log/mysql.log
server-id=1
log-bin=/var/log/mysql/mysql-bin.log
binlog-do-db=babygotdb

log=/var/lib/mysql/mysql.log (this part is important for seeing whether or not data is replicating)

Restart MySQL then launch the client and issue the following command to add a user with replication privileges:

GRANT REPLICATION SLAVE ON *.* TO ‘replicant’@'%’
IDENTIFIED BY ‘replicantsarepeopletoo’;

FLUSH PRIVILEGES;

Now use the database so we can finish things off…

USE babygotdb;

We want to clear any read locks before we move on so,

FLUSH TABLES WITH READ LOCK;

Now we want to check if what we set up looks like right:

SHOW MASTER STATUS;

This will tell you about the database File, Position, Binlog_Do_DB, and Binlog_Ignore_DB. You will need to know both the file and the position. In this case mine has the following:

File – mysql-bin.000023
Position – 3617723
Binlog_Do_DB – babygotdb
Binlog_Ignore_DB -

You should see something similar to that though it will be in a different format.

quit;

Now is when we dump the database and get it ready to ship over to the slave server.

$ mysqldump -B babygotdb | gzip > babygotdb.sql.gz

Then just scp it to the slave.

Step Two – Get To Know Your Slave

Like on the master we need to make some changes to /etc/mysql/my.cnf

server-id=2
master-host=domU-12-34-56-78-90-1A.usma1.compute.amazonaws.com
master-user=replicant
master-password=replicantsarepeopletoo
master-connect-retry=60
replicate-do-db=babygotdb
log=/var/lib/mysql/mysql.log

Restart mySQL and then launch the client and we have only a little more work to do until we are done.

Gunzip your SQL dump then jump into the mysql client as we need to create our replicated database:

CREATE DATABASE babygotdb;

Then we need to suck in what we dumped on the master:

SOURCE babygotdb.sql;

Stop the slave from running:

SLAVE STOP;

And get our environment ready for replication (this is one long command with each component marked out with commas)

CHANGE MASTER TO
MASTER_HOST=’domU-12-34-56-78-90-1A.usma1.compute.amazonaws.com’,
MASTER_USER=’replicant’,
MASTER_PASSWORD=’replicantsarepeopletoo’,
MASTER_LOG_FILE=’mysql-bin.000023′, MASTER_LOG_POS=3617723;

Now start the slave back up…

SLAVE START;

Watch the replication happen in real time:

$ tail -f /var/lib/mysql/mysql.log

If all is working properly you should be seeing transactions flying by on both as changes are made in the master database.

Gratefully cribbed from Phillip Pearson over at Second p0st and the HowTo Forge write up by falko.

My long term goal is to create images of slaves, masters, data nodes, and management nodes so that deployment will require less hammering on the forge and more tying up loose ends.

Gabriella’s In Lockdown

Sunday, August 5th, 2007

Just slide the cookie through the slot.

Towering

I watch and I wait.

Closing out the first week: Monit, Mongrel, and MySQL

Friday, August 3rd, 2007

One of the things I’ve realized with this new position is that I am my own worst taskmaster, driving myself to work longer hours in tightly focused stretches of time rarely punctuated by breaks. I suppose on some level that I feel like I need to be even more productive because of the absence of “face-time”, that there is no boss leaning over me making sure that I at least have the appearance of being busy. In contrast, though, I really am enjoying the work and the challenge that it presents, so I often feel that itch in the back of my brain to tray and solve the puzzle before I go to bed.

What have I been working on? Well, half the week was spent training Monit to play nice with Mongrel and I am decently confident that it works as advertised in the test environment. This afternoon we did a test deploy with Capistrano nesting it between Monit stop and start statements and everything appeared to work without a hitch. The challenge we faced with Monit in our environment was that we are unable to actually issue Mongrel starts and stops inside the config file. The solution was to take those statements and drop them into bash scripts, so at the moment I have an kludgey but operational method of fourteen scripts for seven mongrels (one start and one stop). When I get a moment, I plan on cleaning them up and making a single one that executes with variables, ie $ monit-mongrel stop 8001 but at the moment I am epically lazy. If I have the time I would like to figure out what exactly it is about the environment that doesn’t like mongrels being started or stopped inside Monit.

Half of yesterday and all of today I have been pounding my head against a nail studded board trying to get secure replication rolling inside EC2 for our MySQL boxen. The masters and slaves (yes, the developers on the crew with a more PC sensibility have chided me saying that the correct terms are primary and secondary. Fine we can meet in the middle with boss and underling) fire up fine and do what they are supposed to except actually perform replication of any shape, form, or fashion. To pipe them together I went the Stunnel route–could not for the life of me get SSL in MySQL to actually do anything–and I know that something is happening because the moment I issue a SLAVE START; command this shows up in the stunnel logs on the master: 2007.08.03 15:46:10 LOG5[13077:3083316112]: localhost.3306 connected from xx.xx.xx.xx:36769. I’m thinking that possibly it is how I set up the replication account permissions on the master, GRANT REPLICATION SLAVE ON *.* TO ‘replicantsarepeopletoo’@'%.mydomain.com’ IDENTIFIED BY ‘s3KrEtpa5Sw0rd’;. Taking shot in the dark, since I am tunneling the traffic it likely should just be ‘replicantsarepeopletoo’@'localhost’ so when I’m feeling a little less punchy I’m going to take a look at that again but after twelve hours I pretty much hate MySQL and EC2 at the moment.

What I haven’t been doing is taking pictures, writing, reading something other than man pages and long-winded newsgroup threads, and really listening to some of the new albums I just picked up (Nicole Willis & The Soul Investigators – Keep Reachin’ Up and Red Bumb Ball: Rare and Unreleased Rocksteady (1966-1968) are fucking amazing albums though). Hopefully, I’ll find my stride soon and build a sort of groove where I’m not pushing myself so hard that I’m dreaming about how the company abandons it current market focus and I’m forced to look into re-architecting the mongrel cluster for their plans to launch a fried chicken franchise. Yeah, I do need more sleep.