I have several Neo4j databases which I'm using with one Neo4j server. I'm switching these databases (stop server, copy database to required database path, start server).
Is there any way how to identify which database is currently used? Is there any unique ID in neo4j database which I can use? Because I don't see any identifier in Neo4j API.
Yes, I can create node with label "DatabaseId" and store some unique identifier in this node, but I can't add additional data into existing Neo4j database (my application is not permitted to do any changes in Neo4j database).
Yes, I can analyze data in Neo4j database and create some UUID from these data but data in database can be changed by other application from time to time.
Or is there any "system node" in Neo4j database which I can create and this node is not visible for Cypher? Because this type of change of data is acceptable.
Each Neo4j database maintains a internal storeId. You can access it either via neo4j-shell with the following command:
neo4j-sh (?)$ dbinfo -g Kernel StoreId
{"StoreId": "550503bbc2af134e"}
Other option is to use JMX which exposes the same information.
Related
I was hoping to allow an administrative function in our app where the creation of a new client would mean they get their own database, which I can do and works by simply running a CREATE DATABASE cypher instruction.
Now I am running into two issues when accessing these databases (I'm on neo4j enterprise v4.1.3)
My JDBC driver does not like me prepending queries with USE <database_name(client_name)>. Probably not the biggest deal.
Even when I switch to the neo4j native driver I get this
[Neo.ClientError.Statement.SyntaxError]:Dynamic graph lookup not allowed here. This feature is only available in a Fabric database
Attempted to access graph $1
"USE $1 MATCH (n) RETURN n.name as name"
Again, enabling fabric is not going to kill me but when I looked into how to do this, it seems that each database needs to be upfront declared in the conf file a la this before it can participate in this USE command. Is that right, or is there a way I can just have fabric 'switched on' and after that when I add new databases I can USE them in my queries?
Basically I don't want client on-boarding to require config changes and application releases.
When upgrading from Neo4J 3.3.3 community to enterprise (or even between the versions), I noticed that the users, user roles, and permissions are not transferred.
Is this normal?
Do I have to set up the users manually every time there's an upgrade because they are stored in a separate DB?
In Neo4j 3.x.x, user and authentication data is stored in various directories at NEO4J_HOME/data/dbms, so you need to make sure you copy this over when you perform an upgrade within 3.x.x, and to sync this yourself if you're using a cluster.
In Neo4j 4.x.x, we introduced the concept of the system database to hold user, database, and security data, and this is automatically synced to a cluster. For backup/restore/upgrade you will need to include the system database when you perform these operations.
So we didn't have the concept of a separate database for this before 4.0, it only lived within discrete files.
I am developing a social networking website with Grails and MYSQL DB. But I am planning to move to Neo4j DB. Grails supports complete GORM features with MYSQL. But I am sure about the same features in Neo4j. There is a Grails plugin for Neo4j which does not support some of the features that is required to support big websites. So I am planning to use the native Neo4j API. From Grails how to connect to Neo4j DB? There are two scenarios in my case.
Case 1:
Neo4j server is up and running. How to connect and perform the database transactions?
Case 2:
Neo4j server is not running. How to connect and perform the database transactions? I was able to connect using GraphDatabaseService class. But why would one need to connect to DB which is not running. What is this class GraphDatabaseService particularly used for?
I want to use the native Neo4j API to get access to maximum features. Is there a better approach to build the application.
The Grails Neo4j GORM plugin in version 2.0.0.M01 is able to run embedded mode only - so the JVM running the Grails applications spawns the database inside the same JVM. Next milestone (M02) will add support for accessing Neo4j via REST.
In case you don't want to transparently use the GORM methods to talk to Neo4j you can always use direct access by emitting Cypher statements or accessing GraphDatabaseService directly (only on embedded mode of course).
I have installed neo4j version 1.9.5 and tried some java sample to access / write data into graphdb, but for every action the existing graph db instance is created newly using below,
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("c:/movies/moviesdb"); so is it possible to access and execute cypher query through java on active Neo4j db without REST API concept.
Note : Consider Ne04j DB is already started and running
When running Neo4j as a server process, you communicate with your DB only via REST. The other usage model is embedded. Here you're application code controls the lifecycle of the DB by using new GraphDatabaseFactory().newEmbeddedDatabase(). These two modes are distinct.
It is required to run multiple application on same neo4j db. But when I try to do that, I am meeting a problem about locking.
Neo4j is locking itself when an application is using it. Multiple application can't be run.
The exception is like,
Unable to lock store [/opt/neo4j-lojika-db/neostore.relationshiptypestore.db.names], this is usually a result of some other Neo4j kernel running using the same store
Is there a way to run multiple web application with same embedded neo4j db.
Thank you!
You can't do this way. You have two options
Use Neo4j HA or
Run Neo4j in server mode rather than embedded mode. If your application is simple then you can use the REST api provided by Neo4j out of box. If your service layer is more involved then, put a service layer on top of a single Neo4j embedded instance and let each application talk to Neo4j through this service layer.