CloudStack and KVM Installation on Centos 6. 5

What is Cloud-Computing? Cloud  is a shared multi-tenant environment built on a highly efficient, highly automated, and preferably virtualized IT infrastructure where IT resources can be provisioned on demand from anywhere over a broad network, and can be metered.

Virtualisation is the technology that has made the enablement of these features simpler and convenient. A cloud can be deployed in various models; including private, public, community or hybrid clouds.

There are Different type of Cloud-Computing.

  • Private cloud: In this deployment model, the cloud infrastructure is operated solely for an Organization and may exist on premise or off premise. It can be managed by the Organization or a third-party cloud provider.
  • Public cloud: In this deployment model, the cloud service is provided to the general public or a large industry group, and is owned and managed by the Organization providing cloud services. • Community cloud: In this deployment model, the cloud is shared by multiple organization and is supported by a specific community that has shared concerns. It can be managed by the Organization or a third party provider, and can exist on premise or off premise.
  • Hybrid cloud: This deployment model comprises two or more types of cloud (public, private, or community) and enables data and application portability between the clouds.

What is CloudStack and how Its a part of Cloud-Computing platforms ? CloudStack is a solution or a platform for IT infrastructure as a service that allows to pool computing resources which can be used to build public, private and hybrid IaaS cloud services that can be used to provide IT infrastructure such as compute nodes (hosts), networks, and storage as a service to the end users on demand.

What is IAAS? Infrastructure-as-a-Service (IaaS) clouds can be a complex thing to build, and by definition they have a plethora of options, which often lead to confusion for even experienced admins who are newcomers to building cloud platforms.

OverView of what we are going to do today? CloudStack cloud using KVM on CentOS 6. 5 with NFS storage on a flat layer-2 network utilizing layer-3 network isolation (aka Security Groups), and doing it all on a single piece of hardware. Security Groups act as distributed firewalls that control access to a group of virtual machines.

Prerequisites

  • BareMetal Server with hardware virtualization enable 64bit. • CentOS 6. 5 x86_64 minimal installation in BareMetal Server
  • Route with /24 network with the gateway being at 192. 168. 1. 1. Router should be having static ip.

Lets prepare the environment before we install Apache CloudStack-Computing

Network Configuration…

IP Addressing – Throughout this post I ll assume router have  A/24 network for your CloudStack implementation. Thus I ll use 192. 168. 1. 2 as you might have  some other configuration according to your network layer.

Connecting via console will see login as root check /etc/sysconfig/network-scripts/ifcfg-eth0, by default it ll be like below:

DEVICE=”eth0″
HWADDR=”52: 54: 00: B9: A6: C0″
NM_CONTROLLED=”yes”
ONBOOT=”no”
DEVICE =”eth0″
HWADDR =”52: 54: 00: B9: A6: C0″
NM_CONTROLLED =”yes”
ONBOOT =”no”
CloudStack should be configured with static IP address, netmask, etc. as below…
DEVICE=eth0
HWADDR=52: 54: 00: B9: A6: C0
NM_CONTROLLED=no
ONBOOT=yes
BOOTPROTO=none
IPADDR=192. 168. 1. 2
NETMASK=255. 255. 255. 0
GATEWAY=192. 168. 1. 1
DNS1=8. 8. 8. 8
DNS2=8. 8. 4. 4

CloudStack requires that the hostname properly set.

DEVICE = eth0
HWADDR = 52: 54: 00: B9: A6: C0
NM_CONTROLLED = no
ONBOOT = yes
BOOTPROTO = none
IPADDR = 192. 168. 1. 2
NETMASK = 255. 255. 255. 0
GATEWAY = 192. 168. 1. 1
DNS1 = 8. 8. 8. 8
DNS2 = 8. 8. 4. 4

CloudStack requires that the hostname properly set.

vim /etc/sysconfig/network
HOSTNAME=cloudstack. domain. com
vim / etc / sysconfig / network
HOSTNAME = cloudstack. domain. com

Set the hostname in /etc/hosts file as follows:

