Sunday, February 14, 2016

So, I plan to move my tech posts off of Blogger and on to Wordpress. Going forward, I will be posting to I may decide to use a custom domain in the future, but for now it is what it is. Why am I doing this? Well, Blogger has become too cluttered for me. My new theme is much cleaner and more up-to-date, too. For now, my old posts will remain here, but I will eventually move them, maybe. :D

Saturday, April 4, 2015

Docker - Remove All Containers by Image Name or ID

As I monkey around with Docker, I find that it is sometimes useful to remove all the containers based on the same image in a single command. So , without further ado, create a file in your PATH named docker-rmall and paste the following code into it: #!/bin/bash
docker rm $(docker ps -a | grep $1 | awk '{ print $1 }' | grep -v CONTAINER)
Make sure you grant executable permissions on the file. Now, to remove all of the containers associated with a particular image, you can simply run: docker-rmall <some_image_name_or_id>

Wednesday, September 25, 2013

VirtualBox - Allowing one hosts file to rule them all

So, I started using a nice feature on VirtualBox for simple DNS mappings. If you are using a NAT interface on your guest virtual machine, you can set up the host to resolve DNS requests for each guest. This is especially handy for me when setting up host-only networks for guests because it eliminates the need for a dedicated DNS server and I can simply rely on the host OS for lookups. Simply run the following for each guest VM you want it to apply to:

VBoxManage modifyvm "My VM Name" --natdnshostresolver1 on

Now, you can configure some simple DNS using the hosts file on your host machine and the guest VMs will see the changes as if you edited the hosts file on each of them. Of course, if you have more robust needs, running a dedicated DNS server will probably be more appropriate.

Friday, September 13, 2013

Good Things To Know About Vanilla MySQL Installation

I just wanted to share this video posted by Philip Thrasher. It points out some ugly default behavior from MySQL that devs and db admins should be aware of.

Wednesday, August 14, 2013

Run Elasticsearch as a Service on Windows 2003/2008 Server

UPDATE: As of Elasticsearch release 0.90.5, there is a default Windows service included in elastic search. So, instead of following this guide... upgrade!!!

If you'd like to run Elasticsearch (or any batch or executable file for that matter) as a service on Windows 2003 Server, it's pretty simple and straight-forward. I didn't have a Windows 2008 Server license available to tinker with, but it seems like it's even easier.

Windows 2003 Server

The steps outlined in this section involve editing the registry on your server. If you are not comfortable editing the registry then look elsewhere. See this article for information on backing up and restoring the registry.
  1. Download and extract Elasticsearch to C:\elasticsearch. Make sure you have a Java Runtime Environment (JRE) installed on your system and that you have the JAVA_HOME environment variable configured correctly on your machine and that you can actually get Elasticsearch running before continuing to the next step.
  2. We need srvany.exe on the machine. So, to get that, install Windows Resource Kits if it's not already installed (default installation is C:\Program Files\Windows Resource Kits)
  3. From a command prompt do the following:
    cd "C:\Program Files\Windows Resource Kit\Tools"
    instsrv.exe elasticsearch "C:\Program Files\Windows Resource Kits\Tools\srvany.exe"
  4. Now you should have the registry editor open. In the registry editor go to: HKEY_LOCAL_MACHINE > SYSTEM > CurrentControlSet > Services
  5. Find elasticsearch in the list and right-click on it. Choose New > Key and name the key Parameters
  6. Right-click on the Parameters key and choose New > String Value. Change the name of this value to Application.
  7. Right-click on the Application value and choose Modify, then in the Value data field enter C:\elasticsearch\bin\elasticsearch.bat
  8. Open the Services control panel (Start > Control Panel > Services) and find the elasticsearch service. You will notice that the service is by default set to start automatically when the system starts. Start the service.
*An important note about the configuration described above is that it is good for starting Elasticsearch (or whatever you tell it to), but not good for stopping it. You see, when the service is started, it actually starts srvany.exe with a parameter telling srvany the name of an application to start. In this demo srvany runs elasticsearch.bat which ultimately fires up an instance of java.exe. So, the resulting process that is started is a java.exe process. If you stop the elasticsearch service from the service manager, what it actually stops is the srvany.exe process that was started. If you want to stop Elasticsearch you need to manually stop the java.exe process from the task manager. On the plus-side, if you want to start up additional elasticsearch nodes, you can simply restart the elasticsearch service from the service manager and srvany will launch elasticsearch.bat each time.

Windows 2008 Server

As I mentioned above, I didn't have a Windows 2008 Server license available to tinker with, but from what I can tell you can use the sc create command to achieve the same results. I would be interested to know if this works, so feel free to leave a comment and let me know what you find.
  1. Follow step 1 above
  2. From the command line type the following (note that the command should be all on one line):
    sc create elasticsearch binpath=C:\elasticsearch\bin\elasticsearch.bat start=auto
  3. Follow step 8 above

