如何设置neo4j以使用Google Compute Engine?

时间:2014-11-05 06:57:02

标签: python neo4j google-compute-engine

我想知道如何让neo4j与Google Compute Engine合作。有人这样做过吗?你遇到了什么问题?

2 个答案:

答案 0 :(得分:12)

你走了,

基本设置

GCE的配置

玩耍

  • 启动neo4j服务器./bin/neo4j start
  • 检查正在运行的实例@ http://IP_ADDRESS:7474/

安装py2neo并启动服务器后,尝试使用某个pycode进行测试

>> from py2neo.neo4j import GraphDatabaseService, CypherQuery
>> # Set up a link to the local graph database.
>> # When () left blank defaults to http://localhost:7474/db/data/
>> graph = GraphDatabaseService('http://IP_ADDRESS:7474/db/data/')
>> CypherQuery(graph, "CREATE (n {name:'Example'}) RETURN n;").execute()

以上python设置/代码,您也可以在GAE中使用它。

参考

编辑:Appengine + Neo4j

from py2neo import neo4j
GRAPH_DB = neo4j.GraphDatabaseService(
        'http://uname:psswd@localhost:7474/db/data/')
if IS_PROD:
    GRAPH_DB = neo4j.GraphDatabaseService(
        'http://uname:psswd@host:port/db/data/')

def _execute(query):
    """Execute all neo4j queries and return list of Record objects.

    Returns:
      Returns list of Record objects.
    """
    try:
        result = neo4j.CypherQuery(GRAPH_DB, query).execute()
        # logging.info(result.data)
        return result
    except neo4j.CypherError as error:
        logging.error(error.exception)
    except DeadlineExceededError as dead:
        logging.warn(dead)
    except urlfetch_errors.InternalTransientError as tra_error:
        logging.warn(tra_error)
    except httplib.HTTPException as exp:
        logging.warn(exp)
    except neo4j.http.SocketError as soc:
        logging.warn(soc)

答案 1 :(得分:4)

最简单,最安全的方法是使用docker neo4j image

这是docker docs,用于在谷歌计算引擎上安装和部署