Docsity

OpenStack Compute and Storage Configuration: A Practical Guide, Study notes of Computer Science

Partial preview of the text

Download OpenStack Compute and Storage Configuration: A Practical Guide and more Study notes Computer Science in PDF only on Docsity!

OpenStack Cloud

Computing Cookbook

Over 100 recipes to successfully set up and manage your

OpenStack cloud environments with complete coverage

of Nova, Swift, Keystone, Glance, and Horizon

Kevin Jackson

BIRMINGHAM - MUMBAI

Credits

Author

Kevin Jackson

Reviewers

Thierry Carrez Atul Kumar Jha

Acquisition Editor

Kartikey Pandey

Lead Technical Editor

Azharuddin Sheikh

Technical Editors

Veronica Fernandes Azharuddin Sheikh Prasad Dalvi Joyslita D'Souza

Copy Editor Brandt D'Mello

Project Coordinator Yashodhan Dere

Proofreader Kevin McGowan

Indexer Tejal R. Soni

Production Coordinator Nilesh R. Mohite

Cover Work Nilesh R. Mohite

About the Author

Kevin Jackson is married, with three children. He is an experienced IT professional working

with small businesses and online enterprises. He has extensive experience with various flavors of Linux and Unix. He specializes in web and cloud infrastructure technologies for Trader Media Group.

I'd like to thank my wife, Charlene, and the rest of my family for their time, patience, and encouragement throughout the book.

I'd also like to extend my thanks to the OpenStack community, which has helped a great deal during my journey with OpenStack. The talent and support is phenomenal. Without the OpenStack community, there would be no OpenStack.

A specific mention goes to all those who have made this book possible. Your comments, guidance, and motivation have made writing this book an enjoyable experience.

www.PacktPub.com

Support files, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support files and downloads related to your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.

Why Subscribe?

f Fully searchable across every book published by Packt f Copy and paste, print and bookmark content f On demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

Table of Contents

iii

iv

  • Preface
  • Chapter 1: Starting OpenStack Compute
    • Introduction
    • Creating a sandbox environment with VirtualBox
    • Installing OpenStack Compute packages
    • Configuring database services
    • Configuring OpenStack Compute
    • Stopping and starting Nova services
    • Creating a cloudadmin account and project
    • Installation of command line-tools
    • Uploading a sample machine image
    • Launching your first cloud instance
    • Terminating your instance
  • Chapter 2: Administering OpenStack Compute
    • Introduction
    • Creating and modifying user accounts
    • Managing security groups
    • Creating and managing keypairs
    • Using public cloud images
    • Alternative upload method using euca2ools
    • Creating custom Windows images
    • Creating custom CentOS images
  • Chapter 3: Keystone OpenStack Identity Service
    • Introduction
    • Installing OpenStack Identity Service
    • Configuring roles
    • Creating tenants
    • Adding users
    • Defining service endpoints Table of Contents
    • Configuring the service tenant and service users
    • Configuring OpenStack Image Service to use OpenStack Identity Service
    • Configuring OpenStack Compute to use OpenStack Identity Service
    • Using OpenStack Compute with OpenStack Identity Service
  • Chapter 4: Installing OpenStack Storage
    • Introduction
    • Creating an OpenStack Storage sandbox environment
    • Installing the OpenStack Storage services
    • Configuring storage
    • Configuring replication
    • Configuring OpenStack Storage Service
    • Configuring the OpenStack Storage proxy server
    • Configuring Account Server
    • Configuring Container Server
    • Configuring Object Server
    • Making the Object, Account, and Container rings
    • Stopping and starting OpenStack Storage
    • Testing OpenStack Storage
    • Setting up SSL access
    • Configuring OpenStack Storage with OpenStack Identity Service
  • Chapter 5: Using OpenStack Storage
    • Introduction
    • Installing the swift client tool
    • Creating containers
    • Uploading objects
    • Uploading large objects
    • Listing containers and objects
    • Downloading objects
    • Deleting containers and objects
    • Using OpenStack Storage ACLs
  • Chapter 6: Administering OpenStack Storage
    • Introduction
    • Preparing drives for OpenStack Storage
    • Managing the OpenStack Storage cluster with swift-init
    • Checking cluster health
    • OpenStack Storage benchmarking
    • Managing capacity
    • Removing nodes from a cluster
    • Detecting and replacing failed hard drives Table of Contents
    • Collecting usage statistics
  • Chapter 7: Glance OpenStack Image Service
    • Introduction
    • Installing OpenStack Image Service
    • Configuring OpenStack Image Service with MySQL
    • Configuring OpenStack Compute with OpenStack Image Service
    • Configuring OpenStack Image Service with OpenStack Storage
    • Managing images with OpenStack Image Service
    • Registering a remotely stored image
  • Chapter 8: Nova Volumes
    • Introduction
    • Configuring nova-volume services
    • Configuring OpenStack Compute for nova-volume
    • Creating volumes
    • Attaching volumes to instances
    • Detaching volumes from an instance
    • Deleting volumes
  • Chapter 9: Horizon OpenStack Dashboard
    • Introduction
    • Installing OpenStack Dashboard
    • Keypair management in OpenStack Dashboard
    • Security group management by using OpenStack Dashboard
    • Launching instances by using OpenStack Dashboard
    • Terminating instances by using OpenStack Dashboard
    • Connecting to instances by using OpenStack Dashboard and VNC
    • Adding new tenants by using OpenStack Dashboard
    • User management by using OpenStack Dashboard
  • Chapter 10: OpenStack Networking
    • Introduction
    • Configuring Flat networking
    • Configuring Flat networking with DHCP
    • Configuring VLAN Manager networking
    • Configuring per-project (tenant) IP ranges
    • Automatically assigning fixed networks to tenants
    • Modifying a tenant's fixed network
    • Manually associating floating IPs to instances
    • Manually disassociating floating IPs from instances
    • Automatically assigning floating IPs
  • Chapter 11: In the Datacenter Table of Contents
    • Introduction
    • Installing MAAS for bare-metal provisioning
    • Using MAAS for bare-metal provisioning of hosts
    • Installing and configuring Juju
    • Installing OpenStack services using Juju
    • Increasing OpenStack Compute capacity
    • MySQL clustering using Galera
    • Configuring HA Proxy for MySQL Galera load balancing
    • Increasing resilience of OpenStack services
    • Bonding network interfaces for redundancy
  • Chapter 12: Monitoring
    • Introduction
    • Monitoring Compute services with Munin
    • Monitoring instances using Munin and Collectd
    • Monitoring the storage service using StatsD/Graphite
    • Monitoring MySQL with Hyperic
  • Chapter 13: Troubleshooting
    • Introduction
    • Checking OpenStack Compute Services
    • Understanding logging
    • Troubleshooting OpenStack Compute Services
    • Troubleshooting OpenStack Storage Service
    • Troubleshooting OpenStack Authentication
    • Submitting bug reports
    • Getting help from the community
  • Index

