lost and found ( for me ? )

Ubuntu 13.10 KVM: build VMs without VNC by using virt-install

Here are logs when building VMs via virt-install without VNC.

# virt-install --version
0.600.4

error..
# virt-install --name ubuntu1204-varm -r 1024 --vcpus=2 --os-type=linux --os-variant=ubuntuprecise --disk path=/var/lib/KVM_images/ubuntu1204-varm.qcow2,size=10,format=qcow2 --cdrom  /home/hattori/ISO_files/ubuntu-12.04.1-server-amd64.iso --accelerate  --nographics --network network=default,model=virtio --hvm --extra-args='console=tty0 console=ttyS0,115200n8 serial'
ERROR    --extra-args は --location とともに指定する場合のみ機能します。

when using --extra-args option, I need to use --location instead of --cdrom option.

I need to specify nfs or http or ftp path when using --location.
nfs:host:/path or nfs://host/path
            An NFS server location containing an installable distribution image

        http://host/path
            An HTTP server location containing an installable distribution image

        ftp://host/path
            An FTP server location containing an installable distribution image

To specify http path, create a directory to mount ISO
# mkdir /var/www/mnt

mount the ISO
# mount -t iso9660 -o loop /home/hattori/ISO_files/ubuntu-12.04.1-server-amd64.iso /var/www/mnt
mount: block device /home/hattori/ISO_files/ubuntu-12.04.1-server-amd64.iso is write-protected, mounting read-only

# ls /var/www/mnt/
boot          dists  efi      isolinux    pics  preseed             ubuntu
cdromupgrade  doc    install  md5sum.txt  pool  README.diskdefines

start apache2
# apache2ctl start

Now, you can specify installable image over http.

try again.
Okay, I can install ubuntu via console without VNC.
virt-install --name ubuntu1204-varm -r 1024 --vcpus=2 --os-type=linux --os-variant=ubuntuprecise --disk path=/var/lib/KVM_images/ubuntu1204-varm.qcow2,size=10,format=qcow2 --location http://127.0.0.1/mnt --accelerate  --nographics --network network=default,model=virtio --hvm --extra-args='console=tty0 console=ttyS0,115200n8 serial'

Starting install...
Retrieving file version.info...                          |  116 B     00:00 ...
Retrieving file linux...                                 | 9.5 MB     00:00 ...
Retrieving file initrd.gz...                             |  33 MB     00:00 ...
Creating domain...                                       |    0 B     00:00     
Connected to domain ubuntu1204-varm
Escape character is ^]
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.2.0-29-generic (buildd@allspice) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 (Ubuntu 3.2.0-29.46-generic 3.2.24)
[    0.000000] Command line: method=http://127.0.0.1/mnt console=tty0 console=ttyS0,115200n8
[    0.000000] KERNEL supported cpus:
[    0.000000]   Intel GenuineIntel
[    0.000000]   AMD AuthenticAMD
[    0.000000]   Centaur CentaurHauls
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
[    0.000000]  BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
[    0.000000]  BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
[    0.000000]  BIOS-e820: 0000000000100000 - 000000003fffe000 (usable)
[    0.000000]  BIOS-e820: 000000003fffe000 - 0000000040000000 (reserved)
[    0.000000]  BIOS-e820: 00000000feffc000 - 00000000ff000000 (reserved)
[    0.000000]  BIOS-e820: 00000000fffc0000 - 0000000100000000 (reserved)
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] DMI 2.4 present.
[    0.000000] No AGP bridge found





CentOS 6.5: configure bonding

bond0: eth0, eth1 ( active eth0, standby eth1 )

create a file uder /etc/modprobe.d directory.
# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 mode=1 primary=eth0 miimon=500

mode 1 is active – standby.

# grep -v ^# /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="none"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
MASTER=bond0
SLAVE=yes

# grep -v ^# /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
BOOTPROTO="none"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
MASTER=bond0
SLAVE=yes

