[neo4j: 2.1.3, Windows 7 64 bit, Java 7]
I want to be able to connect to the embedded neo4j database in java, using the neo4j shell.
As suggested here adding the property remote_shell_enabled="true" should do that.
I tried as suggested but my shell is not able to connect to the db with error
Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock
on store lock file:
~\store_lock. Please ensure no
other process is using this database, and that the directory is
writable (required even for read-only access)
at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:82)
I set the property as follows in my code
graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DBPATH).setConfig("remote_shell_enabled","true").newGraphDatabase();
Also, doing this results in the database not shutting down through the shutdown hook. Instead the process does not end, seemingly the shutdown hook is never executed.
If however I use the below to start the property the shutdown hook is executed successfully everytime.
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DBPATH);
or
graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DBPATH).newGraphDatabase();
Is there some other way to enable the shell access to the embedded database.
In order to open the neo4j-shell server at e.g. port 5000, start the database with something like
new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DB_DIR)
.setConfig(ShellSettings.remote_shell_enabled, "true")
.setConfig(ShellSettings.remote_shell_port, "5000")
.newGraphDatabase();
and the connect to it using
neo4j-shell -port 5000
Does that work?
Related
I have a successful import using the bin/neo4j-admin tool, can see the new database folder in my /databases, have restarted the server, but cannot get the database to appear in the console as an option to switch to. Do you have any suggestions for getting a newly imported database to be available in the console?
I assume that you are referring to the Neo4j Desktop environment.
The Desktop currently seems to be designed to support local DBs created by the Desktop itself.
As a workaround, you can:
Create a new "Graph" in the Desktop, using the "Connect to Remote Graph" option.
Accept the default "bolt://localhost:7687" as the Connect URL (assuming the default is acceptable).
Manually start your local neo4j installation from the command line, and
Click Connect on your "Graph" to connect.
Be aware that the Desktop has fewer bells and whistles for "remote
graphs".
I resolved the issue. The steps I found to successfully import a set of CSV using the admin -import tool is to:
Stop the server
Run the admin -import tool and use --database=aDatabaseName
Start the server
In the console switch to the System database using the pulldown control
Run the following command at the system prompt: create database aDatabaseName
(should be the same name set in #2 above)
Switch to the database just created using the console pulldown control
I was able to see the database nodes and relationships I created following the above steps
This is what worked for me. I was trying to access my database generated through neo4j-admin on my Neo4j Desktop app browser console.
On Neo4j Desktop App open the browser of the database server you want to include the new database
Switch to the system database https://neo4j.com/developer/manage-multiple-databases/
:use system
as system, create the database you want to import
:create database dbname
Stop the server
Use the neo4-admin tool to import the database https://neo4j.com/graphacademy/online-training/v4/19-using-neo4j-admin-tool-import/ (make sure to use the same name --database dbname). Run these command on the terminal opened from the Desktop app under the databases>_Open Terminal. On windows the neo4j-admin.bat is located in the bin directory
start the server and open the neo4j browser and switch to the system database https://neo4j.com/developer/manage-multiple-databases/
:use system
To list all the database available to use as system
:dbs
switch to your imported database
:use dbmame
Your browser console is ready now for your queries.
Current it seems we cannot run both Neo4J Server and Gremlin Server at the same time. Is there any way to have run both?
NEO4J is running and I try to start to Gremlin Server then I get the following error
java.lang.RuntimeException: GraphFactory could not instantiate this
Graph implementation [class
org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph].......................(truncated)
Gremlin Server is running and I try to start NEO4J Server then I get the following error
Caused by: org.neo4j.kernel.StoreLockException: Store and its lock
file has been locked by another process:
/home/galaxia/Documents/neo4j-gremlin/data/databases/graph.db/store_lock.
Please ensure no other process is using this database, and that the
directory is writable (required even for read-only access)
Versions
Neo4J 3.3.1
Gremlin 3.3.1
I realize it has been a while, but I finally figured this out and thought others should know. As Stephen Mallette said, you can use the Bolt implementation. To configure this for Gremlin Server, use the included gremlin-server-neo4j.yaml file and make the following change:
graphs: {
graph: conf/neo4j-bolt.properties}
Then create the neo4j-bolt.properties file with this content:
gremlin.graph=com.steelbridgelabs.oss.neo4j.structure.Neo4JGraph
#neo4j.graph.name=graph.db
neo4j.identifier=dummy
neo4j.url=bolt://localhost:7687
neo4j.username=neo4j
neo4j.password=<password>
neo4j.readonly=false
neo4j.vertexIdProvider=com.steelbridgelabs.oss.neo4j.structure.providers.Neo4JNativeElementIdProvider
neo4j.edgeIdProvider=com.steelbridgelabs.oss.neo4j.structure.providers.Neo4JNativeElementIdProvider
Remember to replace the password, and any other property with the correct values.
You cannot run them together that way (i.e. embedded mode), but it should be possible to run them together, if you either:
Configure the Neo4j graph in Gremlin Server to use HA mode as described here
Configure the Neo4j graph in Gremlin Server to use the Bolt implementation found here
Enable the Bolt protocol in the Neo4j properties file provided to Gremlin Server.
As an example of the third option, given the default Gremlin Server packaged configuration files for Neo4j, you can edit conf/neo4j-empty.properties to include:
gremlin.graph=org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph
gremlin.neo4j.directory=/tmp/neo4j
gremlin.neo4j.conf.dbms.connector.0.type=BOLT
gremlin.neo4j.conf.dbms.connector.0.enabled=true
gremlin.neo4j.conf.dbms.connector.0.address=localhost:7687
and then start Gremlin Server with bin/gremlin-server.sh conf/gremlin-server-neo4j.yaml at which point you can use standard TinkerPop drivers as well as standard Bolt connectivity against the same graph instance.
With neo4j 2.3.x community edition I use to set the ip address to local host and change the port to allow multiple instances for development.
#org.neo4j.server.webserver.address=0.0.0.0
org.neo4j.server.webserver.port=7384
Upon starting the instance, I use to have a confirmation message with ip and port.
Starting Neo4j Server...WARNING: not changing user
process [28531]... waiting for server to be ready........ OK.
http://localhost:7384/ is ready.
I would then upload data using a shell script and cypher commands.
$neo/bin/neo4j-shell -path $neo/data/graph.db -file upload.cypher
With neo4j 3.0, the server setup slightly changed. I turned on HTTP connection, CSV import, and shell connection.
dbms.connector.http.enabled=true
dbms.connector.http.address=localhost:7384
dbms.shell.enabled=true
# dbms.shell.host=127.0.0.1
dbms.shell.port=1387
When I start the instance, I get the following message in which the port is not correct.
Starting Neo4j.
Started neo4j (pid 28718). By default, it is available at http://localhost:7474/
There may be a short delay until the server is ready.
Uploading data with the same shell script as for neo4j-2.3.x works well, no error message and I can see the data using neo4j-shell.
./neo4j-3.0.0/bin/neo4j-shell -path neo4j-3.0.0/data/graph.db
However, when I connect using host and port instead, I see no data. Furthermore, when I connect using the web interface, I see no data either.
./neo4j-3.0.0/bin/neo4j-shell -host localhost -port 1387
Is there anything wrong in my database setup?
Thanks!
In 3.0 the location of the datastore has changed. 2.x used data/graph.db, in 3.0 it's by default in data/databases/graph.db. So you want to change your setup script to:
./neo4j-3.0.0/bin/neo4j-shell -path neo4j-3.0.0/data/databases/graph.db
I just installed the latest version of Neo4J on ubuntu 15.04 and on my application code I have provided the path for the database as the following :
GraphDatabaseService db = dbFactory.newEmbeddedDatabase("/home/aimad/Documents/Neo4j/default.graphdb");
When I type match(n) return n; on console of http://localhost:7474 I cant see any graph.
And I notice that the location of the database is : /home/aimad/neo4j-community-2.3.0/data/graph.db on the Neo4j plateform.
I also tried to change the location of the database in conf/neo4j-server.properties but I got this error message when I want to start neo4j :
Starting Neo4j Server...WARNING: not changing user process [3151]...
waiting for server to be ready... Failed to start within 120 seconds.
Neo4j Server may have failed to start, please check the logs.
How can I solve this problem ?
As #AllessandroNegro indicated, you cannot start a neo4j server on the same DB that is already opened by an embedded app.
If you want to visualize the DB used by your embedded app, this other question might be helpful.
I have a Neo4j server running on my machine and access the database via the webadmin interface. Then I run a java application which writes data to the database using the Java API and exists afterwards.
If I then try to see the new data in the webadmin, I have to restart the Neo4j server (refreshing doesn't help).
How can I refresh the webadmin without having to restart the server?