[SOLVED] Log2ram full because logs too big

Hello,
I’ve got trouble with log2ram that stopped because it’s full (not enough RAM space). I’ve got already extended the size from 40M to 100M, but now that it reached 100M, it’s stopped again.
I’ve got a look to /var/log/ and the bigger directory is /var/log/mysql/.
I don’t know how to access inside /var/log/mysql because owners are ‘mysql - adm’. How can I do that?
How can I emptied this specific log?
How can I configure logrotate to avoid such problem.
Thanks,

I believe you will get quicker answer, if you can write a little bit more about you System and Hardware.
Generally if you do not have system with your /var/log/ on SD or eMMC you do not need log2ram.

Sorry gas85,
Nextcloud is on a Raspberry 3B+, with a SD card so I use Log2ram. NC version is 13.0.6 (I know it’s not up to date).
I’ve got extended in log2ram.conf size from 40M to 100M. But now again it’s full.
I watched in /var/log/ try to find who is so big (du): /var/log/mysql is 101M and is the only one of this size. I try to access inside this directory (cd), no way ; owners are mysql-adm even with root.
I’ve got force logrotate but error message is ‘can’t acces mysql logs’.
Thanks,

This is a big one…
Try to increase you partition a bit more.
Check that you have correct log rotate configuration under /etc/logrotate.d/mysql-server. My config will execute daily with compression looks like following:

# cat /etc/logrotate.d/mysql-server
# - I put everything in one block and added sharedscripts, so that mysql gets 
#   flush-logs'd only once.
#   Else the binary logs would automatically increase by n times every day.
# - The error log is obsolete, messages go to syslog now.
/var/log/mysql.log /var/log/mysql/*log {
	daily
	rotate 7
	missingok
	create 640 mysql adm
	compress
	sharedscripts
	postrotate
		test -x /usr/bin/mysqladmin || exit 0
		# If this fails, check debian.conf! 
		MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
		if [ -z "`$MYADMIN ping 2>/dev/null`" ]; then
		  # Really no mysqld or rather a missing debian-sys-maint user?
		  # If this occurs and is not a error please report a bug.
		  #if ps cax | grep -q mysqld; then
		  if killall -q -s0 -umysql mysqld; then
 		    exit 1
		  fi 
		else
		  $MYADMIN flush-logs
		fi
	endscript
}

For you it is important that you have at least daily and compress. Postrotate could be different depends on you setup. Also by rotate 7 you will set rotation limit - 7 Logs.

You could force log rotation of mysql by command:
logrotate --force /etc/logrotate.d/mysql-server

Also have a look on zram solution. It is possible to create compressed log2ram partition that will use less of you physical ram. Like armbian did: https://github.com/armbian/build/blob/master/packages/bsp/common/usr/lib/armbian/armbian-zram-config#L63

Added:
Also received comment that maxsize could help and there is a raspberry config attached: https://github.com/azlux/log2ram/pull/56#issuecomment-435332986

… a big one still increasing…
Here is my /etc/logrotate.d/mysql-server :

# - I put everything in one block and added sharedscripts, so that mysql gets
#   flush-logs'd only once.
#   Else the binary logs would automatically increase by n times every day.
# - The error log is obsolete, messages go to syslog now.
/var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/mariadb-slow.log /var/log/mysql/error.log {
        daily
        rotate 7
        missingok
        create 640 mysql adm
        compress
        sharedscripts
        postrotate
          test -x /usr/bin/mysqladmin || exit 0
          if [ -f `my_print_defaults --mysqld | grep -m 1 -oP "pid-file=\K.+$"` ]; then
            # If this fails, check debian.conf!
            mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log \
              flush-engine-log flush-general-log flush-slow-log
          fi
        endscript
}

I try :

The reported error is :

mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'                                                                    
error: error running shared postrotate script for '/var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/mariadb-slow.log /var/log/mysql/error.log '

The error rely on a access problem.
I will try zram later.
Thanks,

Hi,
Back again with this trouble log2ram.

First question : I look in /var/log/mysql and I see old files (date from the beginning of the installation) of this type mariadb-bin.0004 (many different numbers). This the part that is too big. So can I safely remove mysefl these files (the owner is mysql and the group is adm) myself with rm ?

Second : in /etc/logrotate.d/mysql-server ther is no path for this kind of files (mariadb-bin.000X) is it needed to add this path to end this problem?

Thanks

Not sure. Based on this:

It is kind of binary logs, have no experiance with it. Looks like you better to use MariDB log rotation function:

Looks it has nothing with standard log rotate functions. You can also read more about binary logs here:

Why are you logging to RAM? RAM is not very large on a raspberry. And then why the bin logs on RAM, when you system crashes everything from RAM will be lost (so it helps only if the database crashes itself).

Hi,
Yes it has nothing to do with NC. It’s an MariaDB issue. Binary Logs can’t be erased with an rm. I should try to purge bin logs with mariadb commands. I’m not use with mariadb so it’s time for me to learn about it.
Thanks,

Hi, I’m not sure about all things related on mariadb. But I use log2ram to reduce the writing on the SD card and extend its life this way. So many logs are written on the RAM. Bin Logs have to do with mariadb way to activate and purge these bin logs. I’m on the way.
Thanks.

Hello,
The problem is solved it was an issue with binary logs in mariadb. The reading given by gas85 gives me the solution. Thanks all.