127. 0. 0. 1 localhost localhost. localdomain localhost4 localhost4. localdomain4
:: 1 localhost localhost. localdomain localhost6 localhost6. localdomain6
192. 168. 1. 2 cloudstack. domain. com
127. 0. 0. 1 localhost localhost. localdomain localhost4 localhost4. localdomain4
:: 1 localhost localhost. localdomain localhost6 localhost6. localdomain6
192. 168. 1. 2 cloudstack. domain. com

Now restart and keep network on to boot:

service network start
chkconfig network on
service network start
chkconfig network on
Selinux Configuration…
Set  Selinux to be 0
setenforce 0
setenforce 0

Configure the file /etc/selinux/config to reflect the permissive state:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE=targeted
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX = permissive
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE = targeted

NTP Configuration…
NTP is a necessity for keeping all of the clocks in your cloud servers in sync.

yum -y install ntp
chkconfig ntpd on
service ntpd start
yum – y install ntp
chkconfig ntpd on
service ntpd start
CloudStack Package Repository…
Add the CloudStack repo in /etc/yum. repos. d/cloudstack. repo add below lines.
[cloudstack]
name=cloudstack
baseurl=
enabled=1
gpgcheck=0
[ cloudstack ]
name = cloudstack
baseurl =
gpgcheck = 0

NFS Configuration…
NFS will run both primary and secondary storage. We are going to go ahead and setup two NFS shares for those purposes. We’ll start out by installing nfs-utils.

yum -y install nfs-utils
yum – y install nfs – utils

We now need to configure NFS to serve up two different shares. Add below lines in /etc/exports file.

cat >>/etc/exports <<EOM
/export *(rw, async, no_root_squash, no_subtree_check)
EOM
exportfs -a
cat >> / etc / exports << EOM
/ export    * (rw, async, no_root_squash, no_subtree_check)
exportfs – a