Preface

2

What this book covers

Chapter 1 , Starting OpenStack Compute , teaches you how to set up and use OpenStack Compute running within a VirtualBox environment.

Chapter 2, Administering OpenStack Compute , teaches you how to manage user accounts and security groups as well as how to deal with cloud images to run in an OpenStack environment.

Chapter 3 , Keystone OpenStack Identity Service , takes you through installation and configuration of Keystone, which underpins all of the other OpenStack services.

Chapter 4 , Installing OpenStack Storage , teaches you how to configure and use OpenStack Storage running within a VirtualBox environment.

Chapter 5 , Using OpenStack Storage , teaches you how to use the storage service for storing and retrieving files and objects.

Chapter 6 , Administering OpenStack Storage , takes you through how to use tools and techniques that can be used for running OpenStack Storage within datacenters.

Chapter 7 , Glance OpenStack Image Service , teaches you how to upload and modify images (templates) for use within an OpenStack environment.

Chapter 8 , Nova Volumes , teaches you how to install and configure the persistent storage service for use by instances running in an OpenStack Compute environment.

Chapter 9 , Horizon OpenStack Dashboard , teaches you how to install and use the web user interface to perform tasks such as creating users, modifying security groups, and launching instances.

Chapter 10 , OpenStack Networking , helps you understand the networking options currently available as well as teaching you how to configure an OpenStack environment so that instances are accessible on the network.

Chapter 11 , In the Datacenter , takes you through understanding how to do bare-metal provisioning, scale up OpenStack, and introduces you to adding resilience to our OpenStack installations for high availability.

Chapter 12 , Monitoring , shows you how to install and configure various open source tools for monitoring an OpenStack installation.

Chapter 13 , Troubleshooting , takes you through an understanding of the logs and where to get help when encountering issues while running an OpenStack environment.

Preface

3

What you need for this book

To use this book, you will need access to computers or servers that have hardware virtualization capabilities. To set up the lab environments you will need Oracle's VirtualBox installed. You will also need access to an Ubuntu 12.04 ISO image, as the methods presented detail steps for Ubuntu environments.

Who this book is for

This book is aimed at system administrators and technical architects moving from a virtualized environment to cloud environments who are familiar with cloud computing platforms. Knowledge of virtualization and managing Linux environments is expected. Prior knowledge or experience of OpenStack is not required, although beneficial.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Similar information is presented by the nova list and nova show commands".

A block of code is set as follows:

bind_port = 443 cert_file = /etc/swift/cert.crt key_file = /etc/swift/cert.key

Any command-line input or output is written as follows:

sudo apt-get update

sudo apt-get -y install qemu-kvm cloud-utils

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "In the INSTANCE section, we get details of our running instance".

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Starting OpenStack

Compute

In this chapter, we will cover:

