Sunday, September 9, 2012

Compile and install Thrift 0.8.0 on CentOS 5.8 and 6

When you want to install Thrift on CentOS 5.8 or 6, it is better to download the tallbar from Apache thrift website. Don't checkout the source code from SVN or git because CenOS 5.8 and 6 don't have the correct version of AutoConf so that you cannot run ./bootstrap.sh of Thrift. The tarball doesn't need ./bootstrap.sh because ./configure is already generated. Just follow the installation guide.
I had troubles to compile thrift on CentOS 5.8 with ruby 1.9.3 and 1.8.7 in RVM.

  • For 1.9.3, I ran "bundle install", but failed in compiling mongrel-1.1.5. mongrel-1.1.5 is not compatible with Ruby 1.9.3. Using mongrel-1.2.0pre2, it will be ok. You need to rerun "./configure" if you change the ruby version in RVM. And when you install, you have to pass your ANT_HOME and rvm_path if root doesn't have them.
    vi thrift-0.8.0/lib/rb/thrift.gemspec
    
      s.add_development_dependency "mongrel", "1.2.0pre2"
    
    cd thrift-0.8.0/lib/rb
    bundle install
    cd ../../..
    ./configure
    make
    sudo ANT_HOME=$ANT_HOME rvm_path=$rvm_path bash -c "source /home/bewang/.rvm/scripts/rvm && rvm use 1.9.3 && make install"
    
  • For 1.8.7, I ran "bundle install" without any problem, but the compilation failed sometimes with this rspec error.
    Spec::Mocks::MockExpectationError in 'Thrift::UNIXSocket should raise an error when read times out'
    < IO class> expected :select with (any args) once, but received it twice
    /home/bewang/temp/thrift-0.8.0/lib/rb/spec/socket_spec_shared.rb:94:
    
You can disable ruby if you don't want it or have troubles in building it successfully.
sudo yum install automake libtool flex bison pkgconfig gcc-c++ boost-devel libevent-devel zlib-devel python-devel ruby-devel
tar zxvf thrift-0.8.0.tar.gz
./configure --without-ruby
make
sudo ANT_HOME=$ANT_HOME make install 

Thursday, September 6, 2012

VirtualBox CentOS 5.8 guest DHCP add search

I have a CentOS 5.8 guest using VirutalBox. There are two network interface, one is NAT, and the other is "Host Only". I have three environments
  1. In company, there are three networks mycompany.corp.com, mycompany.net and mycompany.dmz.com;
  2. At home, I want to access the Internet without VPN;
  3. Use VPN at home to access company's networks.
Here is my issue: If check "Automatically obtain DNS information from provider" in network configuration, only mycompany.corp.name in search of /etc/resolv.conf
; generated by /sbin/dhclient-script
search mycompany.corp.com
nameserver 10.184.77.23
nameserver xx.10.217.47
nameserver 192.168.0.1

This is not convenient because I have to type the full DNS name if I want to access a host hostA.mycompany.net instead of hostA.

I can add the other twos in DNS tab network-configuration, but the change will be overwritten by dhclient when the interface is restarted, or machine reboot.

If set DNS name servers will be different for company and home. It works in one environment and fails in the others. Company internal DNS servers are accessible from outside without VPN.

Here is my solution to config dhclient to include the other two network in DNS search like this:

add /etc/dhclient-eth1.conf

interface "eth1" {
    append domain-name " mycompany.net mycompany.dmz.com";
};
Then restart the network:
sudo /sbin/service network restart
NOTES:
  • a blank in domain-name value is important because the string is simply concatenated to the string retrieved from the provider.
  • if it is not working, check /var/log/message
  • use "domain-name" for search. "domain-search" is not correct for CentOS 5.8.