There are a number of ways in which the file system for MySQL can be established. The primary recommendation is that all volumes for a MySQL instance, regardless of how many, should be exported from the same FlashArray. The following table highlights the different approaches to the file system layouts for InnoDB based MySQL installations.
|
Default layout All of the database/schema files, data dictionary, undo files, bin logs, and transaction logs will be placed in the same directory at the default location for the operating system.
Note:
The recommendation for volumes from FlashArray is to mount a volume to the following locations with the correct permissions set before installing MySQL: Microsoft Windows - C:\ProgramData\MySQL (Permissions - NETWORK SERVICE - Full Control) Linux - /var/lib/MySQL (Permissions - user mysql , group mysql , drwxr-x--x) No system variables have been set or changed with this layout. |
||||
|---|---|---|---|---|
|
Migrating from default location to a different location The data files and database contents can be moved from the default location without data loss. This requires downtime.
The recommendation for a migration from the default location to a different one are to ensure the FlashArray volume has been formatted with a file system and mounted at the desired location. This example will assume that the new location is C:\MySQL for windows and /MySQL/data for Linux operating systems.
Microsoft Windows - C:\MySQL (Permissions - NETWORK SERVICE - Full Control). It is recommended NOT to place the database files directly on the root of the filesystem - for this example a new directory "data" will be created on the filesystem root and the permissions inherited from the parent. Linux - /MySQL/data (Permissions - user mysql , group mysql , drwxr-x--x)
Microsoft Windows- In a PowerShell terminal type the following command (for those running MySQL 8 the service name is mysql80, for mysql 5.7 it is mysql57):
Linux - In a terminal type the following command:
Microsoft Windows - In a PowerShell terminal use the following command to copy from the default directory to the new one while preserving the permissions:
Linux - In a command terminal use the following command to copy the contents of the default directory to the intended target destination:
Microsoft Windows - Modify the file "C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" and change the datadir entry to point towards the new location:
Linux - Modify the /etc/my.cnf configuration file and change the datadir entry to point towards the new location:
Get the SElinux labeling for the default data directory with the following command:
Once you have the label change it with the following command:
Edit the AppArmour configuration at the following location:
Change/copy the lines granting access to /var/lib/mysql to the new location reload AppArmor with the following command:
Microsoft Windows - Run the following command in a PowerShell terminal (for those running MySQL 8 the service name is mysql80, for mysql 5.7 it is mysql57):
Linux - Run the following command in a terminal:
|
||||
|
Separate data, binary, and transaction log directory It is possible to separate MySQL data directories based on what content should be located in each. This can be useful in some scenarios such as a replication use case recovering from binary logs on a remote system or applying quotas/quality of service restrictions on a per volume basis.
For each of the segregated directories required a corresponding volume on FlashArray should be present and connected to the MySQL host. In this example the host is named DB-01 and 5 volumes have been created for the MySQL instance. MySQL should be stopped during this process.
Each volume has been connected to the initiator, formatted with the relevant file system, and mounted at the relevant directory: Microsoft Windows Note:
In each mount a folder is created "data" which the "NETWORK SERVICE" user is assigned full control over. This user can be changed but must be the same user responsible for starting th MySQLXX service.
Linux Note:
Each mounted volume needs to be owned by the mysql user and group.
Windows In windows the options file is located at: C:\ProgramData\MySQL\MySQL Server 8.0\my.ini. Place the following variables and entries into the file with any other required customizations:
Linux In Linux the options file is located at: /etc/my.cnf. Place the following variables and entries into the file with any other required customizations:
This step is only optional if the data files have not been copied from the default location. See the section on Migrating from default location to a different location for how to copy the existing data files. Initializing the Data Directory creates a new MySQL instance with new data files and/or formats. This process can be used to change the default page size if it is required. A new defaults file at a different location or the standard defaults file can be used. Additional information on how to initialize the Data Directory can be found in the MySQL documentation. Windows In a PowerShell terminal execute the following to initialize the Data Directory:
If the Data Directory initializes successfully the output will offer a temporary password:
Linux In a terminal execute the following command as root to initialize the Data Directory:
Once the Data Directory has initialized successfully the output will offer a temporary password:
Get the SElinux labeling for the default data directory with the following command:
Once you have the label change it with the following command:
Edit the AppArmour configuration at the following location:
Change/copy the lines granting access to /var/lib/mysql to the new location. reload AppArmor with the following command:
Microsoft Windows - Run the following command in a PowerShell terminal (for those running MySQL 8 the service name is mysql80, for mysql 5.7 it is mysql57):
Linux - Run the following command in a terminal:
In order to access and customize the MySQL deployment, the initial setup process needs to be performed. To do this the mysql_secure_installation utility will be used. Microsoft Windows - The mysql_secure_installation executable is typically located in the bin folder of the installation directory for MySQL - the default location is "C:\Program Files\MySQL\MySQL Server 8.0\bin". The temporary password retrieved at the end of step 2 needs to be used to as the root password. Linux - The msql_secure_installation is accessible from the command line by invoking "mysql_secure_installation".
At this point the MySQL deployment is ready to use for database operations. |
||||
|
Separating database/schema files When a database or schema is created the corresponding data files are placed in a folder in the data directory. This layout is suitable for the majority of implementations but can be enhanced to allow for applying quality of service limits or per database capacity/quota management. This example is made up of four pre-existing databases/schemas each with the respective names warehouse01,warehouse02,warehouse03 and warehouse04. The files for each database/schema will be relocated to separate volumes and a symbolic link created to the data directory. Four volumes have been created on FlashArray and connected to the MySQL host - each corresponding to a database/schema:
Each volume needs to be formatted and mounted into a directory.
Microsoft Windows - The location of the mounted database volumes will be C:\MySQL\<DatabaseName>. A folder named "Data" is created in the root directory of each volume and the correct permissions assigned (NETWORK SERVICE with full control or the appropriate user which starts the mysql windows service). Linux - The location of the mounted volumes will be /mysq/<DatabaseName>. The correct permissions need to be assigned to each directory (chown mysql:mysq <directory>). Note:
MySQL naming for both databases are directories are case sensitive. Ensure that the directory names directly match the database names.
Microsoft Windows- In a PowerShell terminal type the following command (for those running MySQL 8 the service name is mysql80 , for mysql 5.7 it is mysql57):
Linux - In a terminal type the following command:
Microsoft Windows - In a PowerShell terminal use the following command to copy from the default directory to the new one while preserving the permissions:
Microsoft Windows- In a command terminal use the following command to copy the contents of the default directory to a new one:
Microsoft Windows In Microsoft Windows the mklink utility in command prompt will be used to create the symbolic link for each database volume. The following syntax will be used "mklink Link Target":
Once the symbolic links have been created there will be .symbolic files in the data directory. Note:
The directory the symbolic link points to must have the correct permissions assigned.
Linux - creating symbolic links will follow the syntax "ln -s <new volume directory> <base data directory>.
Once the symbolic links have been created they will show as links to the database volumes when looking at the directory listing.
Get the SElinux labeling for the default data directory with the following command:
Once you have the label change it with the following command:
Edit the AppArmour configuration at the following location:
Change/copy the lines granting access to /var/lib/mysql to the new location reload AppArmor with the following command:
Microsoft Windows - Run the following command in a PowerShell terminal (for those running MySQL 8 the service name is mysql80 , for mysql 5.7 it is mysql57):
Linux - Run the following command in a terminal:
In any one of the MySQL tools create a table and then check the corresponding data volume for the files created:
The table will have a corresponding *.ibd file created in the database volume. Microsoft Windows
Linux
|