Monday, December 21, 2015

Installing and running DevStack

Introduction

DevStack is like a small preconfigured OpenStack cloud.
To run it, you don't need to have your own datacenter, the average laptop would be enough for this purpose.

You can install DevStack just to taste OpenStack services, but it's mainly intended to be used in development process by OpenStack developers.
In this guide I will help you to install DevStack in a way suitable with further development process. After completing the guide you will know how to start and stop DevStack cloud and access it via OpenStack Dashboard web interface.

Instead of just providing instructions, I'll also tell you some important details and describe the obstacles you might be facing during the process of installing DevStack. When I was getting started with DevStack, I was in need of such guide. So now I'm writing this guide like for the past me.

Prerequisites

Before we start, ensure you have some linux knowledge and a machine (can be virtual) with at least 2 cores, 4GB of RAM or more and 50 GB or more free disk space. In my experience, DevStack can eat up to 8GB of RAM, so if you don't want your machine end up using swap(virtual memory), you better use a machine with more than 4GB of RAM.

Also it's preferred if the machine's processor supports virtualization natively. You can find out if it's true for your processor in the Internet. This feature is called vt-x on Intel processors and amd-v on AMD processors.

If you will use your existing development machine for running DevStack, you will find that the OS on your machine is bloated with new installed linux packages, new running services and DevStack components eating disk space. So it's better to use a separate machine or a virtual machine for running DevStack. This will allow DevStack to not interfere with services you might be already running on your development machine. And also it would be much easier to recreate DevStack environment, if something will go wrong. Don't worry, the development process would still be possible in this case with the help of file syncronization and remote control. I will tell you about them in my third guide about OpenStack.

If you decided to run DevStack in a virtual machine, I can recommend VirtualBox virtual machine manager. It's user frendly, can do snapshots and clone virtual machines. It's also totally okay if you'll create a virtual machine on the other non-development machine connected the same local network.
Note: if you plan to try Nova (Compute service) in DevStack or develop services relying on Nova or Nova itself, then you better not install DevStack on VirtualBox virtual machine. Use a real separate machine or other virtual machine manager. That's because VirtualBox doesn't support native nested virtualization, and Nova will use QEMU hypervisor (non-native virtualization) in that case. Your virtual machines will run slowly.

Then install fresh Ubuntu or CentOS operating system on the machine. The full list of supported operating systems for running DevStack you can find in the Official DevStack Page. If you choose Ubuntu as your DevStack machine's OS, don't forget to turn off some spying.

I will use VirtualBox and Ubuntu in this and the future guides about OpenStack.

Guide

Step 1. Making VirtualBox virtual machine fully accessible in your local network (Only for VirtualBox users)

I suppose you already have set up the virtual machine with 4GB of RAM or more, 2 cores, 50GB disk space and with Ubuntu/CentOS installed.

Now let's make the virtual machine fully accessible in your local network. In the Network section in the virtual machine's settings choose "Bridged Adapter" as network adapter:

Step 2. Cloning DevStack repository, creating stack user and configuring DevStack

In this step we will download the script called stack.sh. This script automatically sets up DevStack cloud.

On default settings stack.sh clones default OpenStack projects(services) to /opt/stack/ directory, sets up environment to run them, i.e. installs, configures and runs linux services they need, creates configuration files for each OpenStack service in /etc/<service> directory and finally starts them. After script execution the OpenStack services will be running in the background and you'll be able to play with them. The script's behavior can be customized by the local.conf configuration file.

There is also unstack.sh script that just stops OpenStack services.

Use the All-In-One Single Machine DevStack tutorial to clone DevStack repository with stack.sh inside and configure DevStackBut don't run the script yet, we'll do it in the next step.

I suppose you have created local.conf configuration file. You can find more about local.conf configuration options in DevStack Configuration. Take a look at the DEST, RECLONE and PIP_UPGRADE options. I think they are most important ones.

Step 3. Running stack.sh script

Inside the DevStack local repository execute:

stack@devstack:~/Sync/Repos/devstack$ ./stack.sh

During execution you will see many lines running in your terminal. Now you can relax as the script execution can take up to 5-10 minutes. You can go and make yoursef a tasty tea. 

