patternsqlMinor
mysql bin-log.index not found
Viewed 0 times
binlogmysqlfoundindexnot
Problem
I moved my bin-logs to a different folder:
When I try to start mysqld I get this:
Permissions for the files and directory are fine,
Any ideas what could cause this?
log-bin = /storage/mysql/bin-log
log-bin-index = /storage/mysql/bin-log.indexWhen 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?
Solution
Based on this documentation from Red Hat: Chapter 3. SELinux Contexts and
I want to have logfiles in
The newly created log directory
So:
For example:
This is not necessarily helpful in this case.
Use
Now adapt the file context of the tree
Check what its supposed value is by retrieving the context for
Add an entry to the SELinux settings database to define the context of the new file tree:
Set SELinux attributes recursively on the new file tree itself:
This gives what we want:
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 mariadbNow 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:s0Add 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:sSet 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:Code Snippets
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:
...# 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# 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# 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:srestorecon -r -F /var/log/mysql/Context
StackExchange Database Administrators Q#12346, answer score: 2
Revisions (0)
No revisions yet.