How do you set up neo4j to work with Google Compute Engine?

旧时模样 提交于 2019-12-30 03:41:09

问题


I'm wondering how one would get neo4j to work with Google Compute Engine. Has anybody done this? What problems did you encounter?


回答1:


Here you go,

Basic Setup

  • Install and setup gcloud
  • Install py2neo
  • Create your GCE Instance (https://console.developers.google.com/project/PROJECT_APPID/compute/instancesAdd) using image (debian-7-wheezy-v20141021, Debian GNU/Linux 7.7 (wheezy) amd64 built on 2014-10-21 or ANY)
  • SSH your instance gcloud compute ssh INSTANCE_NAME --zone AVAILABLE_ZONES --> AVAILABLE_ZONES
  • Download and Install neo4j in GCE - You may need to install java(Fix) and lsof (Fix: apt-get install lsof).

Configuration for GCE

  • Configure server neo4j
  • (Optional), Add neo4j https support
  • Whitelist neo4j port 7474 (More on Networking and Firewalls)
  • Add security username:password from github

    gcloud compute firewall-rules create neo4j --network default --allow tcp:7474

Play around

  • Start neo4j server ./bin/neo4j start
  • Check your running instances @ http://IP_ADDRESS:7474/

Once py2neo Installed and server started, try some pycode to test it

>> 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()

Above python setup / code, you can use it in GAE as well.

References

  • Check pricing of GCE.
  • py2neo Cookbook
  • Compute Instances
  • gcloud compute

Edit: 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)



回答2:


the easiest and the safest way is to use docker neo4j image

and this is docker docs, to install and deploy on google compute engine



来源:https://stackoverflow.com/questions/26751346/how-do-you-set-up-neo4j-to-work-with-google-compute-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!