Sunday, February 12, 2017

Setting up Openstack on Ubuntu

I have been using Openstack for the past a couple of years, starting from Ice House, Juno, till Liberty and Mitaka. I have enough rights in the Horizon dashboard but somehow, i want to try the installation of Openstack myself onto my own VM.

Here as a reference I am taking some notes of what went into the effort.


1. Download Ubuntu 14.04 from:
    http://old-releases.ubuntu.com/releases/14.04.0/ubuntu-14.04-desktop-amd64.iso
    My VM's host machine is Windows 10, even though it is an Intel Inside, it is OK to use Ubuntu's AMD64 iso.
2. Setting up Ubuntu is pretty straight forward except, unlike Centos, Ubuntu is using Debian flavor of the package management tools: apt-get (while Centos uses rpm and yum). Assure the network setting in Virtualbox uses Bridged Adaptor and has Promiscuous Mode enabled, as below:

3. As usual, always perform update to the OS image that we just loaded.
    >sudo apt-get update
    >sudo apt-get upgrade
    (if there is any connectivity issue related to the network, do following:
    >sudo ifconfig eth0 down
    >sudo ifconfig eth0 up  )
    (if above also failed, add following to /etc/network/interface
  #The loopback network interface
   auto lo
   iface lo inet loopback
  #The primary network interface
   auto eth0
   iface eth0 inet static
   address 192.168.1.2   #<--use ifconfig to determine this
   netmask 255.255.255.0
   gateway 192.168.1.1
   dns-nameservers 192.168.1.1 8.8.8,8  #<-8.8.8.8 is google's DNS server)
4. Create new user stack, which is going to own openstack
   >sudo adduser stack
   >sudo passwd root
5. Change to be root user:  >su -
6. Grant the stack user with sudo privilege:
  >echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
7. change to user stack:
   >su - stack
8. Install git:
   >sudo apt-get install git
9. Get devstack from git hub
  >git clone https://git.openstack.org/openstack-dev/devstack

10. Change to devstack diretory: >cd devstack
11. Edit local.conf file to specify passwords used in the devstack installation with following contents: >vi local.conf
   [[local|localrc]]
   ADMIN_PASSWORD=openstack
   DATABASE_PASSWORD=openstack
   RABBIT_PASSWORD=openstack
   SERVICE_PASSWORD=openstack
12. Start the installation: ./stack.sh
13. After fair long time of installation below is the final results and my devstack installation:
    http://192.168.1.2/dashboard
    http://192.168.1.2/identity
    default users: admin and demo
    password: openstack


14. Plug in dashboard url and log in and start exploring...

Setting up Centos7 with Virtualbox

As more and more companies embrace the "Cloud", where I work was no exception. In recent 2+ years, I have been in PaaS team setting up platform for various application development teams.  In a nut shell, the work is about automation! Provisioning VMs, configuring VM with platform level components and services. Many times in the earlier stage, I felt like it would be very helpful to help junior team members to study and understand the corner stone - Virtual Machine - of the cloud paradigm. JVM, the most common virtual machine that we work with almost every single day. But, once being asked if the person has provisioned a Linux machine, the answer was normally no. In this blog, I am trying to capture the steps of setting up a Linux VM on windows.

Before we start, a few jargon or concepts to clarify:

  • Guest Machine: the virtual machine you get. 
  • Hypervisor: a piece of software that is responsible to create and manage virtual machines. Specifically, from infrastructure's angle, the resources to be managed are compute (CPU and memory), storage and network. In our example, Virtualbox is the Hypervisor.
  • Host Machine: the machine where virtual machines are created and run

In this example, the goal is to provision a Linux machine running in Windows. We will select Oracle's Virtualbox as hypervisor to create and manage our Linux VMs.

1a. Download "Centos DVD ISO" image from https://www.centos.org/download/ .
1b. Download Virtualbox for Windows Hosts from https://www.virtualbox.org/ For this exercise I am using version 5.1.10
2. Install Virtualbox on the windows machine. I am using windows 10.
3. Launch Virtualbox. You are presented with a console from which you can manage existing VMs or create a new VM. Click New button to create a new VM:

4. Give a name and select Redhat Linux (Centos in the list, but it is the community version fo Redhat Linux, so selecting Redhat is perfectly OK)

5. Memory allocation: depends on your host machine, select 6G as the minimum RAM setting

6. Storage allocation: for basic setup with Centos OS image, allocate 30G of host machine's hard disk.....



7. Upon hitting Create button, a new VM entry is created in the console list.

Let's continue setting up the new VM. Virtualbox provides you with many customization options. We will perform some basic ones below.

8. System: since there is no floppy dive here, disable boot from Floppy.

9. Display: give 32Mb video memory

10. Storage: Select the Centos7 image file we just downloaded for Optical Drive

11. Network: for demo and simple use cases, attach the network adapter to NAT and set the adapter type to be: Paravirtualized Network (virtio-net)

There are many options to config a VM's network setup. Refer to Virtualbox's official guidelines (https://www.virtualbox.org/manual/ch06.html).  I will explore in another post.
12. Done. Click on Start to set up the newly created VM.

Install Centos and Launch the VM
13. Complete the general setups (you may want to select the Gnu Desktop as well).

14. Create a root password and a new user which you can log on after the VM is ready.

15. Reboot and your VM is ready.

Update operating system with latest Centos updates
16. log in as the user you just created and then change to root: su -
17. yum -y update
      (if you see an error message like: Cannot find a valid baseurl for repo: base/7/x86_64
try to ping a web site, if unsuccessful, issue command dhclient should solve it. If not, as root, edit this file: 
>vi /etc/sysconfig/network-scripts/ifcfg-eth0
assure NM_CONTROLLED=no save it and issue
>ifdown eth0

>ifup eth0
 

It should take care of the issue.)
18. Install guest additions utilities packages: yum install kernel-devel
19. Install gcc compiler: yum install gcc* compiler
20. Now the new Centos 7 VM is ready to use.