Skip to content

Instantly share code, notes, and snippets.

@lukedemi
Created December 10, 2013 03:29
Show Gist options
  • Save lukedemi/7885325 to your computer and use it in GitHub Desktop.
Save lukedemi/7885325 to your computer and use it in GitHub Desktop.
Install Open vSwitch and Xen on CentOS 6.4
# Install Centos 6.4 Minimal (for this gist I used an iLO virtual media, not a kickstart file)
# Change Hostname
vi /etc/sysconfig/network
# Edit eth0 to get ssh and network access to the box
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.9.2.32
NETMASK=255.255.255.0
GATEWAY=10.9.2.1
USERCTL=no
DNS1=10.75.14.15
DNS2=10.1.1.30
# SSH into the new box
# Disable selinux (ghetto, I know)
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux
# Because it was CentOS minimal :P
yum -y install wget ntp screen links mlocate redhat-rpm-config rpm-build tcpdump traceroute vconfig rsync vim-enhanced telnet
# Yum update
yum -y update
# Shit needed to compile
yum -y install avahi gcc make libxml2-devel gnutls-devel device-mapper-devel python-devel libnl-devel dejavu-lgc-sans-fonts openssl-devel yajl-devel avahi-devel libssh2-devel libcurl-devel kernel-devel libpciaccess-devel
# Xen Shit
yum -y install centos-release-xen
yum -y install xen
# Run this script to fix grub
/usr/bin/grub-bootxen.sh
# Check to make sure xen is in the grub.conf
cat /boot/grub/grub.conf
# First boot option should be:
title CentOS (3.4.61-9.el6.centos.alt.x86_64)
root (hd0,0)
kernel /xen.gz dom0_mem=1024M,max:1024M loglvl=all guest_loglvl=all
module /vmlinuz-3.4.61-9.el6.centos.alt.x86_64 ro root=/dev/mapper/vg_shphlpxen01-lv_root rd_LVM_LV=vg_shphlpxen01/lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_shphlpxen01/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
module /initramfs-3.4.61-9.el6.centos.alt.x86_64.img
# Enable ntpd after editing ntpd.conf with local ntp servers
service ntpd start
# Don't want any of these services
chkconfig iptables off
chkconfig ip6tables off
# Restart
shutdown -r now
# Open vSwitch
cd ~
mkdir -p rpmbuild/SOURCES
wget http://openvswitch.org/releases/openvswitch-1.11.0.tar.gz
tar zxvf openvswitch-1.11.0.tar.gz
cd openvswitch-1.11.0
./configure; make dist
cp openvswitch-1.11.0.tar.gz ../rpmbuild/SOURCES/
cp rhel/openvswitch-kmod.files ../rpmbuild/SOURCES/
rpmbuild -bb rhel/openvswitch.spec
rpmbuild -bb rhel/openvswitch-kmod-rhel6.spec
yum -y localinstall /root/rpmbuild/RPMS/x86_64/kmod-openvswitch-1.11.0-1.el6.x86_64.rpm
yum -y localinstall /root/rpmbuild/RPMS/x86_64/openvswitch-1.11.0-1.x86_64.rpm
# Set up eth0
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
SLAVE=yes
MASTER=bond0
HOTPLUG=no
# eth1
vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
SLAVE=yes
MASTER=bond0
HOTPLUG=no
# Bond0
vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
BONDING_OPTS="mode=active-backup primary=eth0 miimon=50"
BOOTPROTO=none
DEVICETYPE=ovs
TYPE=OVSPort
OVS_BRIDGE=ovsbr0
# Set up ovsbr0
vi /etc/sysconfig/network-scripts/ifcfg-ovsbr0
DEVICE=ovsbr0
BOOTPROTO=none
GATEWAY=10.X.X.X
IPADDR=10.X.X.X
NETMASK=255.255.255.0
NM_CONTROLLED=no
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
DNS1=10.X.X.X
DNS2=10.X.X.X
ONBOOT=yes
TYPE=OVSBridge
DEVICETYPE=ovs
# Restart network to let changes take effect. It's usually back within a minute. If it takes longer than 2 mins then you can panic
service network restart
# Set up Xen Open vSwitch Compatability
echo 'vifscript="vif-openvswitch"' >> /etc/xen/xl.conf
echo 'vif.default.bridge="ovsbr0"' >> /etc/xen/xl.conf
# You need to find both of the below files and place them in the below directories.. I'll add em on here later - message me if you're following this and I'll dig them up for you
/etc/xen/scripts/network-openvswitch
/etc/xen/scripts/vif-openvswitch
# Make Xen use openvswitch
sed -i 's/(vif-script vif-bridge)/(vif-script vif-openvswitch)/' /etc/xen/xend-config.sxp
service xend restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment