Linux将MySQL数据库目录挂载至新数据盘

Linux将MySQL数据库目录挂载至新数据盘,mysql挂载

对于Linux系统来讲,挂载磁盘的点子其实都大致,所以本文以CentOS系统为例,介绍下Linux系统磁盘挂载方法,后边超越1/3内容出自天翼云的论坛。
一.翻看磁盘情状
接纳命令fdisk -l # 列出任何磁盘新闻

[[email protected] ~]# fdisk -l

Disk /dev/xvda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008a9a5

Device Boot          Start         End      Blocks   Id  System
/dev/xvda1               1         523     4194304   82  Linux swap / Solaris
Partition 1 does not end on cylinder boundary.
/dev/xvda2   *         523        5222    37747712   83  Linux

Disk /dev/xvde: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

贰.创办分区
 fdisk /dev/xvde # 对xvde硬盘举办分区
  n  # 创设一个新分区
  p  # 创制2个主分区(e为增添分区)
  1  # 壹代表第叁个主分区
  回车  # 从第1柱面起先分区
  回车  #
表示全数xvde全写入第贰分区(若须要将sdb分为八个分区,此时输入+分区大大小小)
  P  # 查看下已创立好的分区
  w  # 保存并退出

[[email protected] ~]# fdisk /dev/xvde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x590ca8b1.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-39162, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-39162, default 39162): 
Using default value 39162

Command (m for help): p

Disk /dev/xvde: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x590ca8b1

    Device Boot      Start         End      Blocks   Id  System
/dev/xvde1               1       39162   314568733+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

三.开立分区文件系统并格式化磁盘
# mkfs.ext4 /dev/xvde1 # 将xvde一以ext四格式举办格式化

[[email protected] ~]# mkfs.ext4 xvde1
mke2fs 1.41.12 (17-May-2010)
Could not stat xvde1 --- No such file or directory

The device apparently does not exist; did you specify it correctly?
[[email protected] ~]# mkfs.ext4 /dev/xvde1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
19660800 inodes, 78642183 blocks
3932109 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2400 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

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

四.在home目录上面创造文件夹mysql,并且将道具挂载至/home/mysql。

[[email protected] home]# mount /dev/xvde1 /home/mysql
[[email protected] home]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda2             36G  2.4G   32G   7% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/xvde1            296G  191M  281G   1% /home/mysql

借使原来文件夹中有文件挂载之后文件会未有并且出现lost+found文件夹,那时不用忧虑,能够用umount命令举办撤废挂载。
由来是那般的。
这一个牵扯到linux的VFS(虚拟文件系统)机制。登入未来,你看看的逐条目款项录,文件都以水源在加载时候组织在内部存款和储蓄器中的VFS目录树,而不是直接看到硬盘上的莫过于目录树。

依照笔者对

5.将磁盘UUID写入fstab

对于Linux系统来讲,磁盘xvda和xvde的分区是依附系统运行时识别的先后顺序来排列,那样就能产出五个当主机重启后,出现跳盘的图景,为了制止此情形的产生,就供给大家将磁盘的UUID消息写入fstab文件,将分区与磁盘绑定。
一)通过blkid得到磁盘分区的UUID

[[email protected] ~]# blkid
/dev/xvda1: UUID="5546dd0c-ef40-451b-b266-df8ef3a49967" TYPE="swap" 
/dev/xvda2: UUID="77fc0962-b3cf-400a-8903-0632e077fa09" TYPE="ext3" 
/dev/xvde1: UUID="1d17945b-c369-42de-85a8-47217d24d3e5" TYPE="ext4"

贰)通过vim /etc/fstab在最后壹行增添xvde1的磁盘音信

#
# /etc/fstab
# Created by anaconda on Thu Jan 12 02:47:21 2017
#
# 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
#
UUID=77fc0962-b3cf-400a-8903-0632e077fa09 /                       ext3    defaults        1 1
UUID=5546dd0c-ef40-451b-b266-df8ef3a49967 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID=d17945b-c369-42de-85a8-47217d24d3e5 /home/mysql ext4 defaults      0 0

六.将/var/lib/mysql/下的剧情转移至/home/mysql/,并且在/var/lib/下创制mysql的链接,实际目录其实为/home/mysql

[[email protected] /]# cd home
[[email protected] home]# mkdir mysql
[[email protected] home]# mv /var/lib/mysql/* /home/mysql
[[email protected] home]# ln /home/mysql /var/lib/mysql

