How to remove neo4j COMPLETE? - neo4j

Installing neo4j at arch with yay -S neo4j-community and starting with systemctl start neo4j I open http://localhost:7474/browser/ and execute the demo command create database movies but I get the error
Neo.ClientError.Statement.NotSystemDatabaseError
Unsupported administration command: CREATE DATABASE movies
because of desperation I tried to remove neo4j completely but he still "remembers" my initial password and also still has a reference to graph.db that I have removed manually in the menubar.
Where are the files neo4j stores and does someone have idea to fix the problem with the database creation?

Related

Neo4j - unable to get routing for database neo4j - unavailable after system upgrade

I have been running a neo4j database for a while without problem.
Yesterday our server OS was update from centos-8 to centos-stream, and since this upgrade our neo4j database does not start anymore.
The service is listed as running but on every query it says: Unable to get a routing table for database 'neo4j' because this database is unavailable.
I cannot log in to the cypher shell because it shuts down with the same error.
I'm not sure what I can do here, I would like to not reset the database as we need the information in there.
The versions I'm running are as follows:
neo4j-4.3.6-1.noarch
neo4j-java11-adapter-1-1.noarch
I had similar issue, so I checked the logs and found the below error in the logs.
Caused by: java.nio.file.AccessDeniedException:
/var/lib/neo4j/data/databases/neo4j/neostore
The fix for the above issue is to change the ownership of noe4j databases folders and files.
cd /var/lib/neo4j/data
sudo chown -R neo4j:neo4j databases/
sudo chown -R neo4j:neo4j transactions/
Restart the neo4j service
sudo systemctl restart neo4j.service

ThingsBoard installation failed! On Ubuntu

I am trying to install thingsboard PE instance on Ubuntu 18.04.3 LTS
while I run this command
sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
I am facing the following error
Error: Could not find or load main class org.springframework.boot.loader.PropertiesLauncher
ThingsBoard installation failed!
the thingsboard.log file is not present in /var/log/thingsboard
Can anyone please suggest me what's the reason for this error?
Make sure the thingsboard database does actually exist. I had the same error. I did follow the instructions, but possibly the CREATE DATABASE was not followed by ';' or it needed to be started.
Restart the ubuntu server.
Log in and log onto PSQL: psql -U postgres -d postgres -h 127.0.0.1 -W
Check for existence of the database: \list
If it does not exists, run: CREATE DATABASE thingsboard;
Run \list again and make sure it exists. Quit by running \q.
Re-run the demo create script: sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
Happy Thing-ing.
Along with the above as Antony Horne has suggested, also you can remove the ThingsBoard related directories under /tmp/. Remove and recreate the 'thingsboard' database. Make sure to set the password as 'postgres'. Then re-run the command
/usr/share/thingsboard/bin/install/install.sh --loadDemo
It should be fine.
Though after that, when I tried to run the 'thingsboard' as
service thingsboard start
Its is not working as 'thingsboard' is unrecognized. Couldn't solve that yet.

How to create new database in neo4j?

