MariaDB 10 CentOS 7 moving datadir woes

后端 未结 3 1289
遇见更好的自我
遇见更好的自我 2021-02-04 09:54

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 co

3条回答
  •  清歌不尽
    2021-02-04 10:17

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

    1. Ensure the user:group is mysql:mysql
    2. Set the SELinux tag to mysqld_db_t
    3. Set the SELinux user to system_u

    This is as simple as:

    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
    

提交回复
热议问题