个人工具

“UbuntuHelp:UEC/RunningImages”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(创建新页面为 '{{From|https://help.ubuntu.com/community/UEC/RunningImages}} {{Languages|UbuntuHelp:UEC/RunningImages}} There are multiple ways to instantiate an image in UEC: * Use the command...')
 
 
第10行: 第10行:
 
<pre><nowiki>
 
<pre><nowiki>
 
if [ ! -e ~/.euca/mykey.priv ]; then
 
if [ ! -e ~/.euca/mykey.priv ]; then
 +
    mkdir -p -m 700 ~/.euca
 
     touch ~/.euca/mykey.priv
 
     touch ~/.euca/mykey.priv
 
     chmod 0600 ~/.euca/mykey.priv
 
     chmod 0600 ~/.euca/mykey.priv
第21行: 第22行:
  
 
<pre><nowiki>
 
<pre><nowiki>
euca-describe-groups    # Work around Bug:452556
 
 
euca-authorize default -P tcp -p 22 -s 0.0.0.0/0
 
euca-authorize default -P tcp -p 22 -s 0.0.0.0/0
 
</nowiki></pre>
 
</nowiki></pre>
第27行: 第27行:
  
 
<pre><nowiki>
 
<pre><nowiki>
euca-run-instances $EMI -k mykey -t c1.medium
+
euca-run-instances $EMI -k mykey -t m1.small
 
</nowiki></pre>
 
</nowiki></pre>
 
{|border="1" cellspacing="0"
 
{|border="1" cellspacing="0"

2010年5月20日 (四) 00:39的最新版本

There are multiple ways to instantiate an image in UEC:

  • Use the command line
  • Use one of the UEC compatible management tools such as Landscape
  • Use the ElasticFox extension to Firefox

Here we will describe the process from the command line:

  1. Before running an instance of your image, you should first create a keypair (ssh key) that you can use to log into your instance as root, once it boots. The key is stored, so you will only have to do this once. Run the following command:
if [ ! -e ~/.euca/mykey.priv ]; then
    mkdir -p -m 700 ~/.euca
    touch ~/.euca/mykey.priv
    chmod 0600 ~/.euca/mykey.priv
    euca-add-keypair mykey > ~/.euca/mykey.priv
fi
Note: You can call your key whatever you like (in this example, the key is called 'mykey'), but remember what it is called. If you forget, you can always run euca-describe-keypairs to get a list of created keys stored in the system.
  1. You must also allow access to port 22 in your instances:
euca-authorize default -P tcp -p 22 -s 0.0.0.0/0
  1. Next, you can create instances of your registered image:
euca-run-instances $EMI -k mykey -t m1.small
Note: If you receive an error regarding image_id, you may find it by viewing Images page or click "How to Run" on the Store page to see the sample command.
  1. The first time you run an instance, the system will be setting up caches for the image from which it will be created. This can often take some time the first time an instance is run given that VM images are usually quite large. To monitor the state of your instance, run:
watch -n5 euca-describe-instances

In the output, you should see information about the instance, including its state. While first-time caching is being performed, the instance's state will be 'pending'.

  1. When the instance is fully started, the above state will become 'running'. Look at the IP address assigned to your instance in the output, then connect to it:
IPADDR=$(euca-describe-instances | grep $EMI | grep running | tail -n1 | awk '{print $4}')
ssh -i ~/.euca/mykey.priv ubuntu@$IPADDR
  1. And when you are done with this instance, exit your SSH connection, then terminate your instance:
INSTANCEID=$(euca-describe-instances | grep $EMI | grep running | tail -n1 | awk '{print $2}')
euca-terminate-instances $INSTANCEID