I'm using Linux 16.04 OS. I have installed fresh neo4j. I get referenced exegetic and digitalocean sites.
By default there's graph.db database.
My question is how to create a new database and create nodes and
relation ship between nodes?
As I show in picture default DB name is graph.db.
Since you're using Neo 3.x, to create a new database without removing your existing one, you can simply edit the neo4j.conf file in your conf directory of your $NEO4J_HOME.
Search for dbms.active_database=, which should have the default value of graph.db. Replace it with some other name and start neo4j again. Now, a new database will be created under that directory name. To switch back to your previous db, repeat the steps, just replace your new value with graph.db in the configuration file.
Neo Technology has come with a new Desktop Tool that greatly improves productivity called Neo4J Desktop. You can download it here
Using it you can manage different projects, create different databases, and simply manage them / switch between them, using the GUI.
Really saves a lot of time.
Apparently in Community Edition you only have 1 database, so I used docker containers to create one server per db. Modify the ports + data volume as shown below:
docker run \
--rm \
--publish=8474:7474 --publish=8687:7687 \
--volume=$HOME/neo4j/data2:/data \
--volume=$HOME/Downloads/neo4j/import:/var/lib/neo4j/import \
--name=neo4j \
--env NEO4J_AUTH=neo4j/password \
neo4j:3.4
# Defaults:
# --publish=7474:7474 --publish=7687:7687 \
# --volume=$HOME/neo4j/data:/data \
In the documentation of Neo4j
Community Edition is a fully functional edition of Neo4j, suitable for
single instance deployments. It has full support for key Neo4j
features, such as ACID compliance, Cypher, and programming APIs. It is
ideal for learning Neo4j, for do-it-yourself projects, and for
applications in small workgroups.
So you only have one database instance.
If you want to get started with Neo4j there is a section in the community edition called "jump into code." There is a wizard to tell you how to get started with their language "Cypher."
To create a new Neo4j database in Unix Environment, the following steps are needed:
first, the configuration file of neo4j exists in the following location:
cd /etc/neo4j (ls ---> neo4j.config);
access the file using vim: sudo vim neo4j.config;
edit the following (by pressing i (for insert)):
there is a commented assignment (at the beginning) which is:
#dbms.active_database=graph.db; remove the comment and add the name of the folder containing the database that you want to create and directly add its location before graph.db
i.e: dbms.active_database=new_db/graph.db; press: Esc + :wq (to save the modification)
After executing sudo service neo4j start, you will see that the activated database is new_db/graph.db
if you want to check that everything went fine, follow these steps:
go to: cd /var/lib/neo4j;
execute: ls (you will have certificates, plugins, data, import); then go to: cd data/databases; then execute ls :you will notice that you have the old database (graph.db), and the new folder new_db that contains also the new_created database graph.db
Remarks:
Neo4j is developed for single database use, and all the manipulations are performed on a single database.
If you want to clear the database, you can go to the location of graph.db and erase everything since doing that from neo4j is very difficult and most of times, you will forget to delete dependencies, labels, ...
i.e : say, we want to clear the new created database graph.db that exists in the folder new_db:
we go to : cd ..../new_db;
execute ls (you will have graph.db);
execute: sudo rm -rf graph.db/*;
Last remark, if you want to access the default database, you just recomment the assignment that you edited
The process is a little tricky in case of causal cluster.
First, stop all the neo4j instances across the VMs in your cluster
sudo systemctl stop neo4j
DB location on Linux machines = /var/lib/neo4j/data/databases
To delete existing db : rm -rf /database/graph.db
Edit new DB name under the template
Search for dbms.active_database=, which should have the default value of graph.db . Replace it with a new DB. On the restart, neo4j will automatically create it.
Remember to UNCOMMENT the line.
Unbind all the nodes — this clears the cluster state and forces the node to freshly join the cluster.
neo4j-admin unbind
Now, this is really important and most people are unaware of this.
Now go ahead and start neo4j instances in all the nodes one by one. This should create new DBs across and you’ll see the nodes joining the cluster.
sudo systemctl start neo4j
Check logs using
journalctl -unit=neo4j -r
OR
sudo systemctl status neo4j

neo4j-shell example of running a Cypher script

I need to run a Cypher query against a Neo4J database, from a command line (for batch scheduling purposes).
When I run this:
./neo4j-shell -file /usr/share/neo4j/scripts/query.cypher -path /usr/share/neo4j/neo4j-community-3.1.1/data/databases/graph.db
I get this error:
ERROR (-v for expanded information):
Error starting org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory, /usr/share/neo4j/neo4j-community-3.1.1/data/databases/graph.db
There is a running Neo4J instance on that database (localhost:7474). I need the script to perform queries against it.
NOTE: this is a split of the original question, for the sake of tidiness.
To execute (one or more) Cypher statements from a file while the neo4j server is running, you can use the APOC procedure apoc.cypher.runFile(file or url).
Since you mention "batch scheduling", the Job management and periodic execution APOC procedures may be helpful. Those procedures could, in turn, execute calls to apoc.cypher.runFile.
Okay I just spun up a fresh instance of Neo4j-community-3.1.1 today and ran into the exact same problem. Note that I had already created a database using the bulk import tool, so one might need to make a directory for a database (mkdir data/databases/graph.db) before using a shell.
I believe your problem might be that you have an instance of Neo4j process running against the database you are trying to access.
For me, shutting down Neo4j, and then starting the shell with an explicit path worked:
cd /path/to/neo4j-community-3.1.1/
bin/neo4j stop ## assuming it is already running (may need a port specifier)
bin/neo4j-shell -path data/databases/graph.db
For some reason I thought you could have both the shell and the server running, but apparently that is not the case. Hopefully someone will correct me if I am wrong.

Could not connect to a primary node for replica set <Moped::Cluster nodes=[<Moped::Node resolved_address="127.0.0.1:27017">]>

I'm following though with the RailsApp tutorial with Devise and Mongoid (http://railsapps.github.io/tutorial-rails-mongoid-devise.html) and am encountering the following error when I get to 'Rake db:seed' down at the 'Set Up a Database Seed File' section.
Could not connect to a primary node for replica set <Moped::Cluster nodes=[<Moped::Node resolved_address="127.0.0.1:27017">]>
I've tried the instructions from nixoncd on this page here but has not fixed the issue. It tells me 'file exists' and 'Already loaded'. 'https://groups.google.com/forum/#!topic/mongodb-user/Hhh8iNCciMk
I get this if I type 'mongod' in terminal.
ERROR: could not read from config file
Any help welcome. I'm on a Mac OSX Mountain Lion with Mongoid installed using homebrew - though MongoDB was installed using the download package mongodb.org.
MongoDB shell version: 2.4.6
Thanks
EDIT: I'm not sure if this issue is related or not. Also having issues launching mongoDB. Also posted issue here:
mongoDB, could not read from config file -- config in different folder / Uninstall it?
First See if your database is running by mongo , If yes
Use this command:
sudo rm /var/lib/mongodb/mongod.lock
mongod --repair
sudo service mongodb start
Your database will work.
Installing MongoDB solved this for me:
sudo apt-get install mongodb-server
The answers above will work for you in the majority of the cases where this error occurs.
However, I would like to note that you can also get the Could not connect to a primary node for replica set error when trying to write exceptionally large batches of records to MongoDB in one request. I have encountered this error when writing more than 200,000 1 KB documents to a remote MongoDB server with in one request. The remote server had 8 GB memory and would handle several requests at once. This error can be avoided by cutting down the batch size of your requests.

Resources