System Administration
I may be a developer at heart, but I love fiddling with Unix too. Shell scripting, sed, awk, firewalls, networking, filesystems, configuration management (e.g. Ansible), maintaing SMTP and DNS servers; it's all good fun.
This section of the blog is full of short scripts, and notes on how to do things that aren't necessarily as obvious as they might be.
Articles on System Administration
-
Installing a specific version of a homebrew package
The homebrew package manager is a great way to install the latest version of lots of open source software on a Mac. It's also quite capable of installing older versions, should you need them, but it's not quite as obvious how you should approach it.
-
Securing Instiki with an SSH tunnel
Wikis are unrivalled for recording your notes, research and relationships between your ideas. If you maintain a private one for your business you'll want to make sure nobody else can get access. I use Instiki, which is only accessible via an SSH tunnel.
-
Showing your laptop battery status in tmux
You can configure the tmux status bar to show pretty much anything you like. To include your laptop battery's current charge, all you need to do is to write a script that prints your current charge level.
-
Downgrading MySQL on Mac OS X
The MySQL installation packages for Mac OS X (on mysql.com) prevent you from downgrading MySQL. They keep track of which versions have been previously installed, and then make the brain dead assumption that you will only ever need to upgrade. It's farcical; even if you remove all copies of MySQL the installer still prevents you from installing an earlier version, unless you know where the silly buggers squirrelled away their nuts.
-
Find performance problems in your web logs
A user recently reported poor performance on one of our Rails apps. I pulled up New Relic's performance graphs and checked what was happening around the time that we received the email. Sure enough there was a massive spike over a 10 minute period in the time taken to serve a request.
-
Installing the pg PostgreSQL gem on Mac OS X
You can connect to a PostgreSQL database from Ruby using the
pg
gem, but if thepg_config
program isn't in your path you'll run into problems during installation.This article is mainly here to provide some Google juice for those who hit the same problem...
-
Installing Merb, DataMapper and Postgres on Ubuntu
This isn't particularly difficult, but if you're not familiar with Postgres on Ubuntu it could take you ten minutes to work it out:
$ sudo apt-get install postgresql-8.2 postgresql-server-dev-8.2 -y $ sudo apt-get install libsqlite3-dev -y $ sudo gem install merb do_postgres
The
merb
gem depends on thedo_sqlite3
DataMapper database driver, so we need thelibsqlite3-dev
package in order to compile it. You can remove it afterwards if you like. -
Deploying Sinatra with Vlad
So you've just written a nice new Sinatra application, and you want to get it running on your web server. How hard can it be? Well with Vlad the Deployer, it's actually rather easy.
-
Configure the Expires header for Rails under nginx
The images, CSS and JavaScript files served up by your Rails application can usually be cached by the web browser, rather than being downloaded every time the browser loads a page on your site. Rails gives you some help here, but it doesn't happen automatically -- you need to configure your web server to set the HTTP Expires header.
-
Removing an entry from /etc/hosts on a Mac
How to remove an entry from the proprietary cached hosts database(s) on Apple Macs.
-
Monitoring BackgrounDRb with God
God is a very neat piece of software, frequently used by Rails developers to monitor mongrel servers, and restart them if/when they crash or use up too many system resources.
Its use isn't limited purely to monitoring web servers though; you can monitor pretty much anything you like. Read on to see how to configure it to monitor the Ruby job processing daemon, BackgrounDRb.
-
Automate your sysadmin with adl
I used to work for a company that was in the business of deploying laptops running Linux into hospitals. We automated the installation of these laptops to such a degree that all we had to do build a new laptop was unwrap it, plug it into an ethernet network and turn it on. We used PXE boot and our own bespoke deployment system to achieve it. It even supported deploying automatic configuration updates over a mobile phone connection, while the laptops were in a different country.
It never seems to be worth going to the effort to setup a tool like puppet when configuring a new desktop computer, a virtual server to run your blog, or a VPS for a small client who is keen to keep the budget down. But why should automation be expensive?
If you like the idea of an automated server build on the cheap, read on...