首页 \ 问答 \ EC2实例在终止状态下启动(EC2 instance launched at terminated state)

EC2实例在终止状态下启动(EC2 instance launched at terminated state)

我第一次使用AWS。 我创建了一个EC2实例。 我选择了“启动配置”作为Ubuntu Server 12.04.1 LTS。

但启动后,国家被“终止”。

以下内容显示在说明中:

State Transition Reason: Server.InternalError: Internal error on launch

它背后的原因是什么?我如何运行实例?


I am using AWS for the first time. I created an EC2 instance. I chose the "Launch Configuration" as Ubuntu Server 12.04.1 LTS.

But after launching it, the state is "terminated".

Following is showed in the description:

State Transition Reason: Server.InternalError: Internal error on launch

What could be the reason behind it and how can i run the instance?


原文:https://stackoverflow.com/questions/17794758
更新时间:2023-07-25 11:07

最满意答案

首先,解析您的xml文件以获取包含您需要的所有信息的文件。

例如,如果您只想拥有一个具有clsid,entryid,semType,baseForm,variant(writeform),variant(type),dc(att),dc(val)属性的表,那么您只需要一个包含这些属性的文件属性(用某些字符分隔)。 文件中的每一行都对应于表中的每一行。

接下来,在Postgresql中创建表模式。 然后使用Postgresql的COPY命令,该命令将所有数据从文件复制到表。

请注意,如果您的xml文件很大,则应使用基于事件的解析器。 像SAX,Java中的StAX之类的东西。

编辑 * 注意 *:使用的库:stax2-api-3.1.1.jar,woodstox-core-asl-4.1.1jar这是代码(希望它能满足您的需求,如果不是,我相信它可以让您入门):

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.net.MalformedURLException;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import java.util.ArrayList;
import org.codehaus.stax2.XMLInputFactory2;
import org.codehaus.stax2.XMLStreamReader2;

public class Main {

    /**
     * @param args the command line arguments
     */

    /*
     * dc(att), dc(val)
     */
    @SuppressWarnings("CallToThreadDumpStack")
    public static void main(String[] args) throws MalformedURLException, IOException, XMLStreamException {
        FileInputStream fstream = new FileInputStream(args[0]);
        Reader in = new InputStreamReader(fstream, "UTF-8");
        XMLInputFactory2 factory = (XMLInputFactory2) XMLInputFactory.newInstance();
        XMLStreamReader2 parser = (XMLStreamReader2) factory.createXMLStreamReader(in);

        FileOutputStream outStream = new FileOutputStream("/home/aseke/Desktop/out.txt");
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outStream, "UTF-8"));


        boolean isCluster = false;
        ArrayList<String> dc = new ArrayList<String>();
        ArrayList<String> variants = new ArrayList<String>();

        /* You actually do not need all of these variables, it's just for clarity */
        String clsID = null;
        String semType = null;
        String varWritten = null;
        String varType = null;
        String entryID = null;
        String baseForm = null;
        String dcAtt = null;
        String dcVal = null;
        String s = null;
        while (true) {
            int event = parser.next();
            if (event == XMLStreamConstants.END_DOCUMENT) {
                parser.close();
                break;
            }

            if (event == XMLStreamConstants.START_ELEMENT) {
                String tag = parser.getLocalName();

                if (tag.equals("Cluster")) {
                    isCluster = true;
                    clsID = parser.getAttributeValue(0);
                    semType = parser.getAttributeValue(1);
                } else if (tag.equals("Entry") && isCluster) {
                    entryID = parser.getAttributeValue(0);
                    baseForm = parser.getAttributeValue(1);
                } else if (tag.equals("Variant") && isCluster) {

                    varWritten = parser.getAttributeValue(0);
                    varType = parser.getAttributeValue(1);

                    variants.add(varWritten + "~" + varType);
                } else if (tag.equals("DC") && isCluster) {
                    dcAtt = parser.getAttributeValue(0);
                    dcVal = parser.getAttributeValue(1);

                    dc.add(dcAtt + "~" + dcVal);
                }
            }

            if (event == XMLStreamConstants.END_ELEMENT && isCluster) {
                if (parser.getLocalName().equals("Cluster")) {
                    isCluster = false;
                    //clsid, entryid, semType, baseForm, variant(writtenform), variant(type), dc(att), dc(val)
                    // Use tabs as delimiter for Postgre COPY
                    String outStr = clsID + "/t" + entryID + "/t" + semType + "/t" + baseForm + "/t";

                    /* Add all variants */
                    for (String var : variants) {
                        String tmp[] = var.split("~");
                        varWritten = tmp[0];
                        varType = tmp[1];
                        outStr += varWritten + "/t" + varType + "/t";
                    }
                    /* Add al DCs */
                    for (String ss : dc) {
                        String[] tmp = ss.split("~");
                        dcAtt = tmp[0];
                        dcVal = tmp[1];
                        outStr += dcAtt + "/t" + dcVal + "/t";
                    }
                    // remove last tab "\t"
                    outStr = outStr.substring(0, outStr.length() - 2);
                    out.write(outStr);
                    variants.clear();
                    dc.clear();

                }
            }
        }

        // close all streams
        fstream.close();
        out.close();
        outStream.close();
    }
}

