No.M55-week5CentOS故障修复RAID简介分区文件系统网络模型实例
Posted hony625
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了No.M55-week5CentOS故障修复RAID简介分区文件系统网络模型实例相关的知识,希望对你有一定的参考价值。
2021-5-27
1.MBR修复
dd命令详解:
[root@centos6 ~]# dd --help
Usage: dd [OPERAND]...
or: dd OPTION
Copy a file, converting and formatting according to the operands.
bs=BYTES #一次读写块大小
cbs=BYTES convert BYTES bytes at a time
conv=CONVS convert the file as per the comma separated symbol list
count=N copy only N input blocks
ibs=BYTES read BYTES bytes at a time (default: 512)
if=FILE #输入文件名,缺省为标准输入
iflag=FLAGS read as per the comma separated symbol list
obs=BYTES write BYTES bytes at a time (default: 512)
of=FILE #输出文件名,缺省为标准输出
oflag=FLAGS write as per the comma separated symbol list
seek=BLOCKS #从输出文件开头跳过blocks个块后再开始复制
skip=BLOCKS #从输入文件开头跳过blocks个块后再开始复制
status=WHICH WHICH info to suppress outputting to stderr;
\'noxfer\' suppresses transfer stats, \'none\' suppresses all
# skip是跳过if中的前多少字节
# seek是跳过of中的前多少字节
一、备份分区文件:
[root@localhost ~]# dd if=/dev/sda of=/data/dpt.img bs=1 count=64 skip=446
[root@localhost ~]# scp /data/dpt.img 10.0.0.6:
二、模拟破坏分区:
索引部分任意地方破导致启动不了,只备份446开始的64字节,破坏这64字节内容
[root@localhost ~]# dd if=/dev/zero of=/dev/sda bs=1 count=64 seek=446
三、救援
reboot
进入光盘救援模式,选择3直接进入shell环境。备注:选1会出错,硬盘挂载不起来
配置临时网络(此时没有网络)
ifconfig ens eth0(看ifconfig中失效网卡) 10.0.0.6/24
scp 10.0.0.16: /root/dpt.img
dd if=dpt.img of=/dev/sda bs=1 seek=446
exit
实战:模拟破坏mbr表并修复
#1.备份MBR分区表
[root@centos6 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 406M 0 rom
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 199.5G 0 part
├─vg_centos6-lv_root (dm-0) 253:0 0 50G 0 lvm /
├─vg_centos6-lv_swap (dm-1) 253:1 0 3.9G 0 lvm [SWAP]
└─vg_centos6-lv_home (dm-2) 253:2 0 145.6G 0 lvm /home
[root@centos6 ~]# dd if=/dev/sda of=/tmp/dpt.img bs=1 count=64 skip=446
64+0 records in
64+0 records out
64 bytes (64 B) copied, 0.000830782 s, 77.0 kB/s
[root@centos6 ~]# scp /tmp/dpt.img 10.0.0.6:
The authenticity of host \'10.0.0.6 (10.0.0.6)\' can\'t be established.
RSA key fingerprint is ad:ce:fa:ec:a7:6d:0d:d1:90:92:e9:d1:b5:b3:79:46.
Are you sure you want to continue connecting (yes/no)? y
Please type \'yes\' or \'no\': yes
Warning: Permanently added \'10.0.0.6\' (RSA) to the list of known hosts.
root@10.0.0.6\'s password:
dpt.img 100% 64 0.1KB/s 00:00
#2.破坏MBR分区表
[root@centos6 ~]# dd if=/dev/zero of=/dev/sda bs=1 count=64 seek=446
64+0 records in
64+0 records out
64 bytes (64 B) copied, 0.000832751 s, 76.9 kB/s
[root@centos6 ~]# reboot
#3.之后无法正常启动,进入grub>;
#重启系统快速按F2键,进入Bios界面,选择Boot选项,将光盘‘CD-ROM Drive’设置为第一个优先启动,F10保存
#4.进入救援模式‘rescue mode’,选择第3项 \'skip to shell\'
sh-4.1# ifconfig eth0 10.0.0.16/24
sh-4.1# scp 10.0.0.6:/root/dpt.img .
sh-4.1# dd if=dpt.img of=/dev/sda bs=1 seek=446
sh-4.1# exit
2.RAID级别及组合方式和性能
RAID介绍
RAID:Redundant Arrays of Inexpensive Disks,廉价磁盘冗余阵列。
多个磁盘组合成一个阵列提供更好的性能、冗余,或者两者都提供。
RAID级别及组合方式和性能
RAID-0 #以chunk为单位,读写数据,读、写性能提升,最少磁盘数:2,2+,无容错能力
RAID-1 #读性能提升,写性能略有下降,有冗余能力,最少磁盘数:2,2N
RAID-4 #多块数据盘异或运算值存于专用校验盘,有冗余能力,至少3块硬盘实现
RAID-5 #读、写性能提升、有容错能力:允许最多1块磁盘损坏,最少磁盘数:3,3+
RAID-6 #读、写性能提升、有容错能力:允许最多2块磁盘损坏,最少磁盘数:4,4+
RAID-10 #读、写性能提升、有容错能力:每组镜像最多只能坏一块,最少磁盘数:4,4+
RAID-01 #多块磁盘先实现RAID0,再组合成RAID1
RAID-50 #多块磁盘先实现RAID5,再组合成RAID0
3.创建文件系统
磁盘及文件系统基本命令介绍:
#磁盘分区等相关命令:
lsblk: #列出块设备信息(list block devices) -f输出文件系统信息
blkid: #打印块设备属性
fdisk: #操作磁盘分区表
pvcreate: #初始化LVM使用的物理卷
mkfs.ext4: #创建一个ext4文件系统
mount: #挂载一个文件系统到分区表
vgcreate: #创建一个卷组
vgs: #显示卷组信息
lvcreate: #创建一个逻辑卷
lvs: #显示逻辑卷信息
实战:创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统 ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
#1.新增一个20G大小的sdb硬盘,做实验操作
[root@CentOS7 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 100G 0 part /
sdb 8:16 0 20G 0 disk
sr0 11:0 1 4G 0 rom
#2.在sdb上创建2G分区
[root@centos6 ~]# fdisk /dev/sdb
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition\'s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
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):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +2G
Partition 1 of type Linux and of size 2 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#3.在sdb分区上创建文件系统
[root@CentOS7 ~]# mkfs.ext4 -b 2048 -m 1 -L TEST /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=TEST
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 1048576 blocks
10485 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=269484032
64 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
#4.查看分区结果
[root@CentOS7 ~]# blkid
/dev/sda1: UUID="9a8e98ca-f998-4af2-9dae-28a78e2e4838" TYPE="xfs"
/dev/sda2: UUID="bbb7b1c6-74d0-499b-8d71-7b6240b0fcb5" TYPE="swap"
/dev/sda3: UUID="14e56b7c-4eff-4c7d-bf27-0d1ec866a3fb" TYPE="xfs"
/dev/sdb1: LABEL="TEST" UUID="e84464e9-70bb-4c87-869e-7e2e3e8a5c76" TYPE="ext4"
/dev/sr0: UUID="2015-12-09-23-14-10-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
[root@CentOS7 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 100G 0 part /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part
sr0 11:0 1 4G 0 rom
#5.将分区挂载到指定文件夹/test
[root@CentOS7 ~]# mkdir /test
[root@CentOS7 ~]# echo \'UUUUID=e84464e9-70bb-4c87-869e-7e2e3e8a5c76 /test ext4 acl 0 0\' >> /etc/fstab
[root@CentOS7 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Apr 20 21:28:17 2021
#
# 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=14e56b7c-4eff-4c7d-bf27-0d1ec866a3fb / xfs defaults 0 0
UUID=9a8e98ca-f998-4af2-9dae-28a78e2e4838 /boot xfs defaults 0 0
UUID=bbb7b1c6-74d0-499b-8d71-7b6240b0fcb5 swap swap defaults 0 0
UUUUID=e84464e9-70bb-4c87-869e-7e2e3e8a5c76 /test ext4 acl 0 0
#6.使挂载生效
[root@CentOS7 ~]# mount -a
#7.查看挂载文件系统
[root@CentOS7 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 100G 0 part /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part /test
sr0 11:0 1 4G 0 rom
实战:创建一个至少有两个PV组成的大小为20G的名为testvg的VG;要求PE大小 为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv;挂载至/users目录
#1.查看磁盘,新增了一个10G盘sdc
[root@CentOS7 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 100G 0 part /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part /test
sdc 8:32 0 10G 0 disk
sr0 11:0 1 4G 0 rom
#2.在sdc创建10G分区
[root@CentOS7 ~]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).
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-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +10G
Value out of range.
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +9G
Partition 1 of type Linux and of size 9 GiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition \'Linux\' to \'Linux LVM\'
Command (m for help): p
Disk /dev/sdc: 10.7 GB, 10737418240 bytes, 20971520 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: 0x625894bd
Device Boot Start End Blocks Id System
/dev/sdc1 2048 18876415 9437184 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#3.在sdc1分区和sdb上分别创建物理卷(PV)
#pvcreate依赖包lvm2-2.02.180-10.el7_6.8.x86_64
[root@CentOS7 ~]# yum provides pvcreate
7:lvm2-2.02.180-10.el7_6.8.x86_64 : Userland logical volume management tools
Repo : update
Matched from:
Filename : /usr/sbin/pvcreate
[root@CentOS7 ~]# yum -y install lvm2-2.02.180-10.el7_6.8.x86_64
#4.在sdc1分区和sdb上分别创建物理卷(pv)
[root@CentOS7 ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
[root@CentOS7 ~]# pvcreate /dev/sdb
WARNING: dos signature detected on /dev/sdb at offset 510. Wipe it? [y/n]: y
Wiping dos signature on /dev/sdb.
Physical volume "/dev/sdb" successfully created.
[root@CentOS7 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb lvm2 --- 20.00g 20.00g
/dev/sdc1 lvm2 --- 9.00g 9.00g
#5.创建物理卷组testvg(vg),并将创建的pv加入其中
[root@CentOS7 ~]# vgcreate -s 16M testvg /dev/sdb /dev/sdc1
Volume group "testvg" successfully created
[root@CentOS7 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
testvg 2 0 0 wz--n- <28.97g <28.97g
#6.在testvg中创建大小为5G的逻辑卷(LV)
[root@CentOS7 ~]# lvcreate -n testlv -L 5G testvg
WARNING: ext4 signature detected on /dev/testvg/testlv at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/testvg/testlv.
Logical volume "testlv" created.
[root@CentOS7 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
testlv testvg -wi-a----- 5.00g
#6.创建文件系统
[root@CentOS7 ~]# mkfs.ext4 /dev/testvg/testlv
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
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
#7.确认BLKID并加入/etc/fstab
[root@CentOS7 ~]# blkid
/dev/sda1: UUID="9a8e98ca-f998-4af2-9dae-28a78e2e4838" TYPE="xfs"
/dev/sda2: UUID="bbb7b1c6-74d0-499b-8d71-7b6240b0fcb5" TYPE="swap"
/dev/sda3: UUID="14e56b7c-4eff-4c7d-bf27-0d1ec866a3fb" TYPE="xfs"
/dev/sdb: UUID="nQf48z-QM6T-QTXA-MwWj-G44h-XQbq-x9wMie" TYPE="LVM2_member"
/dev/sdc1: UUID="WqmKbk-4Ka4-1OQO-JoHt-iHY3-A7RO-ke9Y7U" TYPE="LVM2_member"
/dev/sr0: UUID="2015-12-09-23-14-10-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
/dev/mapper/testvg-testlv: UUID="9e33092d-7dd0-41b8-b576-337cc13c6ee8" TYPE="ext4"
[root@CentOS7 ~]# echo \'UUID=9e33092d-7dd0-41b8-b576-337cc13c6ee8 /users ext4 defaults 0 0\' >> /etc/fstab
[root@CentOS7 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Apr 20 21:28:17 2021
#
# 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=14e56b7c-4eff-4c7d-bf27-0d1ec866a3fb / xfs defaults 0 0
UUID=9a8e98ca-f998-4af2-9dae-28a78e2e4838 /boot xfs defaults 0 0
UUID=bbb7b1c6-74d0-499b-8d71-7b6240b0fcb5 swap swap defaults 0 0
UUID=9e33092d-7dd0-41b8-b576-337cc13c6ee8 /users ext4 defaults 0 0
#8.创建文件夹,并让其生效
[root@CentOS7 ~]# mkdir /users
[root@CentOS7 ~]# mount -a
4.网络模型
实战:简述osi七层模型和TCP/IP五层模型
#OSI七层网络模型
1.应用层 #提供网络服务和接口,协议有HTTP,FTP等
2.表示层 #数据的表示、安全、压缩,格式有JPEG,ASCII、加密格式等
3.会话层 #建立、管理、终止会话,对应主机进程正在进行的会话
4.传输层 #定义传输数据的协议端口号,以及流控和差错校验,协议有TCP,UDP等
5.网络层 #进行逻辑地址寻址,实现不同网络间路径选择,协议有ICMP,IP等
6.数据链路层 #建立逻辑连接,进行硬件寻址,差错校验,如用MAC访问介质
7.物理层 #建立、维护、断开物理连接
#TCP/IP五层模型
1.应用层 #对应OSI的应用层,表示层,会话层
2.传输层 #对应OSI的传输层
3.网络层 #对应OSI的网络层
4.数据链路层 #对应OSI的数据链路层
5.物理层 #对应OSI的物理层
以上是关于No.M55-week5CentOS故障修复RAID简介分区文件系统网络模型实例的主要内容,如果未能解决你的问题,请参考以下文章