Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how and when to delete old neo4j transaction log files

Tags:

neo4j

My local Neo4j has a lot of transaction logs in data/graph.db:

251M  3 Sep 16:44 neostore.transaction.db.0
255M  3 Sep 20:01 neostore.transaction.db.1
255M  3 Sep 23:20 neostore.transaction.db.2
251M  4 Sep 19:34 neostore.transaction.db.3
250M  4 Sep 22:16 neostore.transaction.db.4
134M  5 Sep 05:02 neostore.transaction.db.5
16B  5 Sep 09:57 neostore.transaction.db.6
16B  7 Sep 16:44 neostore.transaction.db.7

I'm backing the graph.db folder up (I have stopped the neo4j instance) in order to reload in another offsite instance, so it would be nice to reduce the folder size.

  1. What methods are there to control these logs?
  2. How do I check if a given neostore.transaction.db.X file has been successfully processed?
  3. Is it safe to remove older processed files?

Logical logs are referred to in the docs, which I believe are the same files: http://neo4j.com/docs/stable/configuration-logical-logs.html

In conf/neo4j.properties I've changed the option keep_logical_logs to 100M size:

# Keep logical logs, helps debugging but uses more disk space, enabled for
# legacy reasons To limit space needed to store historical logs use values such
# as: "7 days" or "100M size" instead of "true".
keep_logical_logs=100M size

and restarted neo4j, but it hasn't removed any of the old log files. Can I do this manually when neo4j has stopped? Or are all of these files required? I stopped neo4j, made a backup of the graph.db directory, removed all bar neostore.transaction.db.7 and started neo4j again. It appears to be happy but...

Thanks!

like image 464
RedCraig Avatar asked Sep 07 '15 16:09

RedCraig


People also ask

Where are Neo4j logs stored?

In most Neo4j server environments, all logs will be found in NEO4J_HOME/logs.

What is log pruning?

The process of removing transaction logs that are no longer necessary for recovery is called pruning.

How to control the number of transaction logs that Neo4j keeps?

You can control the number of transaction logs that Neo4j keeps using the parameter dbms.tx_log.rotation.retention_policy . It is set to 7 days by default, which means Neo4j keeps logical logs that contain any transaction committed within 7 days.

How do I see the state of my Neo4j database?

We can now run the following command to see the state of the database: Most of the space is taken up by Logical Log, which is the aggregate size of Neo4j’s transaction logs. These are the files in our data/databases/graph.db field that have the neostore.transaction.db prefix:

How do I keep Neo4j running in the background?

The neo4j.log for each DBMS can be accessed directly from Desktop and opens in a separate window, which allows you to keep it in the background. This is the standard log and contains general information about Neo4j. Please see Operations Manual → Logging for more information about other Neo4j log files.

How do I delete a transaction log file in Oracle?

Remove Secondary Transaction Log File Right-click on the database and click Properties. Go the “Files” tab on the left side and select the log file that you want to delete from the “database files” secion and click on the remove button at the bottom right.


2 Answers

If you database in good condition you can delete all neostore.transaction.db.x files, but I recommend to you backup them.

  1. Stop Neo4j
  2. Delete neostore.transaction.db.x files
  3. Start Neo4j
like image 142
MicTech Avatar answered Oct 25 '22 08:10

MicTech


Updating:

In neo4j 3.x, the config has changed to:

dbms.tx_log.rotation.retention_policy=<true/false>
dbms.tx_log.rotation.retention_policy=<amount> <type>

see https://neo4j.com/docs/operations-manual/current/configuration/transaction-logs/ for more details

like image 24
Weizhou He Avatar answered Oct 25 '22 08:10

Weizhou He