create a bond0 file.
# grep -v ^# /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE="bond0"
BOOTPROTO="static"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=10.0.0.10
NETMASK=255.255.255.0

reboot the OS.

# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 500
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr:
Slave queue ID: 0

Slave Interface: eth1
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr:
Slave queue ID: 0

Ubuntu 13.10: use KVM and open vswitch GRE tunnel


Reference


Here is how to configure GRE tunnel on openvswitch.
# tail -1 /etc/lsb-release ;uname -ri
DISTRIB_DESCRIPTION="Ubuntu 13.10"
3.11.0-17-generic x86_64
root@ubuntu:~:# dpkg -l openvswitch-switch


+++-==============-============-============-=================================
ii  openvswitch-sw 1.10.2-0ubun amd64        Open vSwitch switch implementatio



VM1: 10.0.0.10
VM2: 10.0.0.20
KVM1 br2: 10.0.0.100
KVM2 br2: 10.0.0.200
KVM1 br0: 192.168.11.100
KVM2 br0: 192.168.11.44
VM1 gateway: 10.0.0.100
VM2 gateway: 10.0.0.200





configure GRE tunnel to have VM1(10.0.0.10) and VM2(10.0.0.20) communicate each other over GRE tunnel.


I have already set up openvswitch and associated br0 with eth0.
http://lost-and-found-narihiro.blogspot.jp/2014/02/ubuntu-1310-install-use-openvswitch.html


on the KVM1 host.
# ovs-vsctl add-br br2
# ifconfig br2 10.0.0.100 netmask 255.255.255.0
# ovs-vsctl add-port br2 gre0 -- set interface gre0 type=gre options:remote_ip=192.168.11.44


# ovs-vsctl show
41d09907-b8ac-4000-817c-41571e987aea
   Bridge "br2"
       Port "gre0"
           Interface "gre0"
               type: gre
               options: {remote_ip="192.168.11.44"}
       Port "br2"
           Interface "br2"
               type: internal
   Bridge "br0"
       Port "br0"
           Interface "br0"
               type: internal
       Port "eth0"
           Interface "eth0"
   ovs_version: "1.10.2"


# ifconfig br0 | grep 'inet'
         inetアドレス:192.168.11.100  ブロードキャスト:192.168.11.255  マスク:255.255.255.0



# ifconfig br2 | grep 'inet'
         inetアドレス:10.0.0.100  ブロードキャスト:10.0.0.255  マスク:255.255.255.0


on the KVM2 host
#  ovs-vsctl add-br br2
# ifconfig br2 10.0.0.200 netmask 255.255.255.0
# ovs-vsctl add-port br2 gre0 -- set interface gre0 type=gre options:remote_ip=192.168.11.100


# ovs-vsctl show
188ac705-d04f-42e1-b194-c90db8176629
   Bridge "br2"
       Port "gre0"
           Interface "gre0"
               type: gre
               options: {remote_ip="192.168.11.100"}
       Port "br2"
           Interface "br2"
               type: internal
   Bridge "br0"
       Port "br0"
           Interface "br0"
               type: internal
       Port "eth0"
           Interface "eth0"
   ovs_version: "1.10.2"


- VM1 ( KVM1 )


VM1 definition file
   <interface type='bridge'>
     <mac address=''/>
     <source bridge='br2'/>
     <virtualport type='openvswitch'>
     </virtualport>



# ifconfig eth0 | grep 'inet'
         inetアドレス:10.0.0.10  ブロードキャスト:10.0.0.255  マスク:255.255.255.0


# netstat -rn
カーネルIP経路テーブル
受信先サイト    ゲートウェイ    ネットマスク   フラグ   MSS Window  irtt インタフェース
0.0.0.0         10.0.0.100      0.0.0.0         UG        0 0          0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 eth0





- VM2 ( KVM2 )


   <interface type='bridge'>
     <mac address=''/>
     <source bridge='br2'/>
     <virtualport type='openvswitch'>



