Converting from MyISAM to InnoDB

To change the default table engine add the following to my.cnf:

default-storage-engine=InnoDB

To check the engines being used:

SHOW TABLES STATUS

Each existing table has to be converted explicitly:

user='mydba'
db='mydb'
mysql -u ${user} -p -e "SHOW TABLES IN ${db};" \
| tail -n +2 | xargs -I '{}' echo "ALTER TABLE {} ENGINE=INNODB;" > alter_table.sql
mysql -u ${user} -p -D ${db} < alter_table.sql

BoxGrinder Chef

BoxGrinder is a JBoss Community project to build appliances based on Fedora, Red Hat and/or CentOS. It appears to build on an earlier project called ThinCrust.  It takes a simple BoxGrinder appliance configuration (‘.appl’) file and uses it to generate a Red Hat kickstart file, which it then uses to build a KVM VM. Additional plugins can then convert the VM to other formats like Amazon EC2 AMI.  BoxGrinder itself is supported on Fedora only, though it can create CentOS 5 appliances.  As of writing a critical bug stops BoxGrinder from building CentOS 6.x images.

The best way to build appliances for Amazon EC2 is to use the provided BoxGrinder meta-appliance AMI to create an EC2 instance:  BoxGrinder meta works best with at least 2G RAM to build i386 appliances.

I created a basic appliance with the Chef client preinstalled by using an appliance definition file as follows:

name: CentOS-chef
summary: "CentOS RBEL Chef"
version: 1
release: 1
hardware:
  partitions:
    "/":
      size: 4
os:
  name: centos
  version: 5
packages:
  - ruby-devel
  - rubygem-chef
repos:
  - name: "rbel5"
    baseurl: "http://rbel.frameos.org/stable/el5/#BASE_ARCH#/"
    ephemeral: true
  - name: "epel"
    baseurl: "http://download.fedoraproject.org/pub/epel/#OS_VERSION#/#BASE_ARCH#/"

Having gems pre-converted to RPMs is better than trying to use gem install during build post-processing.

Configuring the EC2 plugin is done in ~/.boxgrinder/config after which the appliance can be built with

export LIBGUESTFS_MEMSIZE=2048
boxgrinder-build CentOS-chef.appl -p ec2 -d ebs -b --debug

Installing Ruby Enterprise Edition on RHEL

RHEL5 is packaged with ruby 1.8.5 which is now outdated. To replace it with REE:

rpm -e `rpm -qa|grep ruby` # remove outdated ruby packages
sudo yum install wget -y
sudo yum install gcc-c++ make patch zlib-devel -y
sudo yum install openssl-devel readline-devel -y
cd /tmp
wget http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03.tar.gz
tar xzvf ruby-enterprise-1.8.7-2011.03.tar.gz
sudo ./ruby-enterprise-1.8.7-2011.03/installer --dont-install-useful-gems --auto=/opt/ruby-enterprise
cat > /etc/profile.d/ruby-enterprise.sh <<EOF
if ! echo ${PATH} | /bin/grep -q /opt/ruby-enterprise/bin ; then
PATH=/opt/ruby-enterprise/bin:${PATH}
fi
EOF

. /etc/profile.d/ruby-enterprise.sh

Optware

I’ve finally bought myself a Buffalo wireless router with DD-WRT pre-installed. The hardware specs include a 680MHz Qualcomm Atheros CPU (using a MIPS32 core) and 128MB RAM. For connectivity the unit has dual band 2.4GHz/5GHz support and 5x1Gbps ports.  It also has a USB port for an external hard drive. Standard features include a Dnsmasq DHCP/DNS server and NTP.  DD-WRT uses an OpenWrt kernel based on Linux but adapted for a firmware environment.  Optware  installation for Atheros is described in a DD-WRT forum and the preferred package manager is Opkg.  Using the external USB port for storage is discussed in detail on the DD-WRT wiki.

Chef 0.10 on CentOS 5.x

My experience with Chef on CentOS 5 recently confirmed this is still a beta product. The bootstrap instructions are incomplete, leaving you hanging half-way down the page at "CentOS 5.x users will need to have version 4.2 or better of gcc in order for this to function. This may be a newer version of gcc than that which is installed via yum."  To finish the installation detour to this page that provides links to the FrameOS RBEL repository and installation instructions for the Chef server that worked for me. After completing the server install return to Bootstrap instructions and resume from ‘Verify All Components are Running’.