我格式化你输入xml 。 所以输入文件如下所示:

<Cluster clsId="UNIPR_NIRI_PARDP" semType="geneProt">
    <Entry entryId="UNIPR_NIRI_PARDP_1" baseForm="Protein nirI" type="PREFERRED">
        <Variant WRITTENFORM="FMN-binding domain protein" type="orthographic"/>
        <Variant WRITTENFORM="FMN-binding domain-containing protein" type="orthographic"/>
        <Variant WRITTENFORM="unknown" type="orthographic"/>
        <Variant WRITTENFORM="FMN-binding" type="orthographic"/>
        <Variant WRITTENFORM="Pden_2486" type="orthographic"/>
        <Variant WRITTENFORM="nirI" type="orthographic"/>
        <SourceDC sourceName="BioThesaurus" sourceId="Q51699"/>
        <PosDC posName="POS" pos="N"/>
        <DC att="uniprot_ac" val="Q51699"/>
        <DC att="speciesNameNCBI" val="318586"/>
    </Entry>
</Cluster>

输出看起来像这样 。 请注意,它使用制表符分隔。 选项卡稍后将用作Postgre COPY命令中的分隔符。 您可以将分隔符更改为任何其他分隔符。

UNIPR_NIRI_PARDP/tUNIPR_NIRI_PARDP_1/tgeneProt/tProtein nirI/tFMN-binding domain protein/torthographic/tFMN-binding domain-containing protein/torthographic/tunknown/torthographic/tFMN-binding/torthographic/tPden_2486/torthographic/tnirI/torthographic/tuniprot_ac/tQ51699/tspeciesNameNCBI/t318586

I did this using Ruby with help of packages noko-giri and open-uri. As, my input file is so large in size. Many of the parser got failed and noko-giri helped in this.

I provided the answer with three columns, baseForm-variant(writtenform)-dc(val). This information may be a crisp information for the question.

require 'nokogiri'
require 'open-uri'

doc = Nokogiri::XML(File.open("xai"))
ent = doc.xpath("//Entry")

value = String.new
ent.each do |e| 
    d = e.xpath("DC")   
    d.each do |f|       
        if f.attributes["att"].to_s =~ /uniprot_ac/
            value = f.attributes["val"].to_s
        end
    end
    f = e.xpath("Variant")  
    f.each do |g|
        puts "#{e.attributes["baseForm"].to_s}\t" + "#{g.attributes["WRITTENFORM"].to_s}\t" + "#{value}"
    end 
end

相关问答

