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
最满意答案
首先,解析您的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 ...
-
postgresql导入csv文件(postgresql import csv file)[2022-07-21]
您的表格创建不正确。 例如,此列声明: 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 ...
-
从PostgreSQL创建XML?(Create XML from PostgreSQL?)[2023-04-12]
通过使用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 -
PostgreSQL + Big CSV(PostgreSQL + Big CSV)[2022-11-14]
在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 ...