ifconfig eth0 | grep inet
         inet addr:10.0.0.20  Bcast:10.0.0.255  Mask:255.255.255.0


# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.0.0.200      0.0.0.0         UG        0 0          0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U         0 0          0 eth0


send icmp packets to the VM2 from VM1.


# ping 10.0.0.20 -c 1
PING 10.0.0.20 (10.0.0.20) 56(84) bytes of data.
64 bytes from 10.0.0.20: icmp_seq=1 ttl=64 time=18.3 ms


--- 10.0.0.20 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 18.372/18.372/18.372/0.000 ms
root@ubuntu:~# ping 10.0.0.20 -c 4
PING 10.0.0.20 (10.0.0.20) 56(84) bytes of data.
64 bytes from 10.0.0.20: icmp_seq=1 ttl=64 time=24.1 ms
64 bytes from 10.0.0.20: icmp_seq=2 ttl=64 time=11.9 ms
64 bytes from 10.0.0.20: icmp_seq=3 ttl=64 time=7.88 ms
64 bytes from 10.0.0.20: icmp_seq=4 ttl=64 time=6.31 ms



arp table on the VM1
# arp -an
? (10.0.0.100) at 4e:b7:81:f6:c7:44 [ether] on eth0
? (10.0.0.20) at 52:54:00:04:16:21 [ether] on eth0


arp table on the VM2
# arp -an
? (10.0.0.200) at d2:55:99:61:8e:47 [ether] on eth0
? (10.0.0.10) at 52:54:00:1c:ca:06 [ether] on eth0


on the KVM1


n_packets and n_bytes are counting up.
# ovs-ofctl dump-flows br2
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=5800.189s, table=0, n_packets=395, n_bytes=39402, idle_age=0, priority=0 actions=NORMAL
#
# ovs-ofctl dump-flows br2
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=5801.861s, table=0, n_packets=399, n_bytes=39794, idle_age=0, priority=0 actions=NORMAL


on the KVM1
# ovsdb-tool show-log -m



record 47: 2014-02-25 15:43:29 "ovs-vsctl: ovs-vsctl add-br br2"
table Port insert row "br2" (d5f96248):
table Bridge insert row "br2" (f681b74d):
table Interface insert row "br2" (c66453e1):
table Open_vSwitch row 41d09907 (41d09907):


record 48: 2014-02-25 15:43:29
table Interface row "br2" (c66453e1):
table Open_vSwitch row 41d09907 (41d09907):


record 49: 2014-02-25 15:44:22 "ovs-vsctl: ovs-vsctl add-port br2 gre0 -- set interface gre0 type=gre options:remote_ip=192.168.11.44"
table Port insert row "gre0" (4dec49ac):
table Bridge row "br2" (f681b74d):
table Interface insert row "gre0" (4a98fd74):
table Open_vSwitch row 41d09907 (41d09907):


record 50: 2014-02-25 15:44:22
table Interface row "gre0" (4a98fd74):
table Open_vSwitch row 41d09907 (41d09907):


record 51: 2014-02-25 15:53:35 "ovs-vsctl: ovs-vsctl --timeout=5 -- --may-exist add-port br2 vnet0 -- set Interface vnet0 "external-ids:attached-mac=\"52:54:00:1c:ca:06\"" -- set Interface vnet0 "external-ids:iface-id=\"3a76a16f-3478-47b9-8783-798b655a6f6c\"" -- set Interface vnet0 "external-ids:vm-id=\"3f81fba0-7a06-3329-1f4a-516faaf35525\"" -- set Interface vnet0 external-ids:iface-status=active"
table Port insert row "vnet0" (dec63ba3):
table Interface insert row "vnet0" (07f7d36d):
table Bridge row "br2" (f681b74d):
table Open_vSwitch row 41d09907 (41d09907):


record 52: 2014-02-25 15:53:35
table Interface row "vnet0" (07f7d36d):
table Open_vSwitch row 41d09907 (41d09907):