Neo4j HA environment configuration
Neo4j as a graph database, the origin of its name is actually related to the way it is stored at the bottom. The bottom layer of Neo4j will store user-defined nodes and relationships in a graph. In this way, efficient implementation starts from a node and finds out the relationship between the two nodes through the relationship between nodes.
Neo4j is commonly used in the following usage scenarios:
Social Network
Graph-based search
Recommendation engine
Enterprise Infrastructure and Network Architectur
Such as: Tianyan check the relationship between the enterprises of the website and so on.
This article focuses on the deployment of the HA environment, simulating three nodes on a single server. The actual production environment can be deployed separately on different servers, and the configuration file can be modified according to different IP and ports.
1 、 Java environment [root@appcan-t-app-7 ~] # more / etc/profileexport JAVA_HOME=/usr/local/jdk1.8.0_60export JRE_HOME=$ {JAVA_HOME} / jreexport CLASSPATH=.:$ {JAVA_HOME} / lib:$ {JRE_HOME} / libexport PATH=$ {JAVA_HOME} / bin:$PATH [root@appcan-t-app-7 ~] # java-versionjava version "1.8.0 October 60" Java (TM) SE Runtime Environment (build 1.8.0_60-b27 ) Java HotSpot (TM) 64-Bit Server VM (build 25.60-b23 Mixed mode) 2. Download the community version of wget https://neo4j.com/artifact.php?name=neo4j-community-3.4.9-unix.tar.gz (current latest version) You can go to the website to choose the applicable version) 3. Install tar xf neo4j-community-3.4.9-unix.tar.gz-C / usr/local/cd / usr/local/neo4j-community-3.4.9-unix/./bin/neo4j-installer installsystemctl status neo4j-service4, HA configuration:
Complete the HA configuration by modifying the conf/neo4j.properties and conf/neo4j-server.properties files.
Node01: (1) conf/neo4j.properties:##ha.server_id = 1ha.server = 127.0.0.1:6363online_backup_server = 127.0.0.1:6366ha.cluster_server = 127.0.0.1:5001ha.initial_hosts = 127.0.0.1 * (2) conf/neo4j-server.properties##org.neo4j.server.database Location=data/graph.dborg.neo4j.server.webserver.port=7474org.neo4j.server.webserver.address=0.0.0.0org.neo4j.server.webserver.https.port=7484org.neo4j.server.database.mode=HANode02: (1) conf/neo4j.properties:##ha.server_id = 2ha.server = 127.0.0.1:6364online_backup_server = 127.0.0.1:6367ha.cluster_server = 127.0.0.1:5002ha.initial_hosts = 127.0.0.1 .0.1: 5002127.0.0.1 purl 5003 * * (2) conf/neo4j-server.properties##org.neo4j.server.database.location=data/graph.dborg.neo4j.server.webserver.port=7475org.neo4j.server.webserver.address=0.0.0.0org.neo4j.server.webserver.https.port=7485org.neo4j.server.database.mode=HANode03: (1) conf/neo4j.properties:##ha.server_id = 3ha.server = 127.0.0.1:6365online _ backup_server = 127.0.0.1:6368ha.cluster_server = 127.0.0.1:5003ha.initial_hosts = 127.0.0.1virtual 5001127.0.0.1virtual 5002127.0.0.1 * (2) conf/neo4j-server.properties##org.neo4j.server.database.location=data/graph.dborg.neo4j.server.webserver.port=7476org.neo4j.server.webserver.address=0.0.0.0org.neo4j.server. Webserver.https.port=7486org.neo4j.server.database.mode=HA
Start in turn:
. / bin/neo4j start
Detect:
# jps
17131 CommunityBootstrapper
17324 CommunityBootstrapper
16959 CommunityBootstrapper
5. WEB interface
WEB interface display:
6. Basic Cypher operations [add, delete, modify and query] (1) insert node:
Insert a node of the Person category, and the node has an attribute name with a value of Andres
CREATE (n:Person {name: 'Andres'}); (2) insert edges:
Insert a directed edge from a to b, and the edge category is Follow
MATCH (a:Person), (b:Person) WHERE a.name = 'Node A' AND b.name = 'Node B'CREATE (a)-[r:Follow]-> (b); (3) Update the node:
Update a node of the Person category and set the new name.
MATCH (n:Person {name: 'Andres'}) SET n.name =' Taylor'; (4) Delete the node and the edges connected to it:
In Neo4j, if a node is connected by an edge, it cannot be deleted alone.
MATCH (n:Person {name:'Andres'}) DETACH DELETE n; (5) Delete edge: MATCH (a:Person)-[r:Follow]-> (b:Person) WHERE a.name = 'Andres' AND b.name =' Taylor'DELETE r; (6) query statement:
Shortest path:
MATCH (ms:Person {name:'Andres'}), (cs:Person {name:'Taylor'}), p = shortestPath ((ms)-[r:Follow]-(cs)) RETURN p
Query the relationship between two nodes:
MATCH (a:Person {name:'Andres'})-[r]-> (b:Person {name:'Taylor'}) RETURN type (r)
Query all Follower of a node:
MATCH (: Person {name:'Taylor'})-[r:Follow]-> (Person) RETURN Person.name; (7) create Neo4j database
Create a uniqueness constraint with an indexing effect similar to the primary key in a relational database. Note that this can only be set when no data has been inserted into the database.
CREATE CONSTRAINT ON (a:Person) ASSERT a.name IS UNIQUE
Create an index:
CREATE INDEX ON: Person (name)
View all the number of nodes and edges:
MATCH (n) RETURN count (n); MATCH ()-- > () RETURN count (*); reference:
1. Https://www.cnblogs.com/valleylord/p/3676607.html
2. Http://www.cnblogs.com/rubinorth/p/5853204.html
3. Https://neo4j.com/docs/2.0.2/ha-setup-tutorial.html