Running OpenStack Compute (Nova)
Using Nova as a cloud fabric controller, you are first going to need to setup user credentials. Using those, you'll be able to upload images that you want to run in the cloud, then start an instance and connect to it. Here are some basic commands to get Nova running once it's installed.
Contents
Configuration
There are many ways to configure Nova, but the basics include the nova.conf file, setting up the database, and integrating networking.
Setting up a volume group
You'll need to create a volume group for nova-volume if you see errors where the volume manager is looking for the nova-volumes lvm group. More detailed instructions for configuring Compute (nova) to use volumes is available on docs.openstack.org in the Compute Admin manual.
# This creates a 1GB file to create volumes out of dd if=/dev/zero of=MY_FILE_PATH bs=100M count=10 losetup --show -f MY_FILE_PATH # replace /dev/loop0 below with whatever losetup returns # nova-volumes is the default for the --volume_group flag vgcreate nova-volumes /dev/loop0
Setting up your user
If you have installed OpenStack Compute from the nova.sh script, the Nova administrator user was already created for you, and an image was already registered. You can skip directly to Starting an instance.
Create the network configuration
Type or copy/paste in the following line to create a network prior to creating a user or a project.
sudo nova-manage network create novanetwork 10.0.0.0/8 1 64
For this command, the IP address is the cidr notation for your netmask, such as 192.168.1.0/24. The value 1 is the total number of networks you want made, and the 64 value is the number of IP addresses in each network.
Note: This syntax applies to release D3, earlier releases omit the network name "novanetwork"
After running this command, entries are made in the ‘networks’ and ‘fixed_ips’ table in the database.
Create a Nova administrator
Type or copy/paste in the following line to create a user named "anne".
sudo nova-manage user admin anne
You see an access key and a secret key export, such as these made-up ones:
export EC2_ACCESS_KEY=4e6498a2-blah-blah-blah-17d1333t97fd export EC2_SECRET_KEY=0a520304-blah-blah-blah-340sp34k05bbe9a7
Create a project for the user you created
Type or copy/paste in the following line to create a project named IRT (for Ice Road Truckers, of course) with the newly-created user named anne.
sudo nova-manage project create IRT anne
Download credentials for your user/project
Next, type or copy/paste in the following line to get your credentials as a zip file.
sudo nova-manage project zipfile IRT anne
2011-01-31 12:00:53,151 WARNING nova.auth.manager [-] No vpn data for project IRT
Note: If you see an "error loading the config file './openssl.cnf'" it means you can copy the openssl.cnf file to the location where Nova expects it and reboot, then try the command again. Alternatively, if you haven't done yet, generate the certificate information first:
cd /opt/nova-2011.1/CA sudo ./genrootca.sh
Generating a 1024 bit RSA private key ......................................................++++++ .............................................++++++ writing new private key to 'private/cakey.pem' ----- Using configuration from ./openssl.cnf
Unzip and source credentials
You should have a nova.zip file in your current working directory. Unzip it with this command:
unzip nova.zip
You'll see these files extract:
Archive: nova.zip extracting: novarc extracting: pk.pem extracting: cert.pem extracting: nova-vpn.conf extracting: cacert.pem
Then type or copy/paste the following to source the novarc file in your current working directory.
. novarc
If you open a new shell, you'll have to source the novarc file again so that the commands know which cloud credentials to use.
Register an image
Instances are created from registered images. Before you can spin your own instance, you will have to register an image.
Get an image
There are several sources for cloud-ready image tarballs:
Guest OS |
Image size |
Direct link |
~196 Mb |
||
~177 Mb |
||
~7 Mb |
||
ttylinux test image [replaced by cirros] |
~23 Mb |
You can use wget to download the selected image, for example:
wget http://uec-images.ubuntu.com/releases/10.04/release/ubuntu-10.04-server-uec-amd64.tar.gz
Registering the image
If you are using Ubuntu, you can use uec-publish-tarball from the cloud-utils package to register the tarball in one step:
uec-publish-tarball ubuntu-10.04-server-uec-amd64.tar.gz mybucket
This will register your image in the "mybucket" bucket. The tool will output 3 references: emi, eri and eki. You need to use the emi value in the next section (I got “ami-g06qbntt″).
If you can't use uec-publish-tarball, untar the image and customize the first parameters in bundleUploadRegister.sh for your image or follow the manual registration process.
Starting an instance
Create a SSH keypair
Type or copy/paste the following commands to generate and register a SSH keypair for use in accessing the instances.
euca-add-keypair mykey > mykey.priv chmod 600 mykey.priv
Start the instance
Type or copy/paste the following commands to run an instance using the keypair and IDs that we previously created.
euca-run-instances ami-g06qbntt -k mykey -t m1.tiny
You should see this in response:
RESERVATION r-0at28z12 IRT INSTANCE i-1b0bh8n ami-g06qbntt 10.0.0.3 10.0.0.3 scheduling mykey (IRT, None) m1.tiny 2010-10-18 19:02:10.443599
Wait for instance to be running
Type or copy/paste the following command repeatedly to watch as the scheduler launches, and completes booting your instance:
euca-describe-instances
While the instance is still launching, you should see this in response:
RESERVATION r-0at28z12 IRT INSTANCE i-1b0bh8n ami-g06qbntt 10.0.0.3 10.0.0.3 launching mykey (IRT, cloud02) m1.tiny 2010-10-18 19:02:10.443599
When the instance is running, you should see this in response:
RESERVATION r-0at28z12 IRT INSTANCE i-1b0bh8n ami-g06qbntt 10.0.0.3 10.0.0.3 running mykey (IRT, cloud02) 0 m1.tiny 2010-10-18 19:02:10.443599
Authorize SSH connections to the instance and connect
Type or copy/paste the following commands to ssh to the instance using your private key.
euca-authorize -P tcp -p 22 default ssh -i mykey.priv root@10.0.0.3
Tear down instance when you're done with it
Type or copy/paste the following commands to tear down the instance when you're done with it.
euca-terminate-instances i-1b0bh8n