Automated MySQL Backups

Historically I’ve used the ever-so-popular AutoMySQLBackup script.  While it seems to work just fine, I’ve decided to give another solution a whirl.  This solution, provided through Zmanda, seems to be less hackery and more enterprise.  The instructions are very clear, and the backup test went as planned.  Looks  like this is another gem for the toolchest.

S3 Super Backups

My buddy Ian  mentioned Amazon’s S3 service, and the potential for using it for fun webapps.  While utilizing it for webapps will have to wait a few months, I was able to use it as a cheap backup for my home server (pictures, documents, etc,.) – and my server that houses my email and websites.  The setup is pretty quick, and most of it can be detailed here.  The ruby package is here   I’ll toss in my recommendation to use the jets3t Cockpit application for viewing the buckets, especially considering the Firefox extension didn’t work as advertised.  My only two comments will be this:

  1. Making sure SSL is working.  The site mentioned above just has you hunt down some random bash file, that isn’t even hosted anymore.  On my Debian system I simply added this to my upload.sh:
export SSL_CERT_DIR=/etc/ssl/certs/
  1. The second suggestion is another example of the s2sync layout.  Let’s say you created the bucket “kelvinism” – the following would move the documents inside a test folder from /home/kelvin named test to a folder named test in the kelvinism bucket.  Sweet.
 s3sync.rb -r --ssl --delete /home/kelvin/test kelvinism:/test  

Lighttpd As Apache Sidekick

So, you have a web server. So, you have PHP. So, you want to make it a little quicker? The following are a few ideas to let you do that. First, let me share my experiences.
I have always been wondering “what would a digg do to my site.” I mean, I don’t run a commenting system, so I’m refering to just some article. Because I prefer to manage my own server, I have decided to use a VPS (Virtual Private Server) from VPSLink. Before purchasing I searched around, read reviews, and finally tested it out. Liking what I tested, I stayed. However, since I just host a few ‘play’ sites (http/email/ftp), and a few sites for friends, I am not going to spend much money on a high-end plan. That leaves me with a little problem: how can I maximize what I’ve got?
I’ve tried quite a few things. I finally ended up using Apache to handle php and Lighttpd to serve all static stuff. So, how?

Staticzerize A Page

One of the first things you will need to do is pull down a static copy of your page.

 user@vps:~$ wget http://www.kelvinism.com/howtos/notes/quick-n-dirty-firewall.html 

That was easy enough. Next, let’s create a directory for static pages.

user@vps:~$ sudo mkdir /var/www/html/kelvinism/static
user@vps:~$ sudo mv quick-n-dirty-firewall.html /var/www/html/kelvinism/static/ 

Sweet. (This is assuming of course that the site’s DirectoryRoot is /var/www/html/kelvinism). Next, Lighttpd.

Lighttpd Configuration

Install Lighttpd however you choose. There are a few key changes to make in the configuration.
First, change the directory for your base DocumentRoot. Next, change what ports the server will listen on.

server.document-root = \"/var/www/html\"
## bind to port (default: 80)
server.port = 81
## bind to localhost (default: all interfaces)
server.bind = \"127.0.0.1\"

Ok, Lighttpd is all done. Now just start her up, and move onto Apache.

user@vps:/etc/lighttpd$ sudo /etc/init.d/lighttpd start 

Master Configuration

Depending on your distro and what apache you installed, you might need to do this a little different. I will illustrate how to do it with the Apache package from the Debian repository. Let’s activate the mod_proxy module.

 user@vps:~$ sudo a2enmod
Password:
 Which module would you like to enable?
 Your choices are: actions alias asis auth_basic auth_digest authn_alias authn_anon authn_dbd authn_dbm authn_default authn_file authnz_ldap authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cern_meta cgi cgid charset_lite dav dav_fs dav_lock dbd deflate dir disk_cache dump_io env expires ext_filter file_cache filter headers ident imagemap include info ldap log_forensic mem_cache mime mime_magic negotiation php5 proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http rewrite setenvif speling ssl status suexec unique_id userdir usertrack version vhost_alias

 Module name? proxy_http

If you are not using a system with a2enmod, you can edit your configuration by hand. Just insert the following into your apache2.conf or httpd.conf files:

LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so 

The actual location of the extension (*.so) will vary depending on where you installed it. If you have tried this out and get forbidden errors, or it just simply isn’t working, the reason is because the proxy modules isn’t configured right. You will likely get an error like:

 client denied by server configuration: proxy 

To solve this, you need to edit /etc/apache2/mods-enabled/proxy.conf or your httpd.conf file.

