Change storage paths

Add data and log disks on a VM

  1. Attach iSCSI storage to the target host.

  1. On the top navigation bar, click Hosts.

  1. Select a host, and then select the Storage tab.

  1. Click Add.

  1. Add an iSCSI storage pool.

Figure-1 Selecting the iSCSI Network Storage type

 

Figure-2 Configuring storage pool settings

 

  1. Verify that the iSCSI storage pool is normal.

  1. Attach a disk to the target VM.

  1. On the top navigation bar, click Storage, and then select Storage Management > Block Device Management from the navigation pane.

  1. Add a 500 GB block device in a data pool used for cache acceleration.

Figure-3 Adding a 500 GB block device

 

  1. Add a 200 GB block device in an SSD data pool.

Figure-4 Adding a 200 GB block device

 

  1. Edit the VM to attach the 500 GB block device as a disk to the VM.

Figure-5 Attaching the 500 GB block device as a disk

 

  1. Attach the 200 GB block device as a log disk to the VM.

Figure-6 Attaching the 200 GB block device as a disk

 

Format disks

  1. Execute the lsblk command to verify that the data and log disks have been attached to the VM.

[root@localhost ~]# lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

fd0               2:0    1    4K  0 disk

sr0              11:0    1 1024M  0 rom 

vda             252:0    0  100G  0 disk

   vda1          252:1    0    1G  0 part /boot

   vda2          252:2    0   99G  0 part

      centos-root 253:0    0   50G  0 lvm  /

      centos-swap 253:1    0  7.9G  0 lvm  [SWAP]

      centos-home 253:2    0 41.1G  0 lvm  /home

vdb             252:16   0  500G  0 disk

vdc             252:32   0  200G  0 disk

  1. Add partitions on data disk vdb.

[root@localhost ~]# fdisk /dev/vdb

Welcome to fdisk (util-linux 2.23.2).

 

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

 

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x25e7e632.

 

Command (m for help): n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p):

Using default response p

Partition number (1-4, default 1):

First sector (2048-1048575999, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-1048575999, default 1048575999):

Using default value 1048575999

Partition 1 of type Linux and of size 500 GiB is set

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@localhost ~]#

  1. Add partitions on log disk vdc.

 [root@localhost ~]# fdisk /dev/vdc

Welcome to fdisk (util-linux 2.23.2).

 

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

 

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x2d99bcb6.

 

Command (m for help): n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p):

Using default response p

Partition number (1-4, default 1):

First sector (2048-419430399, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399):

Using default value 419430399

Partition 1 of type Linux and of size 200 GiB is set

 

Command (m for help):

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@localhost ~]#

[root@localhost ~]# lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

fd0               2:0    1    4K  0 disk

sr0              11:0    1 1024M  0 rom 

vda             252:0    0  100G  0 disk

    vda1          252:1    0    1G  0 part /boot

    vda2          252:2    0   99G  0 part

      centos-root 253:0    0   50G  0 lvm  /

      centos-swap 253:1    0  7.9G  0 lvm  [SWAP]

      centos-home 253:2    0 41.1G  0 lvm  /home

vdb             252:16   0  500G  0 disk

    vdb1          252:17   0  500G  0 part

vdc             252:32   0  200G  0 disk

    vdc1          252:33   0  200G  0 part

  1. Format the partitions by using Ext4.

 [root@localhost ~]# mkfs.ext4 /dev/vdb1

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

32768000 inodes, 131071744 blocks

6553587 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2279604224

4000 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,

        102400000

 

