Starting an existing EC2 imageThe easiest way to bring up an EC2 image is to create one by cloning somebody elses. Amazon provide some prepopulated Fedora machines; various other people provide different images.
> ec2-describe-images -o self -o amazon IMAGE ami-20b65349 ec2-public-images/fedora-core4-base.manifest.xml amazon available public IMAGE ami-22b6534b ec2-public-images/fedora-core4-mysql.manifest.xml amazon available public IMAGE ami-23b6534a ec2-public-images/fedora-core4-apache.manifest.xml amazon available public IMAGE ami-25b6534c ec2-public-images/fedora-core4-apache-mysql.manifest.xml amazon available public IMAGE ami-26b6534f ec2-public-images/developer-image.manifest.xml amazon available public IMAGE ami-2bb65342 ec2-public-images/getting-started.manifest.xml amazon available public IMAGE ami-36ff1a5f ec2-public-images/fedora-core6-base-x86_64.manifest.xml amazon available public IMAGE ami-bd9d78d4 ec2-public-images/demo-paid-AMI.manifest.xml amazon available public A79EC0DB Pick one of the images, e.g ami-2bb65342 . This is an AMI ID. You can run an instance of this, with the given public key. you can then ssh in to it. Once you deploy it, the $$ starts accruing at $10c/hour or partial hour thereof. Play with it for a while (its cheaper than repeated start/stop, but then delete it before going home at night or the weekend. Make sure you have a the Firefox gui and AMI keys on your laptop so that you are ready to kill it while you travel. You can start the image from the GUI, or the command line, with a pointer to the private key to use ec2-run-instances ami-2bb65342 -k ec2-keypair1 This will queue the new VM for execution. > ec2-run-instances ami-2bb65342 -k ec2-keypair1 RESERVATION r-28c72941 190241856364 default INSTANCE i-3e798c57 ami-2bb65342 pending ec2-keypair1 0 m1.small 2007-11-20T16:02:15+0000 You are under the clock at this point;
consult the GUI For a status > ec2-describe-instances RESERVATION r-28c72941 190241856364 default INSTANCE i-3e798c57 ami-2bb65342 ec2-67-202-21-138.compute-1.amazonaws.com domU-12-31-38-00-22-56.compute-1.internal running ec2-keypair1 0 m1.small 2007-11-20T16:02:15+0000 Once the machine is live, you can ssh in using the key created earlier > ssh -i ~/.ssh/ec2.keypair.ssh ec2-67-202-21-138.compute-1.amazonaws.com -l root
The authenticity of host 'ec2-67-202-21-138.compute-1.amazonaws.com (67.202.21.138)' can't be established.
RSA key fingerprint is f9:9c:3b:f2:f0:75:74:a9:10:5a:8a:18:74:48:63:55.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-67-202-21-138.compute-1.amazonaws.com,67.202.21.138' (RSA) to the list of known hosts.
__| __|_ ) Rev: 2
_| ( /
___|\___|___|
Welcome to an EC2 Public Image
:-)
Getting Started
__ c __ /etc/ec2/release-notes.txt
The base example image is very bare: no java, fairly small machine df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 10321208 786868 9010052 9% / none 870472 0 870472 0% /dev/shm /dev/sda2 153915428 192076 145904908 1% /mnt From the gui you can grab the console output Linux version 2.6.16-xenU (builder@xenbat.amazonsa) (gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)) #1 SMP Mon May 28 03:41:49 SAST 2007
BIOS-provided physical RAM map:
Xen: 0000000000000000 - 000000006a400000 (usable)
980MB HIGHMEM available.
727MB LOWMEM available.
NX (Execute Disable) protection: active
IRQ lockup detection disabled
Built 1 zonelists
Kernel command line: root=/dev/sda1 ro 4
Enabling fast FPU save and restore... done.
Enabling unmasked SIMD FPU exception support... done.
Initializing CPU#0
PID hash table entries: 4096 (order: 12, 65536 bytes)
Xen reported: 2600.002 MHz processor.
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Software IO TLB disabled
vmalloc area: ee000000-f53fe000, maxmem 2d7fe000
Memory: 1718700k/1748992k available (1958k kernel code, 20948k reserved, 620k data, 144k init, 1003528k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok.
Calibrating delay using timer specific routine.. 5202.10 BogoMIPS (lpj=26010529)
Mount-cache hash table entries: 512
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 1024K (64 bytes/line)
Checking 'hlt' instruction... OK.
Brought up 1 CPUs
migration_cost=0
Grant table initialized
NET: Registered protocol family 16
Brought up 1 CPUs
xen_mem: Initialising balloon driver.
highmem bounce pool size: 64 pages
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
Initializing Cryptographic API
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
i8042.c: No controller found.
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Xen virtual console successfully installed as tty1
Event-channel device installed.
netfront: Initialising virtual ethernet driver.
mice: PS/2 mouse device common for all mice
md: md driver 0.90.3 MAX_MD_DEVS=256, MD_SB_DISKS=27
md: bitmap version 4.39
NET: Registered protocol family 2
Registering block device major 8
IP route cache hash table entries: 65536 (order: 6, 262144 bytes)
TCP established hash table entries: 262144 (order: 9, 2097152 bytes)
TCP bind hash table entries: 65536 (order: 7, 524288 bytes)
TCP: Hash tables configured (established 262144 bind 65536)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
NET: Registered protocol family 15
Using IPI No-Shortcut mode
md: Autodetecting RAID arrays.
md: autorun ...
md: ... autorun DONE.
kjournald starting. Commit interval 5 seconds
EXT3-fs: mounted filesystem with ordered data mode.
VFS: Mounted root (ext3 filesystem) readonly.
Freeing unused kernel memory: 144k freed
***************************************************************
***************************************************************
** WARNING: Currently emulating unsupported memory accesses **
** in /lib/tls glibc libraries. The emulation is **
** slow. To ensure full performance you should **
** install a 'xen-friendly' (nosegneg) version of **
** the library, or disable tls support by executing **
** the following as root: **
** mv /lib/tls /lib/tls.disabled **
** Offending process: init (pid=1) **
***************************************************************
***************************************************************
Pausing... 5Pausing... 4Pausing... 3Pausing... 2Pausing... 1Continuing...
INIT: version 2.85 booting
/etc/rc.d/rc.sysinit: line 78: /dev/tty1: Read-only file system
/etc/rc.d/rc.sysinit: line 78: /dev/tty2: Read-only file system
/etc/rc.d/rc.sysinit: line 78: /dev/tty3: Read-only file system
/etc/rc.d/rc.sysinit: line 78: /dev/tty4: Read-only file system
/etc/rc.d/rc.sysinit: line 78: /dev/tty5: Read-only file system
/etc/rc.d/rc.sysinit: line 78: /dev/tty6: Read-only file system
/etc/rc.d/rc.sysinit: line 82: /dev/tty7: Read-only file system
/etc/rc.d/rc.sysinit: line 83: /dev/tty8: Read-only file system
Welcome to Fedora Core
Press 'I' to enter interactive startup.
Starting udev:[ OK ]
Initializing hardware... storage network audio done[ OK ]
Setting clock : Tue Nov 20 11:03:31 EST 2007 [ OK ]
Setting hostname localhost: [ OK ]
Setting up Logical Volume Management: No volume groups found
[ OK ]
Checking filesystems
Checking all file systems.
[/sbin/fsck.ext3 (1) -- /] fsck.ext3 -a /dev/sda1
/dev/sda1 has gone 350 days without being checked, check forced.
/dev/sda1: 30694/1310720 files (0.4% non-contiguous), 237761/2621440 blocks
[ OK ]
Remounting root filesystem in read-write mode: [ OK ]
Mounting local filesystems: [ OK ]
Enabling local filesystem quotas: [ OK ]
Enabling swap space: [ OK ]
INIT: Entering runlevel: 4
Entering non-interactive startup
Starting sysstat: Calling the system activity data collector (sadc):
[ OK ]
Checking for new hardwaremmap /dev/mem: Bad address
mmap /dev/mem: Bad address
[ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth0... done.
[ OK ]
Starting system logger: [ OK ]
Starting kernel logger: [ OK ]
Starting auditd: [FAILED]
Error sending rule list request (Connection refused)
Error sending watch list request (Connection refused)
Error sending rule list request (Connection refused)
Error sending watch list request (Connection refused)
There was an error in line 7 of /etc/audit.rules
Mounting other filesystems: [ OK ]
Starting automount: [ OK ]
Starting sshd: [ OK ]
Starting sendmail: [ OK ]
Starting sm-client: [ OK ]
Starting httpd: [ OK ]
Starting crond: [ OK ]
Starting anacron: [ OK ]
Starting atd: [ OK ]
Starting system message bus: [ OK ]
Starting HAL daemon: [ OK ]
50+0 records in
50+0 records out
Changing password for user root.
passwd: all authentication tokens updated successfully.
Attempting ami-utils update from S3
--11:03:43-- http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.noarch.rpm
=> `ec2-ami-tools.noarch.rpm'
Resolving s3.amazonaws.com... 72.21.206.184
Connecting to s3.amazonaws.com|72.21.206.184|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 106,025 (104K) [audio/x-pn-realaudio-plugin]
0% [ ] 0 --.--K/s 100%[====================================>] 106,025 --.--K/s
11:03:46 (8.88 MB/s) - `ec2-ami-tools.noarch.rpm' saved [106025/106025]
ec2: Retreived ec2-ami-tools from S3
ec2: Preparing... ##################################################
ec2: ec2-ami-tools ##################################################
ec2: Updated ec2-ami-tools from S3
grep: /root/.ssh/authorized_keys: No such file or directory
c
Fedora Core release 4 (Stentz)
Kernel 2.6.16-xenU on an i686
domU-12-31-38-00-22-56 l
Things to do once logged in
Rebooting an imagewhen you reboot an image, its launch time doesnt appear to change. it is cheaper than stopping and starting a machine, as you do not create a new image. [root@domU-12-31-38-00-22-56 .ssh]# Broadcast message from root (console) (Tue Nov 20 11:31:05 2007): The system is going down for reboot NOW! Read from remote host ec2-67-202-21-138.compute-1.amazonaws.com: Connection reset by peer Connection to ec2-67-202-21-138.compute-1.amazonaws.com closed. When it comes back up, all persistent state changes appear as is. Rebooting an instance does not lose instance-local data. The console log shows a normal shutdown Fedora Core release 4 (Stentz) INIT: Sending processes the TERM signal Stopping HAL daemon: [ OK ] Stopping system message bus: [ OK ] Stopping anacron: [ OK ] Stopping atd: [ OK ] Stopping httpd: [ OK ] Stopping sshd: [ OK ] Shutting down sm-client: [ OK ] Shutting down sendmail: [ OK ] Stopping crond: [ OK ] Stopping automount:[ OK ] Shutting down kernel logger: [ OK ] Shutting down system logger: [ OK ] Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Stopping sysstat: [ OK ] Starting killall: [ OK ] Sending all processes the TERM signal... Sending all processes the KILL signal... Saving random seed: Syncing hardware clock to system time Turning off swap: Turning off quotas: Unmounting file systems: Please stand by while rebooting the system... md: stopping all md devices. md: md0 switched to read-only mode. Restarting system. . You can reboot on the command line, by using the instance ID: > ec2-reboot-instances i-3e798c57 > Killing the imageyou can do this in the EC2 gui or on the command line: > ec2-terminate-instances i-3e798c57 INSTANCE i-3e798c57 running shutting-down The GUI shows the console as shutting down, and then terminated (user initiated). The console shows system halted, as with a {{reboot -h }} operation. > ec2-describe-instances i-3e798c57 RESERVATION r-28c72941 190241856364 default INSTANCE i-3e798c57 ami-2bb65342 terminated ec2-keypair1 0 m1.small 2007-11-20T16:02:15+0000 Note that the reservation remains, and even after termination you get a short period to restart it. So maybe your hour's allocation of the CPU remains even after you kill the image -you can add a new image using the remaining time. The image no longer has an IP address, of course. MountingThere is a directory /mnt that is always transient. Use this to store secret information that you do not want saved in an AMI when you create an AMI for reuse. TroubleshootingBad keys>ec2-run-instances ami-2bb65342 -k ~/.ssh/ec2.keypair.ssh Client.InvalidKeyPair.NotFound: The key pair '/home/slo/.ssh/ec2.keypair.ssh' does not exist You need to give the name of the keypair as listed in the AWS server "ec2-keypair1" not the path to the local file. |