You will note that we specified two directories that don’t exist (yet) on the system. We’ll go ahead and create those directories and set permissions appropriately on them with the following commands:
mkdir –p /export /primary /export/secondary /export/mysql
mkdir – p / export / primary / export / secondary / export / mysql
Uncomment below line and Add the domain «cloudstack. domain. com» in /etc/idmapd. conf
Domain = cloudstack. domain. com
Domain = cloudstack. domain. com
Now configure the file /etc/sysconfig/nfs
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
RQUOTAD_PORT=875
STATD_PORT=662
STATD_OUTGOING_PORT=2020
LOCKD_TCPPORT = 32803
LOCKD_UDPPORT = 32769
MOUNTD_PORT = 892
RQUOTAD_PORT = 875
STATD_PORT = 662
STATD_OUTGOING_PORT = 2020
Configure the Iptables to permit incoming NFS connection:
iptables -A INPUT -s 192. 168. 1. 0/24 -m state –state NEW -p udp –dport 111 -j ACCEPT
iptables -A INPUT -s 192. 168. 1. 0/24 -m state –state NEW -p tcp –dport 111 -j ACCEPT
iptables -A INPUT -s 192. 168. 1. 0/24 -m state –state NEW -p tcp –dport 2049 -j ACCEPT
iptables -A INPUT –s 192. 168. 1. 0/24 -m state –state NEW -p tcp –dport 32803 -j ACCEPT
iptables -A INPUT -s 192. 168. 1. 0/24 -m state –state NEW -p udp –dport 32769 -j ACCEPT
iptables -A INPUT -s 192. 168. 1. 0/24 -m state –state NEW -p tcp –dport 892 -j ACCEPT
iptables -A INPUT -s 192. 168. 1. 0/24 -m state –state NEW -p udp –dport 892 -j ACCEPT
iptables -A INPUT -s 192. 168. 1. 0/24 -m state –state NEW -p tcp –dport 875 -j ACCEPT
iptables -A INPUT -s 192. 168. 1. 0/24 -m state –state NEW -p udp –dport 875 -j ACCEPT
iptables -A INPUT -s 192. 168. 1. 0/24 -m state –state NEW -p tcp –dport 662 -j ACCEPT
iptables -A INPUT -s 192. 168. 1. 0/24 -m state –state NEW -p udp –dport 662 -j ACCEPT
iptables – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p udp — dport 111 – j ACCEPT
iptables    – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p tcp — dport 111 – j ACCEPT
iptables    – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p tcp — dport 2049 – j ACCEPT
iptables    – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p tcp — dport 32803 – j ACCEPT
iptables    – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p udp — dport 32769 – j ACCEPT
iptables    – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p tcp — dport 892 – j ACCEPT
iptables – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p udp — dport 892 – j ACCEPT
iptables    – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p tcp — dport 875 – j ACCEPT
iptables – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p udp — dport 875 – j ACCEPT
iptables    – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p tcp — dport 662 – j ACCEPT
iptables    – A INPUT – s 192. 168. 1. 0 / 24 – m state — state NEW – p udp — dport 662 – j ACCEPT
Save and restart the iptables service:
iptables-save
service iptables save
service iptables restart
iptables – save
service iptables save
service iptables restart
Configure nfs service to start on boot:
service rpcbind start && service nfs start
chkconfig rpcbind on && chkconfig nfs on
service rpcbind start && service nfs start
chkconfig rpcbind on && chkconfig nfs on
Cloudstack Configuration…
Install the CloudStack management server and surrounding tools.
Database Installation and Configuration…
Install MySQL and configuring some added parameter:
yum -y install mysql-server
yum – y install mysql – server
edit datadir and add some more additional configuration to /etc/my. cnf. Please note all will go below to the [mysqld] section:
datadir=/export/mysql
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = ‘ROW’
datadir = / export / mysql
innodb_rollback_on_timeout = 1
innodb_lock_wait_timeout = 600
max_connections = 350
log – bin = mysql – bin
binlog – format = ‘ROW’
Lets restart and add on boot:
service mysqld start && chkconfig mysqld on
service mysqld start && chkconfig mysqld on
Now install the management server with yum:
yum -y install cloudstack-management
yum – y install cloudstack – management
Now the database and user needs to be created. The following command sets up the database for CloudStack. It will also create a cloud user on the database.
cloudstack-setup-databases cloud: [email protected] –deploy-as=root
cloudstack – setup – databases cloud: password @ localhost — deploy – as = root

A message like «CloudStack has successfully initialized the database.» It means all are set good:
Now that the database has been created Let complete with final step in setting up the management server:
cloudstack-setup-management
cloudstack – setup – management
If you are using webserver container Tomcat7 then add –tomcat7.
Default System Template Setup from Apache Cloudstack.
CloudStack has a number of system VMs templates. Now we need to download one of the default  system VM template and deploy that to the share we just mounted. The management server includes a script to properly manipulate the system VMs images.
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
-m /export/secondary \
-u
-h kvm -F
/ usr / share / cloudstack – common / scripts / storage / secondary / cloud – install – sys – tmplt \
– m / export / secondary \
– u
Final Setup KVM Installation and Configurtation…
What is KVM?
KVM, or Kernel-based Virtual Machine is a virtualization technology for the Linux kernel. KVM supports native virtualization atop processors with hardware virtualization extensions. KVM is the hypervisor which is installed on top of Operating system to control Baremetal Virtulization Services and share them across the Guest machines.
Here we will recover the initial setup which has already been done on the hypervisor host and cover installation of the agent software, you can use the same steps to add additional KVM nodes to your CloudStack environment.
Lets Start Installation of the KVM agent is trivial with just a single command, but afterwards we’ll need to configure a few things.
yum -y install cloudstack-agent
yum – y install cloudstack – agent
Lets Configure KVM…
We will Do this in  two different parts of KVM to configuration LIBVIRT and QEMU.
QEMU Configuration
KVM configuration is relatively simple at only a single item. We need to edit the QEMU VNC configuration. This is done by editing /etc/libvirt/qemu. conf and ensuring the following line is present and uncommented.
vnc_listen=0. 0. 0. 0
vnc_listen = 0. 0. 0. 0

