MariaDB 10 CentOS 7 移动数据目录问题 [英] MariaDB 10 CentOS 7 moving datadir woes

查看:31
本文介绍了MariaDB 10 CentOS 7 移动数据目录问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CentOS 7 和 MariaDB 10 的全新最小"安装.我有一个额外的已安装镜像卷,我想将其用于数据目录.当 my.cnf [mysqld] 被注释掉时,启动顺序很好并且正常完成.我已经复制了数据..

Brand new "minimal" install of CentOS 7 along with MariaDB 10. I have an additional mounted mirrored volume that I want to use for the datadir. Startup sequence is fine and completes normally when my.cnf [mysqld] is commented out. I've copied the data..

sudo cp -R -p /var/lib/mysql/* /mnt/mysql/

权限与原始权限相同.卷在/etc/fstab 中并且可以正常安装/dev/sdb1/mnt/mysql xfs 默认 0 0

The permissions are identical to those of the original. The volume is in /etc/fstab and mounts fine /dev/sdb1 /mnt/mysql xfs defaults 0 0

[root@femur mysql]# ls -la
total 110632
drwxr-xr-x. 5 mysql mysql     4096 Oct 20 15:27 .
drwxr-xr-x. 3 root  root        18 Oct 16 16:46 ..
-rw-rw----. 1 mysql mysql    16384 Oct 20 15:27 aria_log.00000001
-rw-rw----. 1 mysql mysql       52 Oct 20 15:27 aria_log_control
-rw-r-----. 1 mysql root      7005 Oct 20 13:49 femur.err
-rw-rw----. 1 mysql mysql 12582912 Oct 20 15:27 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Oct 20 15:27 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Oct 20 12:21 ib_logfile1
-rw-rw----. 1 mysql mysql        0 Oct 20 12:22 multi-master.info
drwx--x--x. 2 mysql mysql     4096 Oct 20 12:21 mysql
drwx------. 2 mysql mysql     4096 Oct 20 13:37 performance_schema
drwxr-xr-x. 2 mysql mysql        6 Oct 20 12:21 test

这是在 my.cnf 中

this is in my.cnf

!includedir /etc/my.cnf.d
[mysqld]
log_error = /var/log/mysql-error.log
user = mysql
datadir = /mnt/mysql
socket = /mnt/mysql/mysql.sock

这是我尝试启动它时得到的...

This is what I get when I try to start it...

'[root@femur mysql]# sudo systemctl start mysql.service
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.'

这两个文件都没有说太多,但这是在/var/log/mysql-error.log 中

Neither of those two files says much, but this is in /var/log/mysql-error.log

141020 16:07:09 mysqld_safe Starting mysqld daemon with databases from /mnt/mysql
141020 16:07:09 [Warning] Can't create test file /mnt/mysql/femur.lower-test
141020 16:07:09 [Note] InnoDB: Using mutexes to ref count buffer pool pages
141020 16:07:09 [Note] InnoDB: The InnoDB memory heap is disabled
141020 16:07:09 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
141020 16:07:09 [Note] InnoDB: Memory barrier is not used
141020 16:07:09 [Note] InnoDB: Compressed tables use zlib 1.2.7
141020 16:07:09 [Note] InnoDB: Using Linux native AIO
141020 16:07:09 [Note] InnoDB: Using CPU crc32 instructions
141020 16:07:09 [Note] InnoDB: Initializing buffer pool, size = 128.0M
141020 16:07:09 [Note] InnoDB: Completed initialization of buffer pool
2014-10-20 16:07:09 7f6cb59c9880  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
141020 16:07:09 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions
141020 16:07:09 [ERROR] InnoDB: The system tablespace must be writable!
141020 16:07:09 [ERROR] Plugin 'InnoDB' init function returned error.
141020 16:07:09 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
141020 16:07:09 [ERROR] mysqld: File '/mnt/mysql/aria_log_control' not found (Errcode: 13 "Permission denied")
141020 16:07:09 [ERROR] mysqld: Got error 'Can't open file' when trying to use aria control file '/mnt/mysql/aria_log_control'
141020 16:07:09 [ERROR] Plugin 'Aria' init function returned error.
141020 16:07:09 [ERROR] Plugin 'Aria' registration as a STORAGE ENGINE failed.
141020 16:07:09 [Note] Plugin 'FEEDBACK' is disabled.
141020 16:07:09 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
141020 16:07:09 [ERROR] Unknown/unsupported storage engine: InnoDB
141020 16:07:09 [ERROR] Aborting

141020 16:07:09 [Note] /usr/sbin/mysqld: Shutdown complete

141020 16:07:09 mysqld_safe mysqld from pid file /mnt/mysql/femur.pid ended

http://www.reddit.com/r/linuxadmin/comments/2ebhpf/adventures_in_moving_mariadb_data_folder/ 有点帮助,但我无法让它工作.

http://www.reddit.com/r/linuxadmin/comments/2ebhpf/adventures_in_moving_mariadb_data_folder/ helped a bit, but I wasn't able to get it to work.

任何帮助将不胜感激.

推荐答案

问题确实是SELinux;在 CentOS 7 上启动 MariaDB/MySQL 之前,您需要做三件事:

The issue is indeed SELinux; you need to do three things before MariaDB / MySQL will start on CentOS 7:

  1. 确保 user:group 是 mysql:mysql
  2. 将 SELinux 标签设置为 mysqld_db_t
  3. 将 SELinux 用户设置为 system_u

这很简单:

chcon -Rt mysqld_db_t /database/db
chcon -Ru system_u /database/db
chown -R mysql:mysql /database/db

插入磁盘后我需要做的全部事情如下:

The whole thing I needed to do after plugging in a disk is below:

cfdisk /dev/sdb
pvcreate /dev/sdb1
vgcreate database /dev/sdb1
lvcreate -l 100%FREE -n db database
mkfs.ext4 /dev/database/db
mkdir /database
mount /database
mkdir /database/db
chcon -Rt mysqld_db_t /database/db
chcon -Ru system_u /database/db
chown -R mysql:mysql /database/db
systemctl start mariadb

这篇关于MariaDB 10 CentOS 7 移动数据目录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