linux foundation Exercise 5

1, lvm disk management to complete the requirements below, and write a detailed process:

  1) Create a size of the at least two PV VG is composed of named testvg of 20G; PE claim size 16MB, then the size of 5G created logical volume in the volume group testlv; to mount / users directory

Add two hard drives, plus a hard disk partition, partition LVM adjusted to form as a whole the three disk partition LVM

 


Creating success

 


 

View pv physical volume of a few hard disks, then create a vg (Volume group)

 


Create a volume group

Use vgcreate create a volume group vg0 expressed as a volume group name, add to the group consisting of a hard disk.

 


View basic information about the volume group

Next, create designated PE pe size 16M vgcreate testvg -s 16M / dev / sda6 / dev / sdb / dev / sdc

 


 

 

 


Create and view a logical volume lv

 


Create a file system and mount to the users directory

 2) extend testlv to 7G, archlinux requires the user's file can not be lost

lvextend -L + 2G / dev / testvg / testlv increased space to 7G

 


 

 


 

At this space has been expanded, but the corresponding file system is not created, so the df command or the original 5G of space, we need to add space added to the file system

 


 

ext4 system uses the remaining unallocated space resize2fs synchronization file system

xfs system uses xfs_growfs device mount point name extension

It can be expanded online increases mount, it is recommended to back up

3) testlv to shrink 3G, archlinux requires the user's file can not be lost

When shrink the file system, you need to unmount recommended that you make a backup,

umount canceled after checking the file system to mount the file system using the resize2fs first reduced to reduce the size of the space in 3G


 

 


 

 

 

4) Create a snapshot of the testlv, and try to function-based snapshot backup data validation snapshot

-n name -s specified snapshot to create a snapshot with lvcreate snapshot -pr expressed as a read-only attribute specifies the snapshot size -L / dev / testvg / testlv source logical volume

 


 

 


 

Then take the snapshot to mount the directory. Then found are synchronized, but did not really sync, we made additions and deletions to the source directory when a file in the source directory will be synchronized to the snapshot file

 


 

将旧文件删除。快照保留下来原始数据

 


 

作为备份时在拷贝新文件进来,这是快照将不会生效,只对快照生成时原始数据保留,新添加将不在保留

 


 

取消快照及逻辑卷挂载。用lvconvert --merge /dev/testvg/testlv_snap将快照进行还原

还原之后快将自动删除,注意xfs系统中如果创建快照需要利用mount -o nouuid 参数来取消用uuid挂载快照。不然快照和逻辑卷uuid冲突讲挂载不上去

 


 

重新挂载之后快照还原保留的数据,而快照创建之后的新建数据将不会保留

2、创建一个可用空间为1G的RAID1设备,文件系统为ext4,有一个空闲盘,开机可自动挂载至/backup目录

利用mdadm 组建raid设备

 


 

mdadm -C 创建 -a yes 初始化设备 /dev/md0设备 -l raid级别 -n 2几个成员  /dev/sd{a,b}raid成员

 


 

 


 

blkid /dev/md0取出raid设备的uuid号,将设备挂载至/backup目录实现开机自动挂载

 


 

开机后将自动挂载

3、简述TCP链接建立和断开过程

建立连接

TCP可靠连接,首部20字节的报文头部前四个字节包含发送数据源应用程序端口和目的地端口。

第二个字节包含一个序列号以为长度为32位,可生成的序列号seq为2的32次方为41亿的序列号,后四个字节确认号ack,表示为已方发送数据的序列号,希望对方下次发送过来seq+1的数字。表示对方已收到确认。对方主机也是同理

后四个字节,包含URG,ACK(不同于确认号ack),PSH,RST,SYN,FIN 的几个标志位

URG:表示报文段中发送的数据包含紧急数据,后面的紧急指针URG=1时有效

ACK:表示前面确认号字段是否有效,ACK=1时为有效,TCP规定中连接建立后,ACK必须为1,带ACK标准的TCP报文段称为确认段

PSH:提示接收端应用程序应该立即从TCP缓冲区中读走数据如果为1,表示对方应当立即把数据交给上层应用

RST:如果收到RST=1的保温,说明与主机的连接出现错误,必须释放连接,然后重新建立

