为什么80%的码农都做不了架构师?>>>
云服务器环境:CentOS 7
客户端环境:windows 7
远程连接方式:运行 Xshell,输入命令 ssh username@ip 然后输入密码
查看磁盘空间情况
[root@iZbp1j6oiamq7t2otpryarZ ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 1.6G 36G 5% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 372K 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 783M 0 783M 0% /run/user/0
查看未挂载的硬盘
这里可以看到 Disk /dev/vdb: 107.4 GB 的磁盘是未挂载的
[root@iZbp1j6oiamq7t2otpryarZ ~]# fdisk -l
Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008de3e
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83884031 41940992 83 Linux
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
创建分区
这里我将107G的磁盘分为两个区,各50G ,
First sector (2048-209715199, default 2048): 104800000
红色的部分是我的分区大小分割点
[root@iZbp1j6oiamq7t2otpryarZ ~]# 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 0x0dbdad0c.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-209715199, default 2048): 104800000
Last sector, +sectors or +size{K,M,G} (104800000-209715199, default 209715199):
Using default value 209715199
Partition 1 of type Linux and of size 50 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
格式化
这里我格式化为xfs ,
# mkfs.ext3 /dev/vdb1
# mkfs.ext4 /dev/vdb1
# mkfs.xfs -f /dev/vdb1
Ext3 目前所支持的最大 16TB 文件系统,最大 2TB 文件;
Ext4 目前所支持 1EB(1,048,576TB, 1EB=1024PB, 1PB=1024TB)的文件系统,以及 16TB 的文件。对一般的台式机和服务器而言,这可能并不重要,但对于大型磁盘阵列的用户而言,这就非常重要了。
XFS 是一个64位文件系统,最大支持8EB减1字节的单个文件系统,实际部署时取决于宿主操作系统的最大块限制。对于一个32位Linux系统,文件和文件系统的大小会被限制在16TB。
[root@iZbp1j6oiamq7t2otpryarZ ~]# fdisk -l
Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008de3e
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83884031 41940992 83 Linux
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0dbdad0c
Device Boot Start End Blocks Id System
/dev/vdb1 2048 104859647 52428800 83 Linux
/dev/vdb2 104859648 209715199 52427776 83 Linux
[root@iZbp1j6oiamq7t2otpryarZ ~]# mkfs.xfs -f /dev/vdb1
meta-data=/dev/vdb1 isize=512 agcount=4, agsize=3278600 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=13114400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=6403, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@iZbp1j6oiamq7t2otpryarZ ~]# mkfs.xfs -f /dev/vdb2
meta-data=/dev/vdb2 isize=512 agcount=4, agsize=3274936 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=13099744, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=6396, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
挂载分区
这里我需要创建/app 和 /data 两个目录,分别存放应用程序、mysql数据库文件。
[root@iZbp1j6oiamq7t2otpryarZ ~]# mkdir /app
[root@iZbp1j6oiamq7t2otpryarZ ~]# mkdir /data
[root@iZbp1j6oiamq7t2otpryarZ /]# ls -l
total 68
drwxr-xr-x 2 root root 4096 Nov 1 13:03 app
lrwxrwxrwx. 1 root root 7 Aug 18 11:51 bin -> usr/bin
dr-xr-xr-x. 4 root root 4096 Oct 31 11:26 boot
drwxr-xr-x 2 root root 4096 Nov 1 13:03 data
drwxr-xr-x 20 root root 3060 Oct 31 11:26 dev
drwxr-xr-x. 82 root root 4096 Oct 31 11:26 etc
drwxr-xr-x. 2 root root 4096 Nov 5 2016 home
lrwxrwxrwx. 1 root root 7 Aug 18 11:51 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Aug 18 11:51 lib64 -> usr/lib64
drwx------. 2 root root 16384 Aug 18 11:51 lost+found
drwxr-xr-x. 2 root root 4096 Nov 5 2016 media
drwxr-xr-x. 2 root root 4096 Nov 5 2016 mnt
drwxr-xr-x. 2 root root 4096 Nov 5 2016 opt
dr-xr-xr-x 102 root root 0 Oct 31 11:26 proc
dr-xr-x---. 5 root root 4096 Oct 31 11:26 root
drwxr-xr-x 22 root root 620 Oct 31 11:26 run
lrwxrwxrwx. 1 root root 8 Aug 18 11:51 sbin -> usr/sbin
drwxr-xr-x. 2 root root 4096 Nov 5 2016 srv
dr-xr-xr-x 13 root root 0 Oct 31 19:26 sys
drwxrwxrwt. 8 root root 4096 Nov 1 03:50 tmp
drwxr-xr-x. 13 root root 4096 Aug 18 11:51 usr
drwxr-xr-x. 19 root root 4096 Oct 31 19:26 var
[root@iZbp1j6oiamq7t2otpryarZ ~]# mount /dev/vdb2 /data
[root@iZbp1j6oiamq7t2otpryarZ ~]# mount /dev/vdb1 /app
[root@iZbp1j6oiamq7t2otpryarZ ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 1.6G 36G 5% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 348K 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 783M 0 783M 0% /run/user/0
/dev/vdb2 50G 33M 50G 1% /data
/dev/vdb1 51G 33M 50G 1% /app
[root@iZbp1j6oiamq7t2otpryarZ ~]#
设置开机自动挂载
增加内容:
/dev/vdb1 /app xfs defaults 0 0
/dev/vdb2 /data xfs defaults 0 0
[root@iZbp1j6oiamq7t2otpryarZ ~]# vi /etc/fstab
[root@iZbp1j6oiamq7t2otpryarZ ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Aug 18 03:51:14 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=59d9ca7b-4f39-4c0c-9334-c56c182076b5 / ext4 defaults 1 1
/dev/vdb1 /app xfs defaults 0 0
/dev/vdb2 /data xfs defaults 0 0
卸载分区
[root@iZbp1j6oiamq7t2otpryarZ ~]# umount /dev/vdb2 /data
[root@iZbp1j6oiamq7t2otpryarZ ~]# umount /dev/vdb1 /app
[root@iZbp1j6oiamq7t2otpryarZ ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 1.6G 36G 5% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 348K 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 783M 0 783M 0% /run/user/0
[root@iZbp1j6oiamq7t2otpryarZ ~]# fdisk -l
Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008de3e
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83884031 41940992 83 Linux
Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0dbdad0c
Device Boot Start End Blocks Id System
/dev/vdb1 2048 104859647 52428800 83 Linux
/dev/vdb2 104859648 209715199 52427776 83 Linux