Run your own instance

From Flyer
Revision as of 10:41, 20 September 2010 by Rqcheng (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Euca2ools currently only works under linux, for windows or mac or other os users, please refer to ElasticFox further.

Run a new virtual machine instance in the ubuntu private cloud

install Euca2ools

  1. install euca2ools from your repository or from the original site, for 32bit ubuntu users, you can just run "sudo apt-get install euca2ools"; or if you decide to download it from the original site, only download the Euca2ools is enough; for just a cloud user, there is no need to install the entire eucalyptus;

Now you can run any commands started with "euca-", though it will fail with "EC2_ACCESS_KEY environment variable must be set."

read Eucalyptus users guide

read the original article, or here simplified steps:

  1. Sign up an account at flyer-1
  2. After approval, go back to flyer-1, login, from the "Credentials" page, use "Download Credentials", get a zip file, mkdir ~/.euca/, and unzip into it; optionally keep it private with chmod (chmod 0600 ~/.euca/);
  3. find eucarc file, and import it to current shell, it is "source ~/.euca/eucarc"
  4. Run with euca commands:
$ source ~/.euca/eucarc
    # to import eucarc into current shell
$ euca-describe-images
    # list all availables images, notice lines end with "machine", only those are really available,
    # find their id, currently only "emi-D1EA1497" and "emi-129415BA", correspond to 32bit or 64bit linux;
$ euca-add-keypair mykey >mykey.private
    # create your own public/private key pair, optionally use any string to replace "mykey"; use "chmod 0600 mykey.private" to keep that file private;
$ euca-run-instances -k mykey -n 1 <emi-id>
    # here use above two emi-id; it will default run a machine with 1 processor, 128M memory, and 2GB disk;
    # if you need a more powerful machine, try add a parameter "-t <type>", type can be one of the five, "m1.small, c1.medium, m1.large, m1.xlarge, c1.xlarge";
    # but please DO NOT WASTE resource, try large only if you really need;
$ euca-describe-instances
    # to watch the output of "euca-describe-instances" every 2s, till your instance state become to "running";
    # or use watch euca-describe-instances
    # usually need a minute or more time, it depends on how many instances are already running;
    # notice your assigned public IP address, like;
$ euca-authorize -P tcp -p 22 -s default
    # allow your instance can be connected by ssh;
$ ssh -i mykey.private ubuntu@<accessible-instance-ip>
    # connect to your public address, like;

Enjoy your own virtual machine journey ~

create and attach your own volume

With the methods above, you can run your own vm instance now, but there is a defect that when you leave your vm, terminate it; all your modifications are lost; so then the problem is how to keep your own data persistent between rebooting?

euca provide a method to create your own volume, and attach it to your running instance, this volume is persistently allocated to the account your signed up above, in the vm instance there will be a notice of new storage attached, you can create a filesystem and store your own data on it,

$ euca-create-volume -z flyer-1 -s 8
VOLUME	vol-43D30586	8	creating	2009-12-09T07:59:24.083Z

$ euca-describe-volumes 
VOLUME	vol-43D30586	 8		flyer-1	available	2009-12-09T07:59:24.083Z

here you get the volume id "vol-43D30586", and then you can attach your volume to your running vm instance,

$ euca-attach-volume -i i-3AB4068D -d /dev/sdb vol-43D30586
VOLUME	vol-43D30586

and in your vm, re-check the storage, you will find a new disk named /dev/sdb, like:

$ sudo fdisk -l

Disk /dev/sda: 5416 MB, 5416943616 bytes
4 heads, 32 sectors/track, 82656 cylinders
Units = cylinders of 128 * 512 = 65536 bytes
Disk identifier: 0x00043e69

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       32769     2097152+  83  Linux
/dev/sda2           32769       71910     2505000+  83  Linux
/dev/sda3           71910       82656      687799+  82  Linux swap / Solaris

Disk /dev/sdb: 8589 MB, 8589934592 bytes
64 heads, 32 sectors/track, 8192 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

then the first time you can partition it or directly create a filesystem on it, mount it on somewhere, use it,

$ sudo mkfs.ext4 /dev/sdb
$ sudo mkdir /mnt/sdb
$ sudo mount /dev/sdb /mnt/sdb
$ df
/dev/sdb      ext4    7.9G  146M  7.4G   2% /mnt/sdb

the last "df" command shows that there is a new volume mounted under /mnt/sdb, you can use it in anyway you like, it's your own persistent storage. Next time you start another instance or terminate and run new instance, you can still attach this volume to it and mount it directly, and get all data back again.

bundle and register your own vm image

Instance Types

the cloud currently supports 5 different instance types:

VM Types
Name CPUs Memory (MB) Disk (GB)
m1.small 1 512 5
c1.medium 2 1024 10
m1.large 3 2048 20
m1.xlarge 4 3072 20
c1.xlarge 6 6144 20
after a 6-core amd machine added to this cloud on June 2010, I adjust c1.xlarge to 6 core configuration;
this information is also in the output of euca-describe-availability-zones, run by admin of the cloud;
$ euca-describe-availability-zones verbose
AVAILABILITYZONE	|- vm types	free / max   cpu   ram  disk
AVAILABILITYZONE	|- m1.small	0004 / 0008   1    128     2
AVAILABILITYZONE	|- c1.medium	0004 / 0008   1    256     5
AVAILABILITYZONE	|- m1.large	0002 / 0004   2    512    10
AVAILABILITYZONE	|- m1.xlarge	0002 / 0004   2   1024    20
AVAILABILITYZONE	|- c1.xlarge	0000 / 0001   4   2048    20

For any questions further, you can also contact CHENG Renquan, or directly go to cubic 44.