一.逻辑卷
作用:
1.整合分散的空间 2.空间可以扩大
将众多的物理卷(PV)组建成卷组(VG),再从卷组中划分逻辑卷(LV)
LVM管理工具集
功能 物理卷管理 卷组管理 逻辑卷管理
Scan 扫描 pvscan vgscan lvscan
Create 创建 pvcreate vgcreate lvcreate
Display 显示 pvdisplay vgdisplay lvdisplay
Remove 删除 pvremove vgremove lvremove
Extend 扩展 / vgextend lvextend
制作逻辑卷
1.创建卷组
命令格式:vgcreate 卷组的名字 设备路径.....
[root@server0 ~]# vgcreate systemvg /dev/vdb /dev/vdc1
[root@server0 ~]# pvs #查看物理卷信息
[root@server0 ~]# vgs #查看卷组信息
2.创建逻辑卷
命令格式:lvcreate -L 逻辑卷大小 -n 逻辑卷名称 基于的卷组名
[root@server0 ~]# lvcreate -L 16G -n vo systemvg
Logical volume "vo" created
[root@server0 ~]# lvs #查看逻辑卷信息
[root@server0 ~]# vgs #查看卷组信息
3.使用逻辑卷
[root@server0 ~]# ls /dev/systemvg/vo
[root@server0 ~]# ls -l /dev/systemvg/vo
[root@server0 ~]# mkfs.xfs /dev/systemvg/vo #格式化文件系统
[root@server0 ~]# blkid /dev/systemvg/vo #查看文件系统
[root@server0 ~]# vim /etc/fstab
/dev/systemvg/vo /mylv xfs defaults 0 0
[root@server0 ~]# mkdir /mylv
[root@server0 ~]# mount -a #检测/etc/fstab是否书写正确
[root@server0 ~]# df -h #查看正在挂载设备的信息
逻辑卷的扩展
1.卷组有足够的剩余空间
1)扩展逻辑卷空间
[root@server0 ~]# lvextend -L 18G /dev/systemvg/vo
[root@server0 ~]# lvs
[root@server0 ~]# df -h
2)扩展逻辑卷文件系统
扩展xfs文件系统: xfs_growfs
扩展ext4文件系统:resize2fs
[root@server0 ~]# blkid /dev/systemvg/vo #查看文件系统类型
[root@server0 ~]# df -h
[root@server0 ~]# xfs_growfs /dev/systemvg/vo
[root@server0 ~]# df -h
2.卷组没有足够的剩余空间
1)扩展卷组空间
[root@server0 ~]# vgextend systemvg /dev/vdc[2-3]
[root@server0 ~]# vgs
2)扩展逻辑卷空间
[root@server0 ~]# lvextend -L 25G /dev/systemvg/vo
[root@server0 ~]# lvs
[root@server0 ~]# df -h
3)扩展逻辑卷文件系统
扩展xfs文件系统: xfs_growfs
扩展ext4文件系统:resize2fs
[root@server0 ~]# blkid /dev/systemvg/vo #查看文件系统类型
[root@server0 ~]# df -h
[root@server0 ~]# xfs_growfs /dev/systemvg/vo
[root@server0 ~]# df -h
卷组划分空间的单位 PE
[root@server0 ~]# vgdisplay systemvg #查看卷组详细信息
PE Size 4.00 MiB
请创建一个250M大小的逻辑卷名为redhat
[root@server0 ~]# vgchange -s 1M systemvg #修改PE的大小
Volume group "systemvg" successfully changed
[root@server0 ~]# vgdisplay systemvg
[root@server0 ~]# lvcreate -L 250M -n redhat systemvg
[root@server0 ~]# lvs
请创建一个大小为500个PE的逻辑卷lvtest02
-l:指定PE的个数
[root@server0 ~]# lvcreate -l 500 -n lvtest02 systemvg
[root@server0 ~]# lvs
删除逻辑卷:
优先删除逻辑卷本身,然后在删除卷组,最后删除物理卷
删除卷组时,前提基于该卷组的所有逻辑卷都要删除。
删除逻辑卷时不能删除正在使用的逻辑卷
[root@server0 ~]# lvremove /dev/systemvg/redhat
Do you really want to remove active logical volume redhat? [y/n]: y
Logical volume "redhat" successfully removed
[root@server0 ~]# lvs
二.find高级使用
格式: find [目录] [条件1]
– 常用条件表示:
-type 类型(f文件、d目录、l快捷方式)
-name "文档名称"
-size +|-文件大小(k、M、G)
-user 用户名
-mtime 根据文件修改时间
eg:
-type 类型(f文件、d目录、l快捷方式)
-name "文档名称"
[root@server0 ~]# find /boot/ -type l
[root@server0 ~]# ls /boot/grub/menu.lst
[root@server0 ~]# find /boot/ -type d
[root@server0 ~]# find /boot/ -type f
[root@server0 ~]# find /etc/ -name "passwd"
[root@server0 ~]# find /etc/ -name "*tab"
[root@server0 ~]# find /etc/ -name "*tab*"
[root@server0 ~]# mkdir /root/nsd1911
[root@server0 ~]# touch /root/nsd01.txt
[root@server0 ~]# touch /root/nsd02.txt
[root@server0 ~]# find /root/ -name "nsd*"
[root@server0 ~]# find /root/ -name "nsd*" -a -type f
[root@server0 ~]# find /root/ -name "nsd*" -a -type d
[root@server0 ~]# find /root/ -name "nsd*" -type d
########################################################
-size +或-文件大小(k、M、G)
-user 用户名 #按照所有者进行查找
[root@server0 ~]# find /boot/ -size +10M
[root@server0 ~]# find /boot/ -size -10M
[root@server0 ~]# find /boot/ -size +300k
[root@server0 ~]# find /boot/ -size +1M
[root@server0 ~]# find /home/ -user student
[root@server0 ~]# find / -user student
/proc:不占用磁盘空间,反映内存数据
##########################################################
-mtime 根据文件修改时间,所有的时间表示的为过去时间
-mtime +10 #查找10天之前的数据
-mtime -10 #查找最近10天之内的数据
[root@server0 ~]# find /root/ -mtime +1000
[root@server0 ~]# find /root/ -mtime -10
[root@server0 ~]# find /root/ -mtime +90 #三个月之前
##########################################################
find扩展使用,处理find查询的结果
• 使用find命令的 -exec 操作
– find .. .. -exec 处理命令 {} \;
– 优势:以 {} 代替每一个结果,逐个处理,遇 \; 结束
]# find /boot/ -size +10M
]# find /boot/ -size +10M -exec cp {} /opt \;
]# ls /opt/
]# find /etc/ -name "*tab"
]# find /etc/ -name "*tab" -exec cp {} /opt \;
]# ls /opt/
案例4:查找并处理文件
• 使用find命令完成以下任务
– 找出所有用户 student 拥有的文件
– 把它们拷贝到 /root/findfiles/ 文件夹中
]# mkdir /root/findfiles
]# find / -user student -type f
]# find / -user student -type f -exec cp {} /root/findfiles/ \;
]# ls -A /root/findfiles/
三.NTP网络时间
– NTP服务器为客户机提供标准时间
– NTP客户机需要与NTP服务器保持沟通
RHEL7客户端的校时服务
– 软件包:chrony
– 配置文件:/etc/chrony.conf
– 系统服务:chronyd
1.安装软件包:chrony
[root@server0 ~]# rpm -q chrony
chrony-1.29.1-1.el7.x86_64
[root@server0 ~]#
2.修改配置文件,指定NTP服务端
[root@server0 ~]# vim /etc/chrony.conf
#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
server classroom.example.com iburst #指定服务端
3.重起服务(重起程序)
[root@server0 ~]# systemctl restart chronyd #重起chronyd服务
[root@server0 ~]# systemctl enable chronyd #设置开机自启动
4.测试
[root@server0 ~]# date
[root@server0 ~]# date -s "2000-1-1"
[root@server0 ~]# date
[root@server0 ~]# systemctl restart chronyd
[root@server0 ~]# date
[root@server0 ~]# date
[root@server0 ~]# date #不停刷新date