3

I moved my bin-logs to a different folder:

log-bin = /storage/mysql/bin-log
log-bin-index = /storage/mysql/bin-log.index

When I try to start mysqld I get this:

/usr/libexec/mysqld: File '/storage/mysql/bin-log.index' not found (Errcode: 13)

Permissions for the files and directory are fine, sudo -u mysql touch /storage/mysql/bin-log.index is working fine and there is no apparmor installed.

Any ideas what could cause this?

2 Answers 2

3

SELinux was installed and it didn't allow access to those files.

Disabling it solves the problem.

2
2

Based on this documentation from Red Hat: Chapter 3. SELinux Contexts and man page reading:

I want to have logfiles in /var/log/mysql instead of /var/log/mariadb and leave SELinux enabled.

The newly created log directory /var/log/mysql will by default be unaccessible to MySQL server due to SELinux.

So:

grep for string setroubleshoot in /var/log/ and run the indicated sealert commands to find details on the actual SELinux problem you observe.

For example:

sealert -l 141804b3-9ae5-4484-be0b-741fc558ff6d
SELinux is preventing /usr/libexec/mysqld from 'read, write' accesses on the file bin_hull03.index.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that mysqld should be allowed read write access on the bin_hull03.index file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'mysqld' --raw | audit2allow -M my-mysqld
# semodule -i my-mysqld.pp


Additional Information:
...

This is not necessarily helpful in this case.

Use ls -lZ to find out what the context of /var/log/mysql is relative to /var/log/mariadb:

# ls -lZ /var/log/mysql /var/log/mariadb
drwxrwx---. root mysql unconfined_u:object_r:var_log_t:s0 mysql
drwxr-x---. mysql mysql system_u:object_r:mysqld_log_t:s0 mariadb

Now adapt the file context of the tree /var/log/mysql.

Check what its supposed value is by retrieving the context for /var/log/mariadb from the SELinux config database:

# semanage fcontext --list | egrep '/var/log/(mysql|mariadb)'
/var/log/mysql.*       regular file  system_u:object_r:mysqld_log_t:s0 
/var/log/mysql(/.*)?   all files     system_u:object_r:mysqld_log_t:s0

Add an entry to the SELinux settings database to define the context of the new file tree:

# semanage fcontext --add -s system_u -t mysqld_log_t  '/var/log/mysql(/.*)?'
semanage fcontext --list | egrep '/var/log/(mysql|mariadb)'
/var/log/mysql.*        regular file   system_u:object_r:mysqld_log_t:s0 
/var/log/mariadb(/.*)?  all files      system_u:object_r:mysqld_log_t:s0 
/var/log/mysql(/.*)?    all files      system_u:object_r:mysqld_log_t:s

Set SELinux attributes recursively on the new file tree itself:

restorecon -r -F /var/log/mysql/

This gives what we want:

# ls -lZR /var/log/mysql/
/var/log/mysql/:
drwxrwx---. root  mysql system_u:object_r:mysqld_log_t:s0 binary
drwxrwx---. root  mysql system_u:object_r:mysqld_log_t:s0 general
-rw-rw----. mysql mysql system_u:object_r:mysqld_log_t:s0 mysqld_safe_log.err
drwxrwx---. root  mysql system_u:object_r:mysqld_log_t:s0 relay
-rw-rw----. mysql mysql system_u:object_r:mysqld_log_t:s0 server.err
drwxrwx---. root  mysql system_u:object_r:mysqld_log_t:s0 slow

/var/log/mysql/binary:
-rw-rw----. mysql mysql system_u:object_r:mysqld_log_t:s0 bin_hull03.000001
-rw-rw----. mysql mysql system_u:object_r:mysqld_log_t:s0 bin_hull03.000002
-rw-rw----. mysql mysql system_u:object_r:mysqld_log_t:s0 bin_hull03.index

/var/log/mysql/general:

/var/log/mysql/relay:

/var/log/mysql/slow:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.