7.验证时而,通过df命令查看磁盘的选拔状态。然后进入mysql命令,成立数据库test壹…,试行之后会在/home/mysql/文件夹下现身数据库test1,此外利用df命令查看磁盘使用情形。会意识/dev/xvde1使用量在巩固。

[[email protected] mysql]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda2            37155392   2417608  32850400   7% /
tmpfs                  4018012         0   4018012   0% /dev/shm
/dev/xvde1           309633052    217092 293687524   1% /home/mysql

 

对于Linux系统来讲,挂载磁盘的办法其实都大致,所以本文以CentOS系统为例,介绍下…

对此Linux系统来讲,挂载磁盘的格局其实都毫无2致,所以本文以CentOS系统为例,介绍下Linux系统磁盘挂载方法,前边大多数内容来自天翼云的论坛。
一.翻看磁盘情状
行职分令fdisk -l # 列出壹切磁盘音信

对于Linux系统来讲,挂载磁盘的方法其实都大概,所以本文以CentOS系统为例,介绍下Linux系统磁盘挂载方法,前边超越46%剧情出自天翼云的论坛。
壹.翻看磁盘意况
利用命令fdisk -l # 列出任何磁盘新闻

对此Linux系统来讲,挂载磁盘的不二秘籍其实都千篇一律,所以本文以CentOS系统为例,介绍下Linux系统磁盘挂载方法,前边大多数剧情来自天翼云的论坛。

[root@qxyw ~]# fdisk -l

Disk /dev/xvda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008a9a5

Device Boot          Start         End      Blocks   Id  System
/dev/xvda1               1         523     4194304   82  Linux swap / Solaris
Partition 1 does not end on cylinder boundary.
/dev/xvda2   *         523        5222    37747712   83  Linux

Disk /dev/xvde: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@qxyw ~]# fdisk -l

Disk /dev/xvda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008a9a5

Device Boot          Start         End      Blocks   Id  System
/dev/xvda1               1         523     4194304   82  Linux swap / Solaris
Partition 1 does not end on cylinder boundary.
/dev/xvda2   *         523        5222    37747712   83  Linux

Disk /dev/xvde: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

一.查看磁盘情形
接纳命令fdisk -l # 列出全体磁盘新闻

2.创办分区
 fdisk /dev/xvde # 对xvde硬盘进行分区
  n  # 创设三个新分区
  p  # 创设三个主分区(e为扩张分区)
  1  # 一代表第二个主分区
  回车  # 从第3柱面起首分区
  回车  #
表示整个xvde全写入第3分区(若须要将sdb分为三个分区,此时输入+分区大小)
  P  #Linux将MySQL数据库目录挂载至新数据盘。 查看下已成立好的分区
  w  # 保存并脱离

二.创办分区
 fdisk /dev/xvde # 对xvde硬盘进行分区
  n  # 创造一个新分区
  p  # 成立一个主分区(e为扩大分区)
  1  # 1表示第三个主分区
  回车  # 从第3柱面起头分区
  回车  #
表示全体xvde全写入第一分区(若供给将sdb分为多个分区,此时输入+分区大大小小)
  P  # 查看下已开立好的分区
  w  # 保存并退出

[root@ linuxidc.com ~]# fdisk -l

[root@qxyw ~]# fdisk /dev/xvde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x590ca8b1.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-39162, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-39162, default 39162): 
Using default value 39162

Command (m for help): p

Disk /dev/xvde: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x590ca8b1

    Device Boot      Start         End      Blocks   Id  System
/dev/xvde1               1       39162   314568733+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@qxyw ~]# fdisk /dev/xvde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x590ca8b1.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-39162, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-39162, default 39162): 
Using default value 39162

Command (m for help): p

Disk /dev/xvde: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x590ca8b1

    Device Boot      Start         End      Blocks   Id  System
/dev/xvde1               1       39162   314568733+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Disk/dev/xvda: 42.9 GB, 42949672960
bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier:0x0008a9a5

三.创立分区文件系统并格式化磁盘
# mkfs.ext4 /dev/xvde1 # 将xvde1以ext四格式实行格式化

三.创立分区文件系统并格式化磁盘
# mkfs.ext4 /dev/xvde1 # 将xvde一以ext四格式进行格式化

Device Boot          Start        End      Blocks  Id  System
/dev/xvda1              1        523    4194304  82  Linux swap
/ Solaris
Partition1 does not end on cylinder
boundary.
/dev/xvda2  *        523        5222    37747712  83  Linux

[root@qxyw ~]# mkfs.ext4 xvde1
mke2fs 1.41.12 (17-May-2010)
Could not stat xvde1 --- No such file or directory

The device apparently does not exist; did you specify it correctly?
[root@qxyw ~]# mkfs.ext4 /dev/xvde1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
19660800 inodes, 78642183 blocks
3932109 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2400 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

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@qxyw ~]# mkfs.ext4 xvde1
mke2fs 1.41.12 (17-May-2010)
Could not stat xvde1 --- No such file or directory

The device apparently does not exist; did you specify it correctly?
[root@qxyw ~]# mkfs.ext4 /dev/xvde1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
19660800 inodes, 78642183 blocks
3932109 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2400 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

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Disk/dev/xvde: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders Units = cylinders of
16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier:0x00000000

肆.在home目录上面创设文件夹mysql,并且将器材挂载至/home/mysql。

4.在home目录下边创立文件夹mysql,并且将器具挂载至/home/mysql。

2.开立分区
 fdisk /dev/xvde # 对xvde硬盘举行分区
  n  # 创立1个新分区
  p  # 创制2个主分区(e为扩张分区)
  1  # 一表示第二个主分区
  回车  # 从第3柱面开头分区
  回车  #
表示一切xvde全写入第一分区(若必要将sdb分为多个分区,此时输入+分区大大小小)
  P  # 查看下已开立好的分区
  w  # 保存并退出

[root@qxyw home]# mount /dev/xvde1 /home/mysql
[root@qxyw home]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda2             36G  2.4G   32G   7% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/xvde1            296G  191M  281G   1% /home/mysql
[root@qxyw home]# mount /dev/xvde1 /home/mysql
[root@qxyw home]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda2             36G  2.4G   32G   7% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/xvde1            296G  191M  281G   1% /home/mysql

[root@ linuxidc.com ~]# fdisk /dev/xvde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF
disklabel
Building anew DOS disklabel
with disk identifier
0x590ca8b1.
Changes will remainin memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.

假如原来文件夹中有文件挂载之后文件会磨灭并且出现lost+found文件夹,那时不用操心,能够用umount命令实行撤除挂载。
缘由是这么的。
本条牵扯到linux的VFS(虚拟文件系统)机制。登陆现在,你看到的壹一目录,文件都是根本在加载时候组织在内部存款和储蓄器中的VFS目录树,而不是直接观察硬盘上的实在目录树。
遵照本身对http://www.ibm.com/developerworks/cn/linux/l-vfs/那篇小说所描述的易懂掌握,当您挂载有个别设备到贰个VFS挂载点上时(举个例子/home),系统就把VFS中的那几个挂载点/home指向你聊起底所挂载的这么些设备上。那么你未来做客该挂载点时,就能够看到你最后挂载在那边的配备。而在此以前所挂载的器材依旧在这边,只然而挂载点/home已经不复指向在此之前的设备。你能够把原来的配备卸载以往挂载到一个新的挂载点上来访问。

假使原来文件夹中有文件挂载之后文件会磨灭并且出现lost+found文件夹,那时不用操心,可以用umount命令实行撤废挂载。
缘由是这么的。
以此牵扯到linux的VFS(虚拟文件系统)机制。登陆未来,你看到的次第目录,文件都是根本在加载时候组织在内部存款和储蓄器中的VFS目录树,而不是直接观看硬盘上的实在目录树。
遵照本人对http://www.ibm.com/developerworks/cn/linux/l-vfs/那篇小说所描述的通俗精通,当你挂载有些设备到1个VFS挂载点上时(譬如/home),系统就把VFS中的这一个挂载点/home指向您最后所挂载的可怜设备上。那么您今后做客该挂载点时,就能够看出您聊起底挂载在这里的装置。而在此以前所挂载的配备照旧在那边,只不过挂载点/home已经不再指向从前的设施。你能够把本来的设备卸载未来挂载到一个新的挂载点上来访问。

Warning: invalid flag 0x0000 of partition table 4 will be corrected by
w(rite)

5.将磁盘UUID写入fstab

5.将磁盘UUID写入fstab

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
        switch off the mode
(command ‘c’) and change display units
to
        sectors (command’u’).

对此Linux系统来讲,磁盘xvda和xvde的分区是依靠系统运转时识别的先后顺序来排列,那样就汇合世3个当主机重启后,现身跳盘的图景,为了防止此境况的爆发,就供给大家将磁盘的UUID新闻写入fstab文件,将分区与磁盘绑定。
一)通过blkid得到磁盘分区的UUID