Libvirt Configuration
CloudStack uses libvirt for managing virtual machines. Therefore it is vital that libvirt is configured correctly. Libvirt is a dependency of cloud-agent and should already be installed.
In order to have live migration working libvirt has to listen for unsecured TCP connections. We also need to turn off libvirts attempt to use Multicast DNS advertising. Both will be configured in /etc/libvirt/libvirtd. conf
listen_tls = 0
listen_tcp = 1
tcp_port =”16059″
auth_tcp =”none”
mdns_adv = 0
listen_tls = 0
listen_tcp = 1
tcp_port = “16059”
auth_tcp = “none”
mdns_adv = 0
Turning on «listen_tcp» in libvirtd. conf is not enough, we have to change the parameters as well we also need to modify /etc/sysconfig/libvirtd:
You need to Uncomment the  line and restart service:
LIBVIRTD_ARGS=”–listen”
service libvirtd restart
LIBVIRTD_ARGS =”–listen”
service libvirtd restart
KVM configuration are complete now…
Lets check if KVM is running OK on your machine:
lsmod | grep kvm
kvm_intel 50380 0
kvm 305081 1 kvm_intel
lsmod | grep kvm
kvm _ intel                50380 0
kvm                    305081 1 kvm_intel
Configuration For UI Setup…
As we noted before we will be using security groups to provide isolation and by default that implies that we’ll be using a flat layer-2 network. It also means that the simplicity of our setup means that we can use the quick installer.
UI Access
To get access to CloudStack’s web interface, merely point your browser to
You ll see a prompt requiring you to change the password for the admin user:

Setup Zone
A zone is the largest organization entity in CloudStack – and we’ll be creating one, this should be the screen that you see in front of you now. And for us there are 5 pieces of information that we need.
1. Name – we will set this to the ever-descriptive ‘Zone1’ for our cloud.
2. Public DNS 1 – we will set this to ‘71. 250. 0. 12’ for our cloud.
3. Public DNS 2 – we will set this to ‘68. 237. 161. 12’ for our cloud.
4. Internal DNS1 – we will also set this to ‘8. 8. 8. 8’ for our cloud.
5. Internal DNS2 – we will also set this to ‘8. 8. 4. 4’ for our cloud.

Pod Configuration
Now that we’ve added a Zone, the next step that comes up is a prompt for information regading a pod. Which is looking for several items.
1. Name – We’ll use Pod1 for our cloud.
2. Gateway – We’ll use 192. 168. 1. 1 as our gateway
3. Netmask – We’ll use 255. 255. 255. 0
4. Start/end reserved system IPs – we will use 192. 168. 1. 10-192. 168. 1. 80
5. Guest gateway – We’ll use 192. 168. 1. 1
6. Guest netmask – We’ll use 255. 255. 255. 0
7. Guest start/end IP – We’ll use 192. 168. 1. 100-192. 168. 1. 200

Cluster
Now that we’ve added a Zone, we need only add a few more items for configuring the cluster.
1. Name – We’ll use Cloudstack-1
2. Hypervisor – Choose KVM
You should be prompted to add the first host to your cluster at this point. Only a few bits of information are needed.
1. Hostname – we’ll use the IP address 192. 168. 1. 2.
2. Username – ‘root’
3. Password – password of root of system

Primary Storage
With your cluster now setup – you should be prompted for primary storage information. Choose NFS as the storage type and then enter the following values in the fields:
1. Name – We’ll use ‘Primary-Storage1’
2. Server – We’ll be using the IP address 192. 168. 10. 2
3. Path – Well define /export/primary as the path we are using

Secondary Storage
If this is a new zone, you’ll be prompted for secondary storage information – populate it as follows:
1. NFS server – We’ll use the IP address 192. 168. 1. 2
2. Path – We’ll use /export/secondary