SYN:建立连接时使用,用来同步序号,当SYN=1,ACK=0时表示请求建立连接SYN=1,ACK=1表示对方同意建立连接,SYN=1说明为请求建立连接或同意建立,只有在前两次握手中SYN才为1

FIN:表示通知对方本端口要关闭连接,FIN=1告诉对方“我的数据已经发送完毕,可以释放连接”带FIN的报文段称为结束报文段

 


 

窗口表示现在运行对方发送的数据量,也就是告诉对方,从本报文段的确认号开始允许对方发送的数据量,达到此值,需要ACK确认后才能继续传送后面的数据,有window size value * window size scaling factor (在三次握手阶段tcp选项window scale协商得到)得出此值


三次握手过程

客户端发送报文,标志位中SYN=1 ACK=0 seq=x 其他数据段暂不显示

SYN=1表示与对方请求通信 ACK=0表示未同意因为对方还没收到并回复,seq=x表示数据的序号

服务器接收并回复 SYN=1 ACK=1 表示同意建立连接seq=y表示服务器发送的自己的数据段序号,ack=x+1表示确认对方seq序号已收到,并用x+1方式告诉对方客户机

客户端再次确认ACK=1 seq=x+1 ack=y+1,ACK=1表示客户机已收到服务器发送的数据报seq=x+1表示客户机发送的这个确认报文数据的序号,ack=y+1表示收到上一条服务器发送的seq序号,并以ack=y+1方式告诉对方已收到上条序列号

到此,tcp三次握手建立连接的过程就已经完成,可以开始数据传输

断开连接

断开连接,四次挥手 比三次握手过程中多了一步,

 


 

ESTAB-LISHED在客户机建立连接的状态下,双方可以主动提出分手过程

举例客户机分手过程,客户机发送FIN=1表示为数据传输完成,可以断开连接了,seq=u表示当前发送数据报文的序列号,发送完字段后进入FIN-WAIT1状态,表示终止等待

服务器端收到客户的报文,发送ACK=1(同意断开连接),seq=v(发送的数据段序号),ack=u+1 (回应对方的数据段序号 )进入关闭等待,将传输最后数据段

服务器将最后数据发送给客户机FIN=1,ACK=1(完成传输并统一断开),seq=w(此数据段序号),ack=u+1(上一条确认号),进入LAST-ACK最后确认状态等待客户机发送确认断开的信号,如果一直收不到信号,服务器将一直等待客户机数据传输,

客户机发送ACK=1(统一断开连接),seq=u+1(表示上一个序号之后的),ack=w+1回应收到服务器的上一条数据段,之后进入time-wait状态,如果服务器还有报文,将可以继续连接如果等待时间内没有报文传输,则断开连接进入CLOSED关闭状态

当服务器收到客户机确认后,进入CLOSED状态

到此,四次挥手断开连接过程完成

tcp连接有限状态机的几种状态


 

 

4、简述TCP和UDP的区别

 

 


 

udp协议头部只包含16位源端口,16位目的端口 16位的udp报文长度和校验和,提供一个基础校验,且没有连接过程,确认目标端口号直接发送,不管对方主机有没有收到。

TCP(传输控制协议)提供的是面向连接、可靠的字节流服务。当客户端和服务器彼此交换数据前,必须先在双方之间建立一个TCP连接,之后才能传输数据。TCP提供超时重发,丢弃重复数据,检验数据,流量控制等功能,保证数据能从一端传到另一端。

UDP(用户数据报协议)是一个简单的面向数据报的运输层协议。UDP不提供可靠性,它只是把应用程序传给IP层的数据报发送出去,但是并不能保证它们能到达目的地。由于UDP在传输数据报前不用在客户和服务器之间建立一个连接,且没有超时重发等机制,故而传输速度很快。

由于UDP缺乏拥塞控制(congestion control),需要基于网络的机制来减少因失控和高速UDP流量负荷而导致的拥塞崩溃效应。换句话说,因为UDP发送者不能够检测拥塞,所以像使用包队列和丢弃技术的路由器这样的网络基本设备往往就成为降低UDP过大通信量的有效工具。数据报拥塞控制协议(DCCP)设计成通过在诸如流媒体类型的高速率UDP流中,增加主机拥塞控制,来减小这个潜在的问题。

 

Guess you like

Origin www.cnblogs.com/woaiyitiaochai/p/11757921.html