If you're looking for a pre-configured CloudStack environment please refer to DevCloud.
This is a do-it-yourself guide to help you hack your own custom CloudStack development environment. JFYI, reverse-engineer DevCloud: /root/.bash_history and /home/devcloud/setup.sh
Table of Contents
New to CloudStack? Checkout the n00b developer's guide: Contributing as a non-committer
Terms used throughout the guide:
- host or host-os, means your operating system running on top of your laptop/desktop.
- hypervisor or hypervisor-vm or xen/server or xenserver-vm means a XenServer running inside a VM on VirtualBox.
- guest-os or guest-vm means the virtual machine running on a xenserver-vm.
CAUTION: This kind of setup is unstable, in my case my system with 8GB RAM would crash a lot (make sure you allocate 500MB to dom0). This guide just shares a proof-of-concept setup, not necessarily the best.
For simplicity, in this guide we'll use the same kind of networking, IP ranges and filesystem paths as in DevCloud and create a non-monolithic setup:
- Two XenServer VMs (Both run as separate VMs on VirtualBox).
- One Ubuntu/Linux server to provide DNS and NFS for secondary storage (This may be on one the hypervisor's dom0).
- CloudStack development environment, the management server and the MySQL server runs on your host-os.
- When creating any VM, XenServer or Ubuntu/Linux, use these credentials;
XenServer 6.0.2: http://downloadns.citrix.com.edgesuite.net/akdlm/6760/XenServer-6.0.201-install-cd.iso (if link fails, google for Citrix XenServer and download the free XenServer)
Ubuntu Server: http://www.ubuntu.com/download/server (any, x86 or x86_64)
Get dependencies: Git, Java, Ant, Tomcat (use 6.0.33, problems with latest version), MySQL, mkisofs
Setting up CloudStack Development Environment
Setting up on Linux: Refer to INSTALL.txt in the root directory of the source code
Install MySQL with root user's password blanked out as used as default by CloudStack. In case you gave a password during installation: http://stackoverflow.com/questions/3032054/how-to-remove-mysql-root-password
Configure a host-only network, a host-only network is a private network between your VMs and the host-os only:
- Goto VirtualBox/File->Preferences->Network->Add host-only network (check if there exists one, check the IP ranges below else add a new one)
- 2. Select the add host-only network, Edit host-only network with following IP ranges with DHCP disabled (untick Enable DHCP):
IPv4 Address: 192.168.0.1 (address of your gateway)
IPv4 Network Mask: 255.255.255.0
- Leave other fields as it is and click OK, exit preferences.
Note: While configuring any host-only adapter adapter for a VM select its promiscuous mode to 'allow all'.
We'll use these IPs for our setup:
Ubuntu Linux as DNS/NFS
Create a VM in VirtualBox using the Ubuntu server ISO with about 500MB RAM or more, and disk 10+ GB.
In Network, enable two adapters: (select the first one for your primary network)
For the first one: select NAT.
For the second one: select host-only adapter, select vboxnet0 or appropriate adapter. Make sure to select the adapter's promiscuous mode to: Allow all..
The VirtualBox NAT has following defaults:
Gateway: 10.0.2.2 | DNS: 10.0.2.3 | DHCP: 10.0.2.1
Install Ubuntu Server (or any Linux distro) and install NFS and DNS server (DNS is optional): https://help.ubuntu.com/community/SettingUpNFSHowTo
sudo apt-get install bind9 nfs-kernel-server
To configure bind as a forwarding DNS, simply edit /etc/bind/named.conf.options: Enable forwarders to use 22.214.171.124.
Configure directory structure and NFS exports, setup a SSVM template:
mkdir -p /opt/storage/secondary
mkdir -p /opt/storage/secondary/template/tmpl/1/1
mkdir -p /opt/storage/secondary/template/tmpl/1/5
echo "/opt/storage/secondary *(rw,no_subtree_check,no_root_squash,fsid=0)" > /etc/exports
wget $fileSvr/defaulttemplates/1/dc68eb4c-228c-4a78-84fa-b80ae178fbfd.vhd -P /opt/storage/secondary/template/tmpl/1/1/
wget $fileSvr/defaulttemplates/1/template.properties -P /opt/storage/secondary/template/tmpl/1/1/
Optional: get a sample centos/vm template (~50MB) for testing on your host-os:
A SSVM template is required in the secondary storage (chicken-egg problem), as CloudStack runs the SSVM from NFS and then SSVM then mounts the NFS as secondary storage, make sure the 'host' in global settings is correctly set to your management server IP and at port 8250 it is reachable.
We wish to use NAT as our default interface.
Setup static IP for eth1: (check/edit /etc/network/interfaces)
iface eth1 inet static
Check routes: route -n (if 10.0.2.2/eth0 is not the default gateway, fix that)
Create two VMs (or create one VM, export it and import it as many time as number of XenServer VMs you want, depending on your system capability). Give it at least 2GB RAM, 10GB disk. Add one host-only adapter, select appropriate adapter (vboxnet0) and set promiscuous mode to 'Allow all'. Attach the XenServer ISO image and boot. During setup, skip check disk, skip supplementary packs, select manual time. For user root, use password: password. Static IP, 192.168.0.10 (for 1st vm, xs0.cloudstack.org) 192.168.0.11 (for 2nd vm, xs1.cloudstack.org), netmask 255.255.255.0, gateway 192.168.0.1 and dns 192.168.0.5.
For safety: after the XenServer boots up, login to dom0 of each XenServers and allocate some memory:
xe host-list | grep uuid
xe vm-param-set memory-dynamic-max=500MiB uuid=<put here your dom0's uuid>
Read the README and INSTALL.txt. Grab the source code:
git clone https://git-wip-us.apache.org/repos/asf/incubator-cloudstack.gitgit pull -v # Have your master updated
To build, deploy-server and database:
$ ant clean-all build-all deploy-server deploydb
Type to run mgt server:
$ ant debug
Basic Zone Configuration
Open (localhost is vboxnet0 gateway) http://192.168.0.1:8080/client with user: admin, password: password
Select the option that you know CloudStack. Now, goto Global Settings and make sure to configure these settings:
Restart the management server, ant debug.
Now open the mgmt server, goto Infrastructure-> Zone(View All)>Add Zone>Basic->
Internal DNS1: 192.168.0.5
Pod Name: MyPod
Reserved system gateway: 192.168.0.1
Reserved system netmask: 255.255.255.0
Start reserved system IP: 192.168.0.200
End reserved system IP: 192.168.0.220
Guest Gateway: 192.168.0.1
Guest Netmask: 255.255.255.0
Guest start IP: 192.168.0.100
Guest end IP: 192.168.0.199
Cluster Name: MyCluster
Secondary Storage (Primary storage form will be skipped, if it shows up check your Global Settings with fields mentioned in above section):
NFS Server: 192.168.0.5
Wait till your SSVM/CPVM get started, watchout for errors on your terminal. Next add host, 192.168.0.11. This setup would require a lot of RAM, your system may crash a lot.
If everything goes well, you've your own devcloud setup! Now try to add that template, try migration etc.