对此Linux系统来讲,磁盘xvda和xvde的分区是依靠系统运维时识别的先后顺序来排列,那样就能够产出贰个当主机重启后,出现跳盘的状态,为了幸免此情景的发生,就供给大家将磁盘的UUID新闻写入fstab文件,将分区与磁盘绑定。
壹)通过blkid获得磁盘分区的UUID

Command (mfor help): n
Command action
997755.com澳门葡京 ,  e  extended
  p  primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-39162, default 1):
Usingdefault value 1
Last cylinder,+cylinders or +size{K,M,G} (1-39162, default 39162):
Usingdefault value
39162

[root@qxyw ~]# blkid
/dev/xvda1: UUID="5546dd0c-ef40-451b-b266-df8ef3a49967" TYPE="swap" 
/dev/xvda2: UUID="77fc0962-b3cf-400a-8903-0632e077fa09" TYPE="ext3" 
/dev/xvde1: UUID="1d17945b-c369-42de-85a8-47217d24d3e5" TYPE="ext4"
[root@qxyw ~]# blkid
/dev/xvda1: UUID="5546dd0c-ef40-451b-b266-df8ef3a49967" TYPE="swap" 
/dev/xvda2: UUID="77fc0962-b3cf-400a-8903-0632e077fa09" TYPE="ext3" 
/dev/xvde1: UUID="1d17945b-c369-42de-85a8-47217d24d3e5" TYPE="ext4"

Command (mfor help): p

二)通过vim /etc/fstab在结尾一行增多xvde①的磁盘音讯

贰)通过vim /etc/fstab在最后一行增加xvde一的磁盘音讯

Disk/dev/xvde: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier:0x590ca8b1

#
# /etc/fstab
# Created by anaconda on Thu Jan 12 02:47:21 2017
#
# 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
#
UUID=77fc0962-b3cf-400a-8903-0632e077fa09 /                       ext3    defaults        1 1
UUID=5546dd0c-ef40-451b-b266-df8ef3a49967 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID=d17945b-c369-42de-85a8-47217d24d3e5 /home/mysql ext4 defaults      0 0
#
# /etc/fstab
# Created by anaconda on Thu Jan 12 02:47:21 2017
#
# 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
#
UUID=77fc0962-b3cf-400a-8903-0632e077fa09 /                       ext3    defaults        1 1
UUID=5546dd0c-ef40-451b-b266-df8ef3a49967 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID=d17945b-c369-42de-85a8-47217d24d3e5 /home/mysql ext4 defaults      0 0

    Device Boot      Start        End      Blocks  Id  System
/dev/xvde1              1      39162  314568733+  83  Linux

陆.将/var/lib/mysql/下的内容转移至/home/mysql/,并且在/var/lib/下创办mysql的链接,实际目录其实为/home/mysql

六.将/var/lib/mysql/下的原委转移至/home/mysql/,并且在/var/lib/下创办mysql的链接,实际目录其实为/home/mysql

Command (mfor help): w
The partition table has been altered!

[root@qxyw /]# cd home
[root@qxyw home]# mkdir mysql
[root@qxyw home]# mv /var/lib/mysql/* /home/mysql
[root@qxyw home]# ln /home/mysql /var/lib/mysql
[root@qxyw /]# cd home
[root@qxyw home]# mkdir mysql
[root@qxyw home]# mv /var/lib/mysql/* /home/mysql
[root@qxyw home]# ln /home/mysql /var/lib/mysql

Calling ioctl() to re-read
partition table.
Syncing disks.

柒.验证转眼,通过df命令查看磁盘的选取景况。然后进入mysql命令,创制数据库test壹…,试行之后会在/home/mysql/文件夹下出现数据库test一,其余利用df命令查看磁盘使用景况。会发觉/dev/xvde一使用量在做实。

柒.验证须臾间,通过df命令查看磁盘的行使意况。然后进入mysql命令,成立数据库test1…,实践之后会在/home/mysql/文件夹下现身数据库test1,其余利用df命令查看磁盘使用情状。会开采/dev/xvde壹使用量在加强。

叁.创造分区文件系统并格式化磁盘
# mkfs.ext4 /dev/xvde1 # 将xvde一以ext四格式举办格式化