Wednesday, May 15, 2013

VMware Fusion Sharing Folders with Ubuntu as the Guest Operating System

If you created a new Ubuntu VM in VMWare Fusion and told it to automatically mount your home folder only to find out that, after you finished set-up, it wasn't mounted, don't worry. It's easy to fix. In fact, this is just a really quick post to say that, if you're looking to get shared folders working on Ubuntu with VMware Fusion, the instructions in the VMware knowledge base regarding installing VMware tools on Ubuntu are correct, but there's one caveat... you need to have the build-essential and linux-headers packages installed first. Here are all of the steps on one page:

  1. While your VM is running, in your host environment select Virtual Machine > Install VMware Tools (or Virtual Machine > Reinstall VMware Tools).
  2. Make sure you have the build-essentials and linux-headers packages installed sudo apt-get install build-essential
    sudo apt-get install linux-headers-`uname -r`
    *chances are, the linux-headers are already installed, but just in case
  3. Choose Virtual Machine > Reinstall VMWare Tools and click Install to load the VMWare Tools virtual cd-rom.
  4. Now, mount the cdrom to the file system:
  5. sudo mkdir /mnt/cdrom
    sudo mount /dev/cdrom /mnt/cdrom
  6. Extract the VMware Tools to the /tmp/ directory. Note that the x.x.x-xxxx should be replaced with the version numbers on the actual file: tar xzvf /mnt/cdrom/VMwareTools-x.x.x-xxxx.tar.gz -C /tmp/
  7. Change directories to the /tmp/ directory and run the script: cd /tmp/vmware-tools-distrib/
    sudo ./ -d
    *The -d modifier in the last command above tells the installer that you want to accept all of the defaults. If you want to supply your own answers to the installer, do not use this modifier.
  8. Reboot Ubuntu: sudo reboot
  9. When the Ubuntu boots back up, look in the /mnt/hgfs folder and your shared folders should be there: ls /mnt/hgfs

Disclaimer: I tested this using Mac OS X 10.8.3 Mountain Lion as the host operating system and Ubuntu 12.04 Server LTS 64-bit as the guest operating system using VMware Fusion v5.0.3.

Sunday, January 27, 2013

VirtualBox Errors on Ubuntu 12.10 64-bit Desktop Edition

Before you begin

The instructions below are to be followed at your own discretion and at your own risk. It is up to you to execute the commands outlined in this tutorial and is strongly advised that, if you do not understand the implications or repercussions of one or more of the following instructions, you do not proceed.

Now, let's get started:

If you installed the VirtualBox package from apt-get or via the Ubuntu Software Center and afterwards received the following message(s), then this tutorial is for you: VirtualBox - Error

The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

'/etc/init.d/vboxdrv setup'

as root: If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary
VirtualBox - Error

Failed to open a session for the virtual machine <Your Virtual Machine Name>. The virtual machine '<Your Virtual Machine Name>' has terminated unexpectedly during startup with exit code 1.
At the time of this writing, when installing VirtualBox from the package manager on Ubuntu 12.10 64-bit Desktop Edition, the proper package doesn't get installed. In addition, if this is a fresh install of Ubuntu 12.10 64-bit Desktop Edition, you'll be missing some other packages essential for a working VirtualBox installation. To get VirtualBox up and running, do the following:
  • Read ahead and make sure that you are comfortable proceeding. If you want, make a back-up your machine, or, if you are using LVM (Logical Volume Management), take a snapshot of your current machine state.
  • Go to the Oracle VirtualBox downloads page and download the version of the VirtualBox Debian package for your Ubuntu installation into your /home/<your-username>/Downloads directory. Since this post is specifically targeting Ubuntu 12.10 64-bit ("Quantal Quetzal"), that's the version of the package that I downloaded.
  • Next, run the following commands from a terminal: cd ~/Downloads
    sudo apt-get update
    sudo apt-get purge virtualbox-*
    sudo apt-get install dpkg
    sudo apt-get install linux-headers-`uname -r`
    sudo apt-get install build-essential
    sudo dpkg -i virtualbox-*.deb
    sudo /etc/init.d/vboxdrv setup
    sudo usermod -aG vboxusers `whoami`
    The commands above will do the following:
    • Change your directory to /home/<your-username>/Downloads
    • Update your package list
    • Remove any existing VirtualBox installations
    • Makes sure that the Debian package management system is installed (If this is a fresh install of Ubuntu, it will be)
    • Install the linux-headers for the current Linux kernel version
    • Install the build tools for dpkg
    • Install the downloaded VirtualBox Debian package
    • Run the VirtualBox setup
    • Add the current logged-in user to the vboxusers group
  • Now log out and log back in or, if you want, reboot the machine.
That should do it. Now, launch your VirtualBox installation.