Allocating group tables: ^[[Adone                           

Writing inode tables: done                           

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done    

 

[root@localhost ~]# mkfs.ext4 /dev/vdc1

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

13107200 inodes, 52428544 blocks

2621427 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2199912448

1600 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424, 20480000, 23887872

 

Allocating group tables: done

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

Change disk paths

  1. Stop the MySQL service.

[root@localhost ~]# systemctl stop mysqld.service

[root@localhost ~]#

  1. Add directories /home/mysql and /home/mysqllog.

[root@localhost ~]# cd /home/

[root@localhost home]# mkdir mysql

[root@localhost home]# mkdir mysqllog

[root@localhost home]#

  1. Mount /dev/vdb1 to /home/mysql and /dev/vdc1 to /home/mysqllog.

[root@localhost home]# echo '/dev/vdb1 /home/mysql ext4 defaults 0 0'>> /etc/fstab

[root@localhost home]# echo '/dev/vdc1 /home/mysqllog  ext4 defaults 0 0'>> /etc/fstab

[root@localhost home]#

[root@localhost home]# cat /etc/fstab

# /etc/fstab

# Created by anaconda on Thu Aug  2 20:47:44 2018

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/centos-root /                       xfs     defaults        0 0

UUID=0dba471b-6422-45f7-b0be-fdd3fc9c4eb7 /boot                   xfs     defaults        0 0

/dev/mapper/centos-home /home                   xfs     defaults        0 0

/dev/mapper/centos-swap swap                    swap    defaults        0 0

/dev/vdb1 /home/mysql ext4 defaults 0 0

/dev/vdc1 /home/mysqllog  ext4 defaults 0 0

[root@localhost home]# mount -a

[root@localhost home]# df -h

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/centos-root   50G  7.9G   43G  16% /

devtmpfs                  16G     0   16G   0% /dev

tmpfs                     16G     0   16G   0% /dev/shm

tmpfs                     16G  9.7M   16G   1% /run

tmpfs                     16G     0   16G   0% /sys/fs/cgroup

/dev/vda1               1014M  171M  844M  17% /boot

/dev/mapper/centos-home   42G   37M   42G   1% /home

tmpfs                    3.2G  8.0K  3.2G   1% /run/user/42

tmpfs                    3.2G     0  3.2G   0% /run/user/0

/dev/vdb1                493G   73M  467G   1% /home/mysql

/dev/vdc1                197G   61M  187G   1% /home/mysqllog

  1. Modify the user and user group ownership of the mysql and mysqllog directories.

[root@localhost home]# chown -R mysql:mysql mysql

[root@localhost home]# chown -R mysql:mysql mysqllog/

[root@localhost home]# ll

total 12

drwx------. 16 cloud cloud 4096 Aug  2  2018 cloud

drwxr-xr-x.  3 mysql mysql 4096 Jul  9 02:21 mysql

drwxr-xr-x.  3 mysql mysql 4096 Jul  9 02:21 mysqllog

[root@localhost home]# chmod 777 mysql

[root@localhost home]#

[root@localhost home]#

[root@localhost home]# ll

total 12

drwx------. 16 cloud cloud 4096 Aug  2  2018 cloud

drwxrwxrwx.  3 mysql mysql 4096 Jul  9 02:21 mysql

drwxr-xr-x.  3 mysql mysql 4096 Jul  9 02:21 mysqllog

  1. Modify the my.cnf file.

 [root@localhost home]# vi /etc/my.cnf

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]

#

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

#

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

#

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

#datadir=/var/lib/mysql

#socket=/var/lib/mysql/mysql.sock

datadir=/home/mysql

socket=/home/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

log-error=/home/mysqllog/mysqld.log

innodb_log_group_home_dir=/home/mysqllog

pid-file=/var/run/mysqld/mysqld.pid

skip-grant-tables

[client]

default-character-set=utf8

socket =/home/mysql/mysql.sock

 [mysql]

default-character-set=utf8

socket =/home/mysql/mysql.sock

"/etc/my.cnf" 44L, 1177C written

[root@localhost home]#

  1. Move the files in /var/lib/mysql/ to /home/mysql/.

[root@localhost home]#

[root@localhost home]# mv /var/lib/mysql/*  /home/mysql

[root@localhost home]#

[root@localhost home]#

[root@localhost home]# cd mysql

[root@localhost mysql]# ll

total 110668

-rw-r-----. 1 mysql mysql       56 Jul  6 04:52 auto.cnf

-rw-------. 1 mysql mysql     1679 Jul  6 04:52 ca-key.pem

-rw-r--r--. 1 mysql mysql     1107 Jul  6 04:52 ca.pem

-rw-r--r--. 1 mysql mysql     1107 Jul  6 04:52 client-cert.pem

-rw-------. 1 mysql mysql     1679 Jul  6 04:52 client-key.pem

-rw-r-----. 1 mysql mysql      299 Jul  9 02:24 ib_buffer_pool

-rw-r-----. 1 mysql mysql 12582912 Jul  9 02:24 ibdata1

-rw-r-----. 1 mysql mysql 50331648 Jul  9 02:24 ib_logfile0

-rw-r-----. 1 mysql mysql 50331648 Jul  6 04:51 ib_logfile1

drwx------. 2 mysql mysql    16384 Jul  9 02:21 lost+found

drwxr-x---. 2 mysql mysql     4096 Jul  6 04:52 mysql

drwxr-x---. 2 mysql mysql     4096 Jul  6 04:52 performance_schema

-rw-------. 1 mysql mysql     1679 Jul  6 04:52 private_key.pem

-rw-r--r--. 1 mysql mysql      451 Jul  6 04:52 public_key.pem

-rw-r--r--. 1 mysql mysql     1107 Jul  6 04:52 server-cert.pem

-rw-------. 1 mysql mysql     1675 Jul  6 04:52 server-key.pem

drwxr-x---. 2 mysql mysql    12288 Jul  6 04:52 sys

  1. Set the state of SELinux to disabled and reboot.

[root@localhost mysql]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing - SELinux security policy is enforced.

#     permissive - SELinux prints warnings instead of enforcing.

#     disabled - No SELinux policy is loaded.

SELINUX=disabled

# SELINUXTYPE= can take one of three two values:

#     targeted - Targeted processes are protected,

#     minimum - Modification of targeted policy. Only selected processes are protected.

#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

"/etc/selinux/config" 14L, 546C written

[root@localhost mysql]#

[root@localhost mysql]#

[root@localhost mysql]# reboot