[root@qxyw mysql]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda2            37155392   2417608  32850400   7% /
tmpfs                  4018012         0   4018012   0% /dev/shm
/dev/xvde1           309633052    217092 293687524   1% /home/mysql
[root@qxyw mysql]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda2            37155392   2417608  32850400   7% /
tmpfs                  4018012         0   4018012   0% /dev/shm
/dev/xvde1           309633052    217092 293687524   1% /home/mysql
[root@ linuxidc.com ~]# mkfs.ext4 xvde1
mke2fs 1.41.12 (17-May-2010)
Could not stat xvde1 --- No such file or directory

The device apparently does not exist; did you specify it correctly?
[root@ linuxidc.com ~]# mkfs.ext4 /dev/xvde1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
19660800 inodes, 78642183 blocks
3932109 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2400 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

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

 

四.在home目录上面成立文件夹mysql,并且将配备挂载至/home/mysql。

[root@ linuxidc.com home]# mount /dev/xvde1 /home/mysql
[root@ linuxidc.com home]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda2             36G  2.4G   32G   7% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/xvde1            296G  191M  281G   1% /home/mysql

比如原来文件夹中有文件挂载之后文件会消退并且出现lost+found文件夹,那时不用操心,能够用umount命令进行打消挂载。
缘由是这么的。
本条牵扯到linux的VFS(虚拟文件系统)机制。登6以往,你看到的各类目录,文件都以内核在加载时候组织在内部存款和储蓄器中的VFS目录树,而不是直接看出硬盘上的实际上目录树。
依照本人对 
http://www.linuxidc.com/Linux/2017-06/1450.htm 
那篇文章所讲述的通俗精晓,当您挂载有些设备到2个VFS挂载点上时(举个例子/home),系统就把VFS中的那个挂载点/home指向你最后所挂载的不胜设备上。那么您现在访问该挂载点时,就能够看出您最后挂载在此处的设施。而在此之前所挂载的装置仍旧在那里,只但是挂载点/home已经不复指向以前的器材。你可以把本来的设施卸载今后挂载到三个新的挂载点上来访问。

5.将磁盘UUID写入fstab

对此Linux系统来讲,磁盘xvda和xvde的分区是基于系统运维时识其余先后顺序来排列,那样就能够油但是生二个当主机重启后,出现跳盘的情况,为了幸免此景况的产生,就须求大家将磁盘的UUID音讯写入fstab文件,将分区与磁盘绑定。
1)通过blkid获得磁盘分区的UUID

[root@ linuxidc.com ~]# blkid
/dev/xvda1: UUID="5546dd0c-ef40-451b-b266-df8ef3a49967" TYPE="swap" 
/dev/xvda2: UUID="77fc0962-b3cf-400a-8903-0632e077fa09" TYPE="ext3" 
/dev/xvde1: UUID="1d17945b-c369-42de-85a8-47217d24d3e5" TYPE="ext4"

2)通过vim /etc/fstab在终极1行增加xvde一的磁盘音讯

#
# /etc/fstab
# Created by anaconda on Thu Jan 12 02:47:21 2017
#
# 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
#
UUID=77fc0962-b3cf-400a-8903-0632e077fa09 /                       ext3    defaults        1 1
UUID=5546dd0c-ef40-451b-b266-df8ef3a49967 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
UUID=d17945b-c369-42de-85a8-47217d24d3e5 /home/mysql ext4 defaults      0 0

陆.将/var/lib/mysql/下的从头到尾的经过转移至/home/mysql/,并且在/var/lib/下开创mysql的链接,实际目录其实为/home/mysql

[root@ linuxidc.com /]# cd home
[root@ linuxidc.com home]# mkdir mysql
[root@ linuxidc.com home]# mv /var/lib/mysql/* /home/mysql
[root@ linuxidc.com home]# ln /home/mysql /var/lib/mysql

柒.验证转眼,通过df命令查看磁盘的施用景况。然后进入mysql命令,成立数据库test1…,施行之后会在/home/mysql/文件夹下出现数据库test一,其余利用df命令查看磁盘使用状态。会发觉/dev/xvde一使用量在拉长。

[root@ linuxidc.com mysql]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda2            37155392   2417608  32850400   7% /
tmpfs                  4018012         0   4018012   0% /dev/shm
/dev/xvde1           309633052    217092 293687524   1% /home/mysql

正文长久更新链接地址:http://www.linuxidc.com/Linux/2017-06/145066.htm

997755.com澳门葡京 1

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website