MySQL Cluster: Rotating the log file of the Data Nodes

There is a log file called ndb_<NodeID>_out.log created by the MySQL Cluster data nodes which can become quite big overtime. There is, unlike the cluster logs created by the management nodes, no rotation build in. So you have to revert to the basics and copy the file away, truncating the old one.

For example, if you want to ‘rotate’ the log file of data node with NodeID 3:

$ mv ndb_3_out.log.1.gz ndb_3_out.log.2.gz
$ cp ndb_3_out.log ndb_3_out.log.1
$ cat /dev/null > ndb_3_out.log
$ gzip ndb_3_out.log.1

It’s not elegant, and you might lose some entries, but it will help you keeping disk usage minimal. If you don’t need the log at all, just line 3 would do the trick.

You can use logrotate’s copytruncate to achieve something similar.