栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

您如何设置neo4j与Google Compute Engine一起使用?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

您如何设置neo4j与Google Compute Engine一起使用?

干得好,

基本设定

  • 安装和设置
    gcloud
  • 安装py2neo
  • 使用映像(debian-7-wheezy-v20141021,D​​ebian GNU / Linux 7.7(hehey)amd64建立于2014-10)创建您的GCE实例(https://console.developers.google.com/project/PROJECT_APPID/compute/instancesAdd) -21或任何)
  • SSH您的实例
    gcloud compute ssh INSTANCE_NAME --zone AVAILABLE_ZONES
    -> AVAILABLE_ZONES
  • neo4j
    在GCE中下载并安装-您可能需要安装java(Fix)和lsof(Fix:)
    apt-get install lsof

GCE的配置

  • 配置服务器neo4j

  • (可选),添加neo4j https支持

  • 将neo4j端口7474列入白名单(有关网络和防火墙的更多信息)

  • 从github添加安全 用户名:password

gcloud compute firewall-rules create neo4j --network default --allowtcp:7474

玩耍

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

一旦
py2neo
安装并启动服务器,尝试一些pypre测试它

>> 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中使用它。

参考文献

  • 检查GCE的定价。
  • py2neo食谱
  • 计算实例
  • gcloud计算

编辑:Appengine + Neo4j

from py2neo import neo4jGRAPH_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)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/662656.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号