1. Installing Node.js on Ubuntu 10.04 server

    Most of the guides I find on how to install Node.js on Ubuntu are not about installing the currently released version, instead they focus on installing the latest development release. I think this is the case because they assume the reader is familiar with doing software installs on unix from source. I'm coming from a Windows word were installing from the source is almost never done. This guide is for someone relatively new to unix installation or to Ubuntu server setup.

    Installing Node.js from source is done in 3 basic steps. Step 1 is setting up your system to configure and build Node.js. Step 2 is getting a copy of the Node.js source. And the last step is building the correct version of Node.js. Some of the commands need root permissions to execute. For those commands I use the sudo filter command to elevate the current user to root permissions.

    Step 1: Setting up Node.js dependencies

    Run the following command to install the dependencies. These dependencies are needed to build an configure Node.js without any errors. On a fresh install of Ubuntu 10.04 you will need all of the components. If you happen to already have some of these items install this command will skip it without error.

    sudo apt-get install -y g++ curl libssl-dev apache2-utils git-core pkg-config
    

    Step 2: Creating a local copy of the Node.js source

    The Node.js source is located on Github. Issue the following commands to create a local copy of the full version history. This will include the current production release, as well as, the current development release. If you have a bare system, you might not have created a "source" directory yet for all of your projects. If you have then you can skip the first 2 commands.

    mkdir source
    cd source
    git clone https://github.com/joyent/node.git
    cd node
    

    Step 3: Configuring and building Node.js

    For this step you need to find out what the most resent production release version number is. At the time of writing Node.js is on the 0.6.17 release. The copy of the source includes this version under the tag with a similar name. The following commands will select the production version and then build it. Remember to change the first command to have the version you want. (Don't forget the leading 'v') After the first command git will issue a message that looks like a warning or a failure. The message about the "detached HEAD" is ok to ignore. The message is explaining that you have the master pointer pointing to a commit in the middle of the history. This is acceptable because you are not building the latest development version.

    git checkout v0.6.17
    ./configure
    make && sudo make install
    

    Published on

  2. How to setup Node.js and Npm behind a corporate web proxy

    For those who, like me, are behind a corporate web proxy, setting up Node.js and using npm can be a real pain. I thought that the web proxy settings would be like the rest of the unix world and require me to set the HTTP_PROXY and HTTPS_PROXY environment variables. Although I just cloned the Node repository from Github so they are already setup. What gives?

    A little searching and I discover that npm uses a configuration file and it can be added to via the command line npm config set .... The key to getting it right is the spelling of the settings. This has bit me so many times now! Getting npm to work behind a proxy requires setting the proxy and https-proxy settings. The key is noticing the - (dash) is not an _ (underscore).

    So the full procedure is install Node.js via the installer or source. Open an command prompt or terminal session and run the following commands to configure npm to work with your web proxy. The commands use proxy.company.com as the address and 8080 as the port.

    npm config set proxy http://proxy.company.com:8080
    npm config set https-proxy http://proxy.company.com:8080
    

    Why the developers of npm choose to use a dash instead of an underscore like the rest of the unix work is beyond me. Maybe someone will add in an alias so setting https_proxy will have the same effect as https-proxy.

    Published on

  3. Install Cloudstack 3.0.0 on Ubuntu 10.04 Server

    Cloudstack 3.0.0 was release on Febrary 28th 2012. At the time I was trying to install version 2.2 on a VM. I was having a lot of trouble so seeing a new version was wonderful. The following is what I had to do in order to get the system setup. Hopfully this post will help you get Cloudstack running in your environment.

    Setup procedures

    To get started download the cloud management software and follow these steps. You will need the quick install guide to help you through the GUI part of the setup.

    This assumes that you have an Ubuntu 10.04 Server running with NFS setup. Additionally you need at least 1 host with XenServer 6 installed. Also, all commands must be run as the root user. For this install I'm going to use the following values. Change the values to what you would use.

    Desktop: myhost    
    Management Server: manhost
    XenServer Host: xenhost
    Management IPs: 192.168.0.20 - 192.168.0.29
    Guest IPs: 192.168.0.30 - 39
    

    Step 1 - Install Ubuntu 10.04 Server with NFS

    Follow the guide I wrote on setting up NFS on ubuntu 10.04 server

    Step 2 - Setup SELinux

    Install the SElinux package and change to passive mode

    apt-get install selinux-utils
    setenforce permissive
    

    Step 3 - Create Cloudstack NFS shares

    Create two directories for sharing via NFS. I named mine the same as the documentation: primary and secondary. Then share these via NFS.

    mkdir -p /export/primary
    mkdir -p /export/secondary
    

    Edit the file /etc/exports to add the following two exports

    /export/primary *(rw,async,no_subtree_check,no_root_squash)
    /export/secondary *(rw,async,no_subtree_check,no_root_squash)
    

    Then run the exportfs -a command to expose them.

    Step 4 - Setup Cloudstack management software

    Copy the cloud management software to the Ubuntu box. I used scp to get this done.

    scp myhost:CloudStack-3.0.0-1-ubuntu10.04.tar.gz manhost:
    

    Once on the management server extract it and run the installer.

    tar xzf CloudStack-3.0.0-1-ubuntu10.04.tar.gz
    cd CloudStack-3.0.0-1-ubuntu10.04
    ./install.sh
    

    The installer will first run aptitude update so make sure you have that setup correctly. This should have been done when you setup the Ubuntu box. After updating the components the install script will present you with a prompt to pick what component to install. At this prompt choose option M for the management server.

    Step 5 - Setup Cloudstack database

    This step is just as easy as the last step. The database server (MySql) will be installed via the same install.sh script used in the last step.

    ./install.sh
    

    This will once again try to update all packages. They should be up to date, so you should not have to wait long for this to finish. You will then be given the same prompt from your last run. This time choose option D to install the database.

    During the install of the database server you will be asked for a password. This is the password for the user named root on the database. This is not the same as the root user of the Ubuntu box. Pick a password that does not include an @ symbol. I at first used the password of p@ssword1. This caused so many headaches that its just not worth the workarounds. I went with a password of password1.

    Once the database server is setup you need to create the databases used my the cloud management software.

    cloud-setup-database cloud:password1@localhost --deploy-as=root:password1
    

    This command will create two databases in MySQL and fill them will your systems data.

    Step 6 - Finish Cloudstack management software setup

    Finish the setup by running the management setup command line tool a second time. The command does a few things with iptables but it should all be transparent to you.

    cloud-setup-management
    

    Step 7 - Add System VM image

    Add the system VM to the secondary storage and database.

    /usr/lib64/cloud/agent/scripts/storage/secondary/cloud-install-sys-tmplt -m /export/secondary -u http://download.cloud.com/templates/acton/acton-systemvm-02062012.vhd.bz2 -h xenserver -F
    

    This will copy the system VM to the secondary storage location and setup database entries pointing to it. One of the gotchas I ran into was that the system VM image file must be access via HTTP. I first tried doing it as a local file since it is such a large file. I didn't want to download it from the Internet. Unfortanitly this does not work, so you must use a workaround. My desktop system is also a web server so I just put the system VM image there. You can also use the source URL instead of your local server. Make sure to use port 80 or it will not connect.

    Gotchas

    • need more management ips than hosts so that support VMs can also have IPs
    • Removing VMs does not clean up IP resources for a long time. Need to change the expunge settings.

    Published on

  4. Setting up NFS on Ubuntu 10.04 Server

    I'm currently working on improving my knowledge of UNIX networking. One of the common tasks for a server is acting as an NFS server. These are the steps I take on an Ubuntu 10.04 server to setup NFS.

    The following assumes you have already setup Ubuntu and can access the network. Do all the following as the root user.

    Install the NFS server package

    Run the following commands to install NFS server and rpcbind

    apt-get install nfs-kernel-server
    apt-get install rpcbind
    

    Setup IPTables to restore rules at startup and save rules at shutdown

    Create the following two files

    • /etc/network/if-pre-up.d/iptablesload

        #!/bin/sh
        iptables-restore < /etc/iptables.rules
        exit 0
      
    • /etc/network/if-post-down.d/iptablessave

        #!/bin/sh
        iptables-save -c > /etc/iptables.rules
        if [ -f /etc/iptables.downrules ]; then
            iptables-restore < /etc/iptables.downrules
        fi
        exit 0
      

    Give both scripts execute permissions and run them

    chmod +x /etc/network/if-pre-up.d/iptablesload
    chmod +x /etc/network/if-post-down.d/iptablessave
    /etc/network/if-post-down.d/iptablessave
    /etc/network/if-pre-up.d/iptablesload
    

    Add IPTable rules to allow NFS and RPCBind traffic

    Run the following commands

    iptables -A INPUT -m state --state NEW -p udp --dport 111 -j ACCEPT
    iptables -A INPUT -m state --state NEW -p tcp --dport 111 -j ACCEPT
    iptables -A INPUT -m state --state NEW -p tcp --dport 2049 -j ACCEPT
    iptables -A INPUT -m state --state NEW -p tcp --dport 32803 -j ACCEPT
    iptables -A INPUT -m state --state NEW -p udp --dport 32769 -j ACCEPT
    iptables -A INPUT -m state --state NEW -p tcp --dport 892 -j ACCEPT
    iptables -A INPUT -m state --state NEW -p udp --dport 892 -j ACCEPT
    iptables -A INPUT -m state --state NEW -p tcp --dport 875 -j ACCEPT
    iptables -A INPUT -m state --state NEW -p udp --dport 875 -j ACCEPT
    iptables -A INPUT -m state --state NEW -p tcp --dport 662 -j ACCEPT
    iptables -A INPUT -m state --state NEW -p udp --dport 662 -j ACCEPT
    /etc/network/if-post-down.d/iptablessave
    

    Setup ports for NFS

    Edit the file /etc/default/nfs-kernel-server and add or uncomment the following lines

    LOCKD_TCPPORT=32803
    LOCKD_UDPPORT=32769
    MOUNTD_PORT=892
    RQUOTAD_PORT=875
    STATD_PORT=662
    STATD_OUTGOING_PORT=2020
    

    Add your domain for IdMap service

    Edit the file /etc/idmapd.conf and change the value for Domain to be your domain.

    Create first export

    Create your first exported directory

    mkdir -p /export/first
    

    Setup NFS to export the directory by editing the file /etc/exports. Add the following line

    /export/first *(rw,async,no_subtree_check,no_root_squash)
    

    Update NFS exported files by running exportfs -a

    Restart NFS and networking

    Restart via the following commands

    /etc/init.d/nfs-kernel-server restart
    /etc/init.d/networking restart
    

    Verify it all works

    Run rpcinfo -p and verify that the following services are listed

    mountd
    nlockmgr
    nfs
    portmapper
    

    Further reading

    These are the help pages I read to figure most of this out. They are from the Ubuntu community documentation and are definitely worth reading.

    Published on

  5. Virtualization on the Mac

    My day job is working in .Net, so I spend a lot of time in Visual Studio. To run it on my mac I need to either boot to windows or run it in a virtual machine. I decided to go with virtualization.

    How to setup Windows 7 in a VM on the Macbook Air.

    1. Create ISO image of the Windows Setup DVD
    2. Copy image to USB or SD drive
    3. Install VMware Fusion
    4. Setup VM to install Win7
    5. Install Win7

    Published on

  6. Switched from PC to Mac

    I'm a switcher! I switched from PC to Mac. It started when I wanted to replace the computer I use to run my TV. I picked the Mac Mini because of it's size. I had done the research and all of the Internet services I used on the PC also worked for the Mac. So I waited until the Mac OS X Lion update came out to buy the newest version of the mini.

    In addition to the media streaming I also started using the mini for iTunes and iPhoto. I cannot stand iTunes on Windows, but on the Mac is it much better. This of course led me to using the mini for more and more things. I am super happy with my purchase. So much so that I have purchased a MacBook Air. It arrived today and I'm very excited.

    I'm actually replacing my "main use" computer for the Mac. I'm a full on switcher now.

    Published on