f Creating a sandbox environment with VirtualBox f Installing OpenStack Compute packages f Configuring database services f Configuring OpenStack Compute f Stopping and starting Nova services f Creating a cloudadmin account and project f Installation of command-line tools f Uploading a sample machine image f Launching your first cloud instance f Terminating your instance

Chapter 1: Starting OpenStack Compute

6

Introduction

OpenStack Compute, also known as Nova, is the compute component of the open source cloud operating system, OpenStack. It is the component that allows you to run multiple instances of virtual machines on any number of hosts running the OpenStack Compute service, allowing you to create a highly scalable and redundant cloud environment. The open source project strives to be hardware and hypervisor agnostic. Nova compute is analogous to Amazon's EC2 (Elastic Compute Cloud) environment and can be managed in a similar way, demonstrating the power and potential of this service.

This chapter gets you up to speed quickly by giving you the information you need to create a cloud environment running entirely from your desktop machine. At the end of this chapter, you will be able to create and access virtual machines using the same command line tools you would use to manage Amazon's own EC2 compute environment.

Creating a sandbox environment

with VirtualBox

Creating a sandbox environment using VirtualBox allows us to discover and experiment with the OpenStack Compute service, known as Nova. VirtualBox gives us the ability to spin up virtual machines and networks without affecting the rest of our working environment and is freely available from http://www.virtualbox.org for Windows, Mac OSX, and Linux. This test environment can then be used for the rest of this chapter.

It is assumed the computer you will be using to run your test environment in has enough processing power and has hardware virtualization support (modern AMDs and Intel iX processors) with at least 4 GB RAM. Remember we're creating a virtual machine that itself will be used to spin up virtual machines, so the more RAM you have, the better.

Getting ready

To begin with, we must download VirtualBox from http://www.virtualbox.org/ and then follow the installation procedure once this has been downloaded.

We will also need to download the Ubuntu 12.04 LTS Server ISO CD-ROM image from http://www.ubuntu.com/.

Starting OpenStack Compute

8

# Create CD-Drive and Attach ISO VBoxManage storagectl openstack1 --name "IDE Controller" --add ide --controller PIIX4 --hostiocache on --bootable on VBoxManage storageattach openstack1 --storagectl "IDE Controller" --type dvddrive --port 0 --device 0 --medium Downloads/ubuntu- 12.04-server-amd64.iso

# Create and attach SATA Interface and Hard Drive VBoxManage storagectl openstack1 --name "SATA Controller" --add sata --controller IntelAHCI --hostiocache on --bootable on VBoxManage createhd --filename openstack1.vdi --size 20480 VBoxManage storageattach openstack1 --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium openstack1.vdi

  1. We are now ready to power on our OpenStack1 node. Do this by selecting OpenStack1 Virtual Machine and then clicking on the Start button or by running the following command: VBoxManage startvm openstack1 --type gui
  2. This will take us through a standard text-based Ubuntu installer, as this is the server edition. Choose appropriate settings for your region and choose Eth0 as the main interface (this is the first interface in your VirtualBox VM settings—our NATed interface). When prompted for software selection, just choose SSH Server and continue. For a user, create a user named openstack and the password of openstack. This will help with using this book to troubleshoot your own environment.
  3. Once installed, log in as the openstack user.
  4. We can now configure networking on our OpenStack Compute node. To do this we will create a static address on the second interface, eth1, which will be the public interface and also configure our host to bring up eth2 without an address, as this interface will be controlled by OpenStack to provide the private network. To do this, edit the /etc/network/interfaces file with the following contents:

    The loopback network interface

    auto lo iface lo inet loopback

The primary network interface

auto eth iface eth0 inet dhcp

Public Interface

auto eth iface eth1 inet static address 172.16.0. netmask 255.255.0. network 172.16.0. broadcast 172.16.255.

Chapter 1

9

Private Interface

auto eth iface eth2 inet manual up ifconfig eth2 up

Remember to edit the /etc/network/interfaces file with root privileges.

  1. Save the file and bring up the interfaces with the following commands:

sudo ifup eth sudo ifup eth

Congratulations! We have successfully created the VirtualBox virtual machine running Ubuntu, which is able to run OpenStack Compute.

How it works...

What we have done is created a virtual machine that is the basis of our OpenStack Compute host. It has the necessary networking in place to allow us to access this virtual machine from our host personal computer.

There's more...

There are a number of virtualization products available that are suitable for trying OpenStack, for example, VMware Server and VMware Player are equally suitable. With VirtualBox, you can also script your installations using a tool named Vagrant. While outside the scope of this book, the steps provided here allow you to investigate this option at a later date.

Installing OpenStack Compute packages

Now that we have a machine for running OpenStack, we can install the appropriate packages for running OpenStack Compute, which will allow us to spawn its own virtual machine instances.

To do this, we will create a machine that runs all the appropriate services for running OpenStack Nova. The services are as follows:

f nova-compute: The main package for running the virtual machine instances f nova-scheduler: The scheduler picks the server for fulfilling the request to run the instance