Now, click Launch and your cloud should begin setup – it may take several minutes.
That’s it, you are done with installation of your Apache CloudStack cloud.
Configuration For UI Setup. . .
As we noted before we will be using security groups to provide isolation and by default that implies that we ’ ll be using a flat layer – 2 network. It also means that the simplicity of our setup means that we can use the quick installer.
To get access to CloudStack ’ s web interface, merely point your browser to
You ll   see a prompt requiring you to change the password for the admin user:

Setup Zone
A zone is the largest organization entity in CloudStack – and we ’ ll be creating one, this should be the screen that you see in front of you now. And for us there are 5 pieces of information that we need.

1. Name – we will set this to the ever – descriptive ‘ Zone1 ’ for our cloud.
2. Public DNS 1 – we will set this to ‘ 71. 250. 0. 12 ’ for our cloud.
3. Public DNS 2 – we will set this to ‘ 68. 237. 161. 12 ’ for our cloud.
4. Internal DNS1 – we will also set this to ‘ 8. 8. 8. 8 ’ for our cloud.
5. Internal DNS2 – we will also set this to ‘ 8. 8. 4. 4 ’ for our cloud.

Pod Configuration
Now that we ’ ve added a Zone, the next step that comes up is a prompt for information regading a pod. Which is looking for several items.

1. Name – We ’ ll use Pod1 for our cloud.
2. Gateway – We ’ ll use 192. 168. 1. 1 as our gateway
3. Netmask – We ’ ll use 255. 255. 255. 0
4. Start / end reserved system IPs – we will use 192. 168. 1. 10 – 192. 168. 1. 80
5. Guest gateway – We ’ ll use 192. 168. 1. 1
6. Guest netmask – We ’ ll use 255. 255. 255. 0
7. Guest start / end IP – We ’ ll use 192. 168. 1. 100 – 192. 168. 1. 200

Cluster
Now that we ’ ve added a Zone, we need only add a few more items for configuring the cluster.

1. Name – We ’ ll use Cloudstack – 1
2. Hypervisor – Choose KVM

You should be prompted to add the first host to your cluster at this point. Only a few bits of information are needed.
1. Hostname – we ’ ll use the IP address 192. 168. 1. 2.
2. Username – ‘ root ’
3. Password – password of root of system

Primary Storage
With your cluster now setup – you should be prompted for primary storage information. Choose NFS as the storage type and then enter the following values in the fields:

1. Name – We ’ ll use ‘ Primary – Storage1 ’
2. Server – We ’ ll be using the IP address 192. 168. 10. 2
3. Path – Well define / export / primary as the path we are using

Secondary Storage
If this is a new zone, you ’ ll be prompted for secondary storage information – populate it as follows:

1. NFS server – We ’ ll use the IP address 192. 168. 1. 2
2. Path – We ’ ll use / export / secondary

Now, click Launch and your cloud should begin setup – it may take several minutes.
That ’ s it, you are done with installation of your Apache CloudStack cloud.
Some Trouble Shooting Point For Cloudstack 4. 9…
If this fails, you need have a chance to correct mistakes in the wizard.
If you go to
If you get get a 404 on
If there is no Host, try adding it again, and doublecheck IP address and credentials.
If there is no primary storage, check NFS, check/mnt/primary is mounted and working, and re-add it.
If there is no secondary storage, check NFS, check/mnt/secondary is mounted and working, and re-add it.
As you go fixing these things, don’t forget to hit Refresh on the Infrastructure page.
You should see two system VMs: one for managing secondary storage, and one for managing console access.
If they are missing, CloudStack will try to re-create them every 30 seconds or so.
If it’s not re-creating check the zone is enabled (Infrastructure → Zones → zone1 → enable)
If it’s trying but failing, then look at/var/log/cloudstack/management/management-server. logand /var/log/cloudstack/agent/agent. log.
Check theSSVM, templates, Secondary storage troubleshooting page for more tips. Some are out of date or wrong; for example, to ssh into the SSVM, use:  ssh -i /var/lib/cloudstack/management/. ssh/id_rsa -p 3922

Leave a Reply

Your email address will not be published. Required fields are marked *