【问题标题】:How to delete graph in Titan with Cassandra storage backend?如何使用 Cassandra 存储后端删除 Titan 中的图形?
【发布时间】:2013-10-28 22:29:27
【问题描述】:

我使用 Titan 0.4.0 All,在 Ubuntu 12.04 上以共享 VM 模式运行 Rexster。

如何正确删除 Titan 中使用 Cassandra 存储后端的图表?

我试过TitanCleanup.clear(graph),但它并没有删除所有内容。指数还在。我真正的问题是我有一个我不想要的索引(它使每个查询都崩溃),但是据我了解 Titan 的文档 it is impossible to remove an index once it is created

【问题讨论】:

    标签: cassandra titan tinkerpop rexster


    【解决方案1】:

    对于名为 JanusGraph 的 Titan 的延续,命令是 JanusGraphFactory.clear(graph),但很快就会是 JanusGraphCleanup.clear(graph)

    【讨论】:

      【解决方案2】:

      只是为了更新这个答案。

      使用Titan 1.0.0,这可以通过以下方式在 Java 中以编程方式完成:

      TitanGraph graph = TitanFactory.open(config);
      graph.close();
      TitanCleanup.clear(graph);
      

      【讨论】:

      • 救了我的命唷。
      • 对于新的 Titan JanusGraph,命令是 JanusGraphCleanup.clear() 但很快就会是 JanusGraphCleanup.clear()
      【解决方案3】:

      正如one of the comments to the earlier answer DROPping 一个键空间titan 中提到的那样,使用cqlsh 应该这样做:

      cqlsh> DROP KEYSPACE titan;
      

      Titan 使用的键空间的名称是使用storage.cassandra.keyspace 配置选项设置的。您可以将其更改为您想要的任何名称,并且 Cassandra 可以接受。

      storage.cassandra.keyspace=hello_titan
      

      当 Cassandra 起床时,它会打印出键空间的名称,如下所示:

      INFO 19:50:32 创建新键空间:KSMetaData{name=hello_titan, strategyClass=SimpleStrategy, strategyOptions={replication_factor=1}, cfMetaData={},durableWrites=true, userTypes=org.apache.cassandra.config.UTMetaData@767d6a9f}

      0.9.0-M1中,名称出现在Titan的DEBUG日志中(在conf/log4j-server.properties中设置log4j.rootLogger=DEBUG, stdout):

      [DEBUG] AstyanaxStoreManager - Found keyspace titan
      

      或以下情况:

      [DEBUG] AstyanaxStoreManager - Creating keyspace titan...
      [DEBUG] AstyanaxStoreManager - Created keyspace titan
      

      【讨论】:

        【解决方案4】:

        您可以使用以下命令清除所有边/顶点:

        g.V.remove()
        

        但正如您发现的那样,它不会清除之前创建的类型/索引。最干净的选择是删除 Cassandra 数据目录。

        如果您通过单元测试执行删除,您可以尝试将其作为测试设置的一部分:

        this.config = new BaseConfiguration(){{
            addProperty("storage.backend", "berkeleyje")
            addProperty("storage.directory", "/tmp/titan-schema-test")
        }}
        GraphDatabaseConfiguration graphconfig = new GraphDatabaseConfiguration(config)
        graphconfig.getBackend().clearStorage()
        g = (StandardTitanGraph) TitanFactory.open(config)
        

        请务必在您的测试拆解方法中调用g.shutdown()

        【讨论】:

        • 所以删除 Cassandra 数据目录会完全删除包括我不想要的索引的图表?
        • 是的...包括索引在内的所有数据都存储在 Cassandra 中。我想您也可以在 Cassandra 中删除“泰坦”键空间(无论如何这是默认的键空间名称)。那也行。
        • 我试过这个,但是当我删除数据文件夹时,cassandra(或者可能是 titan/rexster)重新创建文件夹,我仍然得到同样的错误(存在一些我不想要的索引)。我已经尝试删除我可以在机器上找到的每个 cassandra 文件夹,重新启动系统等,但索引仍然存在。有没有办法明确地做到这一点?也许是 cassandra 控制台之类的?
        • 终于让它工作了。我删除了机器上所有同名的文件夹。我怀疑 ubuntu 正在某处或类似的地方缓存该进程。我在嵌入式模式下使用 Titan-rexster,你可以这样做:sudo bin/titan.sh clean 重置数据库。
        • 很高兴你让它工作。应该注意的是,“干净”选项是 0.4.0 中新提供的。在 0.4.0 中,cassandra 并不是真正的“嵌入式”,它只是与 rexster 一起打包,带有一个 titan.sh
        猜你喜欢
        • 2017-04-05
        • 1970-01-01
        • 1970-01-01
        • 2016-09-03
        • 1970-01-01
        • 2016-11-23
        • 1970-01-01
        • 2017-05-31
        • 2016-08-04
        相关资源
        最近更新 更多