If the execution was successful, you'll see something like this in your terminal:

...

This is your host IP address: 127.0.0.1
This is your host IPv6 address: ::1
Horizon is now available at http://127.0.0.1/dashboard
Keystone is serving at http://127.0.0.1:5000/
The default users are: admin and demo
The password: awwnotagain
stack@devstack:~/Sync/Repos/devstack$ 

Don't expect the magic right out of the box. The script might fail for some reason and show you an error instead. If that will happen to you, don't let it make you sad, instead, put the tea away and try to inspect the end of the log in your terminal to find what might be wrong. Then do the actions you think are right.

For example, some required packages might not be installed on your system and stack.sh will throw some "command not found" errors. In this case, just install these missing packages. Things might change in the future, but this is exactly what happens to me when I run stack.sh script on fresh Ubuntu 14.04:

stack@DevStack:~/Sync/Repos/devstack$ ./stack.sh
...
...
...
"2015-12-16 15:13:10.286 | /bin/sh: 1: brctl: not found".
stack@devstack:~/Sync/Repos/devstack$

I manually tried to execute brctl and Ubuntu gave me a hint what the package is missing:

stack@devstack:~/Sync/Repos/devstack$ brctl
The program 'brctl' is currently not installed. You can install it by typing:
sudo apt-get install bridge-utils
stack@devstack:~/Sync/Repos/devstack$

Then I installed bridge-utils package as Ubuntu suggested:

stack@devstack:~/Sync/Repos/devstack$ sudo apt-get install bridge-utils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  bridge-utils
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 29,2 kB of archives.
After this operation, 146 kB of additional disk space will be used.
Get:1 http://fi.archive.ubuntu.com/ubuntu/ trusty/main bridge-utils amd64 1.5-6ubuntu2 [29,2 kB]
Fetched 29,2 kB in 0s (237 kB/s)         
Selecting previously unselected package bridge-utils.
(Reading database ... 198643 files and directories currently installed.)
Preparing to unpack .../bridge-utils_1.5-6ubuntu2_amd64.deb ...
Unpacking bridge-utils (1.5-6ubuntu2) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up bridge-utils (1.5-6ubuntu2) ...
stack@devstack:~/Sync/Repos/devstack$

After this, I was able to execute stack.sh normally.

If you're facing a problem you can't solve, you can always ask for help in #openstack-dev IRC chat on freenode.net.

Step 4. Trying OpenStack Dashboard

You can go now to OpenStack Dashboard. Simply type "localhost" in the address bar in a web browser of your DevStack machine and press Enter. You will see the OpenStack login page.


Try to authenticate using these credentials:

User name: admin
Password: <the password you set in local.conf on step 2>

The Dashboard will open and you'll be able to manage your little DevStack cloud, e.g. manage users, nova instances, etc. Unfortunately for you, I will not describe how to manage particular components in this guide.


You can try to login to the Dashboard with other pre-created users such as: "demo" and "alt_demo". Use the same password as for admin account These are member accounts, they don't have admin rights, so the Dashboard will look different for them.

It's possible to connect to this Dashboard from another machines in your local network. Simply type the IP of the machine running DevStack in the address bar of the another machine's web browser:

http://<IP address of the machine running OpenStack>/

This might not work if you have firewalls installed on machines in your local network. You either have to disable them or configure properly.

Step 5. Turning off your DevStack cloud by unstack.sh

After you have finished playing with Dashboard (hope you didn't break anything), you might want to turn off your DevStack cloud. Inside the DevStack local repository execute:

stack@DevStack:~/Sync/Repos/devstack$ ./unstack.sh

In your terminal you'll see many lines appearing. They will not make much sense. Wait until they finish telling you probably something important. After that you can consider your DevStack cloud is stopped.

In the next guide...

In the next guide I will tell you how to use OpenStack command-line interface (CLI).
CLI can do everything OpenStack Dashboard can and even more!
Many of OpenStack services still don't have their respective UI in OpenStack Dashboard now. But all of them can be controlled by CLI.
One of these services is Zaqar aka Messaging and Notification service.
So we will also install this non-default service in DevStack and perform some actions on it by using CLI.

No comments:

Post a Comment