mysql gem installation on Windows x64

Having run into multiple issues setting up MySQL with Rails on Windows x64 my recommendations are:

  • Install the 32-bit version of MySQL, do not try to use the 64-bit version.
  • Install into a path with no spaces, do not accept a default like "C:\Program Files\MySQL\MySQL Server 5.5\"
  • Install the MySQL gem with an invocation similar to:
         gem install mysql -- --platform=ruby --with-mysql-dir="D:\Programs\MySQL\MySQL-Server-5.5" --with-libmysqllib="D:\Programs\MySQL\MySQL-Server-5.5\lib\"
  • Be sure to uninstall/reinstall whenever you install a new version of MySQL.
  • Make sure D:\Programs\MySQL\MySQL-Server-5.5\lib is included in your path, as well as D:\Programs\MySQL\MySQL-Server-5.5\bin. Make sure other copies of libmysql.dll are not being picked up from elsewhere on your path or your ruby installation directories.

Unfortunately with mysql-5.5.15-win32, mysql-2.8.1-x86-mingw32 and Windows 7 x64 even this was not enough: after experiencing a segmentation fault running rake db:create I gave up and downloaded the libMySql.ddl from InstantRails.

    One year with Rails

    One year since I picked up ‘Agile Web Development with Rails’ and coded my first Rails model/controller/view: seems so long ago now.

    Things I’ve mastered in the past year:

    • Test driven development using unit and functional tests.
    • Master-detail forms using Ajax to add and delete rows, fetching product details in JSON for codes entered into a line item.
    • Prototype and jQuery, including jQuery UI datepickers.
    • Loading and parsing XML data files using Nokogiri.
    • Building complex reports using nested views in PostgreSQL, maintained using rails_sql_views.
    • Creating formatted, multi-tab Excel spreadsheets using Spreadsheet gem.
    • Creating pixel-perfect PDF reports using JasperReports loaded using Java-Ruby bridge.
    • Hosting using Apache with Passenger, Mongrel, Thin and Unicorn.
    • Monitoring using ScoutApp.
    • Upgrading a production app from Rails 2.3.4 to Rails 3.0.9.
    • Switching from ERB to HAML.

    Using Apache with Mongrel or Thin and Rails 3

    When using mod_proxy to load balance between members of a mongrel or thin cluster it’s important not to pass requests through for static content.  A basic virtual site can be configured like this:

    <VirtualHost *:80>
    
        ServerName myapp.mydomain.com
        DocumentRoot /opt/myapp/public
    
        <Proxy balancer://thinservers>
            BalancerMember http://127.0.0.1:3000
            BalancerMember http://127.0.0.1:3001
            BalancerMember http://127.0.0.1:3002
        </Proxy>
    
        ProxyPreserveHost On
        ProxyPass /images !
        ProxyPass /stylesheets !
        ProxyPass /javascripts !
        ProxyPass / balancer://thinservers/
        ProxyPassReverse / balancer://thinservers/
    
        <Proxy *>
         Order deny,allow
         Allow from all
        </Proxy>
    
        ErrorLog /var/log/apache2/error.log
        LogLevel warn
        CustomLog /var/log/apache2/access.log combined
    
    </VirtualHost>

    Thin with Apache

    Having run into compatibility issues between Passenger and RJB and between Mongrel and Rails 2.3.8 I’ve been looking at Thin.

    Slicehost has a couple of good articles on setting up a Thin cluster with Apache on Ubuntu.

    In summary:

    gem install thin
    thin install
    /usr/sbin/update-rc.d -f thin defaults
    thin –h # help
    thin -C /etc/thin/${appenv}.yml -c ${apphome} -s 3 -e production config
    su – ${appenv}bat ; thin -C /etc/thin/${appenv}.yml start

    Installing Nokogiri on Ubuntu

    Worked for me with Nokogiri 1.4.4 on Ubuntu 10.04 LTS:

    # ruby developer packages
    sudo apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8
    sudo apt-get install libreadline-ruby1.8 libruby1.8 libopenssl-ruby 
    
    # nokogiri requirements
    sudo apt-get install libxslt-dev libxml2-dev
    sudo gem install nokogiri

    Posts navigation

    1 2 3 4 5 6 7 8 11 12 13
    Scroll to top