Please also refer to here
Download CentOS install ISO file from http://wiki.centos.org/Download
Verify that the libvirt "default" network is active
In my case, it is not active
# virsh net-list
Name State Autostart Persistent
--------------------------------------------------
libvirt has an example default network XML file under /usr/share/libvirt/networks
# cat /usr/share/libvirt/networks/default.xml
<network>
<name>default</name>
<bridge name="virbr0" />
<forward/>
<ip address="192.168.122.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
</dhcp>
</ip>
</network>
According to http://wiki.libvirt.org/page/Networking , we can use the following steps to create "default" network :
# virsh net-define /usr/share/libvirt/networks/default.xml
Network default defined from /usr/share/libvirt/networks/default.xml
After running the above command, the following file is created :
# ls -al /etc/libvirt/qemu/networks/default.xml
-rw-------. 1 root root 579 Jun 19 22:51 /etc/libvirt/qemu/networks/default.xml
[root@novo networks]# cat default.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh net-edit default
or other application using the libvirt API.
-->
<network>
<name>default</name>
<uuid>a459e540-d37d-cfb4-99ad-1c846144ac0d</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0' />
<mac address='52:54:00:28:C3:B5'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254' />
</dhcp>
</ip>
</network>
# virsh net-start default
Network default started
# brctl show
bridge name bridge id STP enabled interfaces
pan0 8000.000000000000 no
qbr24110dfe-84 8000.f21061f22ed8 no qvb24110dfe-84
tap24110dfe-84
qbr426f579f-55 8000.d6804b3332d3 no qvb426f579f-55
tap426f579f-55
virbr0 8000.52540028c3b5 yes virbr0-nic
virbr0 is the bridge for default network
Now default network is active
# virsh net-list
Name State Autostart Persistent
--------------------------------------------------
default active no yes
# qemu-img create -f qcow2 /tmp/centos-6.5.qcow2 10G
Formatting '/tmp/centos-6.5.qcow2', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536
# virt-install --virt-type kvm --name centos-6.5 --ram 1024 --cdrom=/tmp/CentOS-6.5-x86_64-netinstall.iso --disk /tmp/centos-6.5.qcow2,format=qcow2 --network network=default --graphics vnc,listen=0.0.0.0 --noautoconsole --os-type=linux --os-variant=rhel6
Starting install...
Creating domain... | 0 B 00:00
Domain installation still in progress. You can reconnect to
the console to complete the installation process.
Now continue installation on virt-manager
* select IPv4 DHCP
* select URL
Hostname : localhost.localdomain
* select basic server
After installation is done, reject CDROM by running
# virsh attach-disk --type cdrom --mode readonly centos-6.5 "" hdc
Disk attached successfully
# virsh dumpxml centos-6.5 (before and after diff )
< <disk type='file' device='cdrom'>
---
> <disk type='block' device='cdrom'>
32,33c32
< <source file='/tmp/CentOS-6.5-x86_64-netinstall.iso'/>
< <target dev='hdc' bus='ide'/>
---
> <target dev='hdc' bus='ide' tray='open'/>
Now restart
# virsh destroy centos-6.5
Domain centos-6.5 destroyed
# virsh start centos-6.5
Domain centos-6.5 started
The cloud-init package will automatically fetch the
public key from the metadata server and place the key in
an account. We continue to install the package.
After server is back, login into the server as root.
# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.ih3yas: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
# yum install cloud-init
After installed, vi /etc/cloud/cloud.cfg
remove the following lines :
default_user:
name: cloud-user
Instead, add the following lines : (centos user will be created when OpenStack starts this image, we do not have to create this user manually)
default_user:
name: centos
lock_passwd: true
gecos: Centos Cloud User
groups: [wheel, adm]
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
shell: /bin/bash
Disable the zeroconf route
In order for the instance to access the metadata service, disable
the default zeroconf route:
# echo "NOZEROCONF=yes" >> /etc/sysconfig/network
Configure console
vi /boot/grub/grub.conf
add console=ttyS0,115200n8 to the line that begins with kernel
kernel /vmlinuz-2.6.32-431.el6.x86_64 ro
root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latar
cyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us
console=ttyS0,115200n8 rd_NO_DM rhgb quiet
Shutdown the instance
# /sbin/shutdown -h now
Clean up
There is a utility called
virt-sysprep, that performs various
cleanup tasks such as removing the MAC address references.
It will clean up a virtual machine image in
place
# virt-sysprep -d centos-6.5
Examining the guest ...
Performing "yum-uuid" ...
Performing "utmp" ...
Performing "udev-persistent-net" ...
Performing "sssd-db-log" ...
Performing "ssh-userdir" ...
Performing "ssh-hostkeys" ...
Performing "smolt-uuid" ...
Performing "script" ...
Performing "samba-db-log" ...
Performing "rpm-db" ...
Performing "rhn-systemid" ...
Performing "random-seed" ...
Performing "puppet-data-log" ...
Performing "pam-data" ...
Performing "package-manager-cache" ...
Performing "pacct-log" ...
Performing "net-hwaddr" ...
Performing "net-hostname" ...
Performing "mail-spool" ...
Performing "machine-id" ...
Performing "logfiles" ...
Performing "hostname" ...
Performing "firstboot" ...
Performing "dovecot-data" ...
Performing "dhcp-server-state" ...
Performing "dhcp-client-state" ...
Performing "cron-spool" ...
Performing "crash-data" ...
Performing "blkid-tab" ...
Performing "bash-history" ...
Performing "abrt-data" ...
Performing "lvm-uuids" ...
# virsh undefine centos-6.5
Domain centos-6.5 has been undefined
Now /tmp/centos-6.5.qcow2 is ready for uploading to the OpenStack Image Service.
After this image is uploaded to OpenStack and then we can start an instance.
Now try to connect to this instance.
$ ssh centos@172.24.4.232
The authenticity of host '172.24.4.232 (172.24.4.232)' can't be established.
RSA key fingerprint is b5:4a:5c:c8:9e:e9:63:19:65:b0:80:6c:ab:be:20:08.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.24.4.232' (RSA) to the list of known hosts.
[centos@centos-test01 ~]$
Are you looking to earn cash from your visitors with popup ads?
ReplyDeleteIn case you are, have you ever used Clicksor?