更多
  • 正如PostgreSQL文档中所述( II。PostgreSQL客户端应用程序 - psql ),您可以使用switch -c命令将命令传递给psql : psql -c "COPY tbname FROM '/tmp/the_file.csv' delimiter '|' csv;" As stated in The PostgreSQL Documentation (II. PostgreSQL Client Applications - psql) you can pass a command to ...
  • Postgres(感谢Daniel Lyons指出)可以用来存储你的表的原生XML支持 。 如果您不想手动碎化您的XML数据,则有不同的可能性来在数据库中表示XML数据。 第一个问题应该是,如果您想要一个非常通用的解决方案,那么它将能够存储任何XML文档或特定于您的域的文档(即仅允许特定结构的XML文档)。 根据这一点,您将拥有一个非常灵活的通用表示,然而这很难查询(所需的SQL将非常复杂)。 如果您有更具体的方法,查询将会更简单,但是您每次需要存储其他类型的文档或将字段添加到现有文档时,都需要创建新表或为 ...
  • 首先,解析您的xml文件以获取包含您需要的所有信息的文件。 例如,如果您只想拥有一个具有clsid,entryid,semType,baseForm,variant(writeform),variant(type),dc(att),dc(val)属性的表,那么您只需要一个包含这些属性的文件属性(用某些字符分隔)。 文件中的每一行都对应于表中的每一行。 接下来,在Postgresql中创建表模式。 然后使用Postgresql的COPY命令,该命令将所有数据从文件复制到表。 请注意,如果您的xml文件很大,则 ...
  • 我会尝试一种不同的方法:将XML文件直接读入plpgsql函数中的变量,然后从那里继续。 应该快得多,并且更加健壮。 不过,您需要超级用户权限。 CREATE OR REPLACE FUNCTION f_sync_from_xml() RETURNS boolean AS $BODY$ DECLARE myxml xml; datafile text := 'path/to/my_file.xml'; BEGIN myxml := pg_read_file(datafile, 0 ...
  • 您的表格创建不正确。 例如,此列声明: country_code character varying(10)[] NOT NULL, 正在创建一个varchar(10)数组。 你只想要一个。 删除那些列上的[] 。 此外,您发布的示例数据实际上不是以逗号分隔,但我假设实际的数据文件是。 Your table is created incorrectly. For example, this column declaration: country_code character varying(10)[] N ...
  • INSERT INTO actualstatuses( SELECT (xpath('//ActualStatus/@ACTSTATID', myTempTable))[1]::text::bigint AS ACTSTATID, (xpath('//ActualStatus/@NAME', myTempTable))[1]::text AS NAME FROM unnest(xpath('//ActualStatus', replace(co ...
  • 通过使用XML函数: http://www.postgresql.org/docs/current/static/functions-xml.html#AEN15086 By using the XML functions: http://www.postgresql.org/docs/current/static/functions-xml.html#AEN15086
  • 在PHP中,您可以将函数pg_put_line与COPY tablename FROM STDIN结合使用。 我不知道性能,但它比许多INSERT语句更快。 也许它适合你。 In PHP you could use the function pg_put_line in combination with COPY tablename FROM STDIN. I have no idea about performance, but it is faster than many INSERT-statemen ...
  • 解释临时表方法,这是我自己使用的方法: 创建一个与csv结构匹配的表(可以是临时表) 导入到该表中,不进行过滤 使用SQL处理和导入数据到真实表中以进行过滤和处理。 现在,在PostgreSQL中,您还可以使用file_fdw为您提供对csv文件的直接sql访问。 通常,临时表解决方案通常更干净,但您可以通过实质上让PostgreSQL将文件视为表并通过外部数据包装器来实现。 To explain the staging table approach, which is what I use myself: ...
  • 不,PostgreSQL不会读取XLS文件格式(也不是XLSX格式)。 您可以从CSV导入,在某些情况下可以从XML导入,但全部(无需外部预处理)。 但是,如果您实际上有权访问Excel,则始终可以直接从Excel内部以开放格式(最好是CSV)导出它。 No, PostgreSQL does not read the XLS file format (nor the XLSX format). You can import from CSV, and in some cases from XML, but ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。