设为首页 收藏本站
查看: 1000|回复: 0

[经验分享] [转]Running KVM and Openvswitch on Ubuntu 12.10

[复制链接]

尚未签到

发表于 2015-4-10 16:18:32 | 显示全部楼层 |阅读模式
  Running KVM and Openvswitch on Ubuntu 12.10
  I’ve got an aging VMWare ESXi 4.0 server that needs to be replaced with something a little more modern and flexing. Obviously at home I don’t need all the cool features that licensed VMWare comes with, but I do want more than just the basic free version.
  After a few weeks of installing and testing alternatives ( I’d really love to run openstack, but it’s just not worth it at home for a single box ) I’ve settled on Ubuntu 12.10 server running KVM and Openvswitch.
  After installing Ubuntu 12.10 I did the following to get KVM up and running… I cribbed this mostly from blog.allanglesit.com.
  Install updates and Pre-requisites
  First of all, make sure Ubuntu is fully up to date: sudo to root as pretty much every command here needs to be run as root

sudo bash
apt-get update
apt-get upgrade

  Now we can go ahead and install the necessary packages:

apt-get -y install aptitude apt-show-versions ntp ntpdate vim kvm \
libvirt-bin vlan virtinst virt-manager virt-viewer openssh-server \
iperf pv openvswitch-controller openvswitch-brcompat \
openvswitch-switch nfs-common

  Kill off the default libvirt bridge and nuke ebtables
  We want to delete the default libvirt interface and we don’t need ebtables so we’ll get rid of that.

virsh net-destroy default
virsh net-autostart --disable default
service libvirt-bin stop
service qemu-kvm stop
aptitude purge -y ebtables
service openvswitch-switch restart
service openvswitch-controller restart

  Configure network interfaces
  We’ll be using just a single interface which will be used for both the bridge and the host itself. We will also be bridging that network into the the vswitch and then configuring an interface for the host OS. The network configuration will look something like this:
  /etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface - bridge!
auto eth0
iface eth0 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down
# The host OS network interface
# DNS settings here,  12.10 resets resolv.conf on reboot.
auto ovsbr0p1
iface ovsbr0p1 inet static
address 192.168.50.10
netmask 255.255.255.0
gateway 192.168.50.1
dns-nameservers 192.168.50.1
dns-search example.com
  Configure the openvswitch network
  Now we need to configure the network on the openvswitch. We need to define the bridge, connect it to the uplink interface and create a port for the host OS.
  note: if you’re doing this via SSH it will probably break your session

ovs-vsctl add-br ovsbr0
ovs-vsctl add-port ovsbr0 eth0
ovs-vsctl add-port ovsbr0 ovsbr0p1 -- set interface ovsbr0p1 type=internal
reboot

  Modify network service sleep times
  That took forever to boot. We can fix that by modifying sleeps in /etc/init/failsafe.conf and reboot again to make sure it helped.
  Change :

$PLYMOUTH message --text="Waiting for network configuration..." || :
sleep 40
$PLYMOUTH message --text="Waiting up to 60 more seconds for network configuration..." || :
sleep 59
$PLYMOUTH message --text="Booting system without full network configuration..." || :
  To :

$PLYMOUTH message --text="Waiting for network configuration..." || :
sleep 1
$PLYMOUTH message --text="Waiting up to 60 more seconds for network configuration..." || :
sleep 1
$PLYMOUTH message --text="Booting system without full network configuration..." || :
  LVM configure
  We’re going to also use LVM to for the KVM virtual machines to use as storage. I have a pair of 500g disks in a software raid1 which I’ll use for this.

pvcreate /dev/md0
vgcreate data-disk /dev/md0
lvcreate -L 10G -n ISO data-disk
mkfs.ext4 /dev/data-disk/ISO
mkdir -p /data-disk/ISO
echo "/dev/data-disk/ISO /data-disk/ISO defaults    ext4    0 0" >> /etc/fstab
mount -a

  Create VM
  Now we can go ahead and create our first VM. I’ve already downloaded the Ubuntu ISO to /data-disk/ISO
  note: virt-install does not support setting a virtualport type of openvswitch yet .. so we have to trick it

lvcreate -L 8G -n VM-UbuntuTest data-disk
virt-install --name UbuntuTest --hvm --noautoconsole --ram 1024 \
--disk path=/dev/data-disk/VM-UbuntuTest --nonetworks --vnc \
--os-type=linux --os-variant=ubuntuquantal \
--cdrom /data-disk/ISO/ubuntu-12.10-server-amd64.iso

  set up the networking by editing the VM’s XML and adding a network interface stanza just before the .

virsh edit UbuntuTest







  The VM will need to be reset to pick up the network change, however that will cause it to drop the ISO mount. We can either continue through with the OS install without networking or reset the VM and then re-attach the ISO as a CD. I connected to it from my desktop using the VirtualMachineManager GUI to do that but you could use virsh commands if you want to stick to CLI.
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-55761-1-1.html 上篇帖子: KVM Block Migrate 下篇帖子: [转] KVM I/O slowness on RHEL 6
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表