<IfModule mod_proxy.c>
   #turning ProxyRequests on and allowing proxying from all may allow
    #spammers to use your proxy to send email.
    ProxyRequests Off
    <Proxy \*>
        AddDefaultCharset off
        Order deny,allow
        Deny from all
        Allow from .kelvinism.com
    </Proxy>
    # Enable/disable the handling of HTTP/1.1 \\"Via:\\" headers.
    # (\\"Full\\" adds the server version; \\"Block\\" removes all outgoing Via: headers)
    # Set to one of: Off | On | Full | Block
    ProxyVia On
</IfModule>

Now, open up your httpd-vhosts.conf or httpd.conf or wherever your site configuration is stored, and add the following inside the virtualhost directive:

#DocumentRoot is just for reference, I assume you know how to setup virtualhosts.

DocumentRoot /var/www/html/kelvinism/
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /howtos/notes/quick-n-dirty-firewall.html http://127.0.0.1:81/kelvinism/stat ic/quick-n-dirty-firewall.html 
ProxyPass /images/ http://127.0.0.1:81/kelvinism/images/ 
ProxyPassReverse / http://127.0.0.1:81/kelvinism/

As an alternative, you could use a rewrite rule.

#DocumentRoot is just for reference, I assume you know how to setup virtualhosts.
DocumentRoot /var/www/html/kelvinism/
RewriteEngine On
RewriteRule ^/howtos/notes/quick-n-dirty-firewall\.html$
http://127.0.0.1:81/kelvinism/static/quick-n-dirty-firewall.html [P,L]
ProxyPass /images/ http://127.0.0.1:81/kelvinism/images/
ProxyPassReverse / http://127.0.0.1:81/kelvinism/
 

So what this does is pass the page http://www.kelvinism.com/howtos/notes/quick-n-dirty-firewall.html through mod_proxy to Lighttpd. So, test it out, and you are all done!

Make Dynamic Sites Static

Let’s say one page on your site is getting hit hard. And I mean, it was digg’d or something. If the page resides on some CMS or blog, and each request is being processed by PHP and resulting in requests to your database, which, as they say, crap is gonna hit the fan. Well, at least if you’re cheap like me, you’ll try to squeeze every penny out of what you’ve got.
That said, mod_rewrite comes to the rescue.
There are only a few modifications that you need to do. The first is to ensure that mod_rewrite is enabled. If you have apache installed on debian, this might do:

user@vps:~$ sudo a2enmod
Password:
Which module would you like to enable?
Your choices are: actions alias asis auth_basic auth_digest authn_alias authn_anon authn_dbd authn_dbm authn_default authn_file authnz_ldap authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cern_meta cgi cgid charset_lite dav dav_fs dav_lock dbd deflate dir disk_cache dump_io env expires ext_filter file_cache filter headers ident imagemap include info ldap log_forensic mem_cache mime mime_magic negotiation php5 proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http rewrite setenvif speling ssl status suexec unique_id userdir usertrack version vhost_alias
Module name? rewrite 

Otherwise, you’ll need to drop the following in your apache2.conf (or httpd.conf).

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

Next, grab the page that is getting hit hard from your site.

user@vps:~$ wget http://www.kelvinism.com/stuff/hit-hard.html

Next, let’s create a static directory and move that page into it.

user@vps:~$ sudo mkdir /var/www/html/kelvinism/static
user@vps:~$ sudo mv hit-hard.html /var/www/html/kelvinism/static/

Coolio. Now we’ll rewrite the normal URL (the one being hit hard) to the static URL.
If you have full access to the server, just mimic the following to a VirtualHost:

<VirtualHost *>
    DocumentRoot /var/www/html/kelvinism
    ServerName www.kelvinism.com
    ServerAlias kelvinism.com www.kelvinism.com
<Directory \"/var/www/html/kelvinism\">
    Options Indexes -FollowSymLinks +SymLinksIfOwnerMatch
    allow from all
    AllowOverride None
    RewriteEngine On
    RewriteRule ^stuff/hit-hard\\.html$ /static/hit-hard.html [L]
</Directory>
</VirtualHost>

If you don’t have access to the server, you can just add the following to a .htaccess file:

RewriteEngine On
RewriteRule ^stuff/hit-hard\\.html$ /static/hit-hard.html [L]

Sweet.

MySQL Compat

I’ve run into this error quite a few times, might as well toss blog entry about it:
ERROR 1064 at line 17: You have an error in your SQL syntax near ‘ENGINE=MyISAM DEFAULT CHARSET=latin1’ at line 7
One likely reason this comes about is because the data being imported/exported is not compatible with the database version. For instance, at home you export the information from a mysql5 database. Then you try to import it on a mysql3.23 database somewhere else – and it fails on you. Bummer.
The solution is quite simple:

 mysqldump --compatible=mysql323 -u root -p database > exportName.sql

MCSE: Security

Status: ✅

My buddy Ian and myself have decided to get our MCSEs. However, Ian is a Mac lover, and I can’t seem to stay away from Linux (and I’m too cheap right now to buy a MacBook). The irony might be subtle, yet we are still studying and making progress. For the most part, I have decided to take the tests in the following order:

70-290, Security+, 70-270, 70-291, 70-293, 70-294, 70-298, 70-299

Update: So, now I’m MCSE. I’m still debating whether or not to do the final Security test. I really need to get caught up with Exchange, so I might do the Messaging test at some point, but who knows. At this point I’m calling it good.

Core Exams: Networking System

✅ Exam 70-290: Managing and Maintaining a Microsoft Windows Server 2003 Environment

✅ Exam 70-291: Implementing, Managing, and Maintaining a Microsoft Windows Server 2003 Network Infrastructure (notes)

✅ Exam 70-293: Planning and Maintaining a Microsoft Windows Server 2003 Network Infrastructure

✅ Exam 70-294: Planning, Implementing, and Maintaining a Microsoft Windows Server 2003 Active Directory Infrastructure

Core Exams: Client Operating System

✅ Exam 70-270: Installing, Configuring, and Administering Microsoft Windows XP Professional

Security Specialization: Core Design

✅ Exam 70-298: Designing Security for a Microsoft Windows Server 2003 Network

Security Specialization:Core Security

✅ Exam 70-299: Implementing and Administering Security in a Microsoft Windows Server 2003 Network

✅ CompTIA Security+

Resize a Xen Image

So, you’ve got a few Xen images around, and they are starting to fill up. How do you add a few more gigs to ’em?

 root@tpe:/# xm shutdown vm01  
 root@tpe:/# cd /xenimages  
 root@tpe:/xenimages# dd if=/dev/zero bs=1024 count=1000000 >> vm01.img  
 root@tpe:/path/to/images# resize2fs -f vm01.img  
 

That’s it, you just added a gig to your image called ‘vm01.img’.

Katapult Screencast

Ian keeps bugging me at how great Quicksilver is. Knowning that there must be an alternative built for linux, I accidently stumbled across Katapult.

While it still has a little room to grow, Katapult makes a great tool in any KDE toolchest. Press ALT+SPACE, and your widget fires up, ready to take your orders. Since words don’t really do this justice, I created a screencast.

Katapult Screencast from Kelvin Nicholson on Vimeo.

Xen + nVidia

Status: ✅

I’ve played with quite a bit of virtualization, especially VMWare for ages. About eight months ago I started to play around with Xen, and got it to work great, except for the fact that the nvidia driver wouldn’t work with the Xen kernel. That said, I’m gonna give another go.

Throughout senior high, and especially my last year, I managed to score a bunch of old motherboards and random parts and pieces. Six or so years later, my parents are still finding old motherboards. Considering these computers were mainly P120s with 64-128 megs of RAM, they weren’t so hot. What is one to do?

As you could guess, when I started university I had quite a few computers in my room. I had about three or so P120s (one in a hampster cage, don’t ask), one AMD600, an AMD1ghz and one iBook (500 whooping mhz). Computers would die, get replaced, but overall they worked quite well. Considering almost all the computers ran Linux (the AMD1ghz also ran Windows – to play games – and the iBook sort of ran OSX – and YDL), every system was quite happy. I had an OpenBSD box as my gateway. Life was good.

But now I don’t like having five+ systems. Electricity alone is a strong factor, plus, I don’t really want to manage all those systems. Plus noise.

Because of this, I have two systems: my workstation/test lab, and my laptop. I hopefully will never need anything more. But, because of thise, I needed Xen to play nice with my Nvidia closed source driver – which when I tested it eight months or so ago, it wasn’t. Since then I have been using Linux-Vserver, and while it works great, my requirements have started to change.

Luckily Nvidia has released a few new updates, and a few hackers have patched the driver to include support for a xen-based kernel. Maybe I’ll write up a tutorial at some point.

Since I’ve already done the creation of the doms before, and it is somewhat similar to Vserver, everything went smoothly. You can expect some fun screencasts and experiments in the near future.

Open Source Video Editing

In the next year I plan to make a little video, nothing fancy likely, but something that will require an editor. However, I don’t own a mac (which rules our Final Cut Pro + After Effect and iMovie, which Ian and I both have had too much fun with. Inside joke.) I’m also a die-hard Linux fan, trying to hold out buying a mac for as long as possible.

SF to the rescure. There are four editors listed, and in the next year I’ll try them all. Overalll, they look quite promising.

Jahshaka – Beta. Good reviews from what I’ve seen.
Kdenlive – Alpha/Beta. Looks a lot less mature than Jahshaka, especially since I’m going to have to check it out via svn. But, the screenshots look quite impressive.
LiVES – Beta.