1、圖形添加一個80G的硬盤
[root@server0 ~]# lsblk
[root@server0 ~]# fdisk /dev/vdc #劃分三個主分區,兩個邏輯分區
p 查看分區表
n 創建主分區----->回車----->回車---->回車----->在last結束時 +10G
n 創建主分區----->回車----->回車---->回車----->在last結束時 +10G
n 創建主分區----->回車----->回車---->回車----->在last結束時 +10G
p 查看分區表
n 創建擴展分區
----->回車---->起始回車----->結束回車 將所有空間給擴展分區
p 查看分區表
n 創建邏輯分區----->起始回車------>結束+10G
n 創建邏輯分區----->起始回車------>結束+10G
p 查看分區表
w 保存並退出
[root@server0 ~]# lsblk
2、邏輯卷
1.整合分散的空間 2.空間可以擴展
邏輯卷建立:
將衆多的物理卷(PV)組建成卷組(VG),再從卷組中劃分出邏輯卷(LV)
一、創建邏輯卷
successfully 成功
1.創建卷組
命令格式:vgcreate 卷組名 設備路徑.......
[root@server0 ~]# vgcreate systemvg /dev/vdb /dev/vdc1
[root@server0 ~]# pvs #查看物理卷信息
[root@server0 ~]# vgs #查看卷組信息
2.創建邏輯卷
命令格式:lvcreate -L 邏輯卷大小 -n 邏輯卷名 卷組名
* [root@server0 ~]# vgs #查看卷組信息
* [root@server0 ~]# lvcreate -L 16G -n mylv systemvg
* Logical volume "mylv" created
* [root@server0 ~]# lvs #查看邏輯卷信息
* [root@server0 ~]# vgs #查看卷組信息
3.使用邏輯卷
* [root@server0 ~]# ls /dev/systemvg/mylv #查看邏輯卷設備路徑
* [root@server0 ~]# ls -l /dev/systemvg/mylv
* [root@server0 ~]# mkfs.xfs /dev/systemvg/mylv #格式化文件系統
* [root@server0 ~]# blkid /dev/systemvg/mylv
* [root@server0 ~]# vim /etc/fstab
* /dev/systemvg/mylv /nsd xfs defaults 0 0
* [root@server0 ~]# mkdir /nsd
* [root@server0 ~]# mount -a
* [root@server0 ~]# df -h
二、邏輯卷的擴展
1.卷組有足夠的剩餘空間
1)擴展邏輯卷空間
[root@server0 ~]# vgs
[root@server0 ~]# lvs
[root@server0 ~]# lvextend -L 18G /dev/systemvg/mylv
[root@server0 ~]# lvs
[root@server0 ~]# df -h
2)擴展文件系統
xfs文件系統:xfs_growfs
ext4文件系統:resize2fs
* [root@server0 ~]# df -h
* [root@server0 ~]# xfs_growfs /dev/systemvg/mylv
* [root@server0 ~]# df -h
2.卷組沒有足夠的剩餘空間
1)擴展卷組空間
[root@server0 ~]# vgextend systemvg /dev/vdc2
[root@server0 ~]# vgs
[root@server0 ~]# vgextend systemvg /dev/vdc3
[root@server0 ~]# vgs
2)擴展邏輯卷空間
* [root@server0 ~]# vgs
* [root@server0 ~]# lvs
* [root@server0 ~]# lvextend -L 25G /dev/systemvg/mylv
* [root@server0 ~]# lvs
* [root@server0 ~]# df -h
*
3)擴展文件系統
* [root@server0 ~]# df -h
* [root@server0 ~]# xfs_growfs /dev/systemvg/mylv
* [root@server0 ~]# df -h
補充:邏輯卷也可以支持縮小
xfs文件系統,不支持縮小
ext4文件系統,支持縮小
卷組劃分空間的單位:PE 默認大小 4M
* [root@server0 ~]# vgdisplay systemvg #查看卷組的詳細信息
PE Size 4.00 MiB
請劃分一個大小爲250M的邏輯卷爲lvredhat
[root@server0 ~]# vgchange -s 1M systemvg #修改PE大小
Volume group "systemvg" successfully changed
[root@server0 ~]# vgdisplay systemvg #顯示卷組的詳細信息
PE Size 1.00 MiB
[root@server0 ~]# lvcreate -L 250M -n lvredhat systemvg
Logical volume "lvtest" created
[root@server0 ~]# lvs
• 創建卷組的時候設置PE大小
– vgcreate -s PE大小 卷組名 空閒分區...
• 創建邏輯卷的時候指定PE個數
– lvcreate -l PE個數 -n 邏輯卷名 卷組名
邏輯卷的刪除
首先刪除邏輯卷本身,然後再刪除卷組,最後刪除物理卷
[root@server0 ~]# lvremove /dev/systemvg/lvredhat
Do you really want to remove active logical volume lvredhat? [y/n]: y
Logical volume "lvredhat" successfully removed
[root@server0 ~]# lvs
**find高級使用,查找數據所在的位置**
** 查找文件**
• 根據預設的條件遞歸查找對應的文件
– find [目錄] [條件1] [-a|-o] [條件2] ...
– 常用條件表示:
-type 類型(f文件、d目錄、l快捷方式)
-name "文檔名稱"
-size +|-文件大小(k、M、G)
-user 用戶名
-mtime 根據文件修改時間
[root@server0 ~]# find /boot/ -type l #查找是快捷方式
/boot/grub/menu.lst
[root@server0 ~]# ls /boot/grub/menu.lst
[root@server0 ~]# find /boot/ -type f #查找是文本文件
[root@server0 ~]# find /boot/ -type d #查找是目錄
/proc:反映內存的數據,不佔用磁盤空間
-mtime 根據文件修改時間 都是過去時間
-mtime +10 #10天之前數據
-mtime -10 #最近10天之內數據
[root@server0 ~]# find /root/ -mtime -2
[root@server0 ~]# find /root/ -mtime +10
[root@server0 ~]# find /var/ -mtime +90
find擴展使用
• 使用find命令的 -exec 操作
– find .. .. -exec 處理命令 {} \;
– 優勢:以 {} 代替每一個結果,逐個處理,遇 \; 結束
NTP網絡時間協議
• Network Time Protocol
– NTP服務器爲客戶機提供標準時間
– NTP客戶機需要與NTP服務器保持溝通
NTP服務器:虛擬機cla***oom
NTP客戶機:虛擬機server,指定服務端位置
1.安裝chrony軟件,與NTP服務器溝通的軟件
[root@server0 ~]# rpm -q chrony
chrony-1.29.1-1.el7.x86_64
** 2.修改配置文件**
[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 cla***oom.example.com iburst #指定服務器位置
3.重新啓動程序(重起服務)
[root@server0 ~]# systemctl restart chronyd #重新啓動服務
[root@server0 ~]# systemctl enable chronyd #設置開機自啓動
Set UID
• 附加在屬主的 x 位上
– 屬主的權限標識會變爲 s
– 適用於可執行文件,Set UID可以讓使用者具有文件屬主的身份及部分權限
* [root@server0 ~]# /usr/bin/mkdir /mnt/test01
* [root@server0 ~]# ls /mnt/
* [root@server0 ~]# cp /usr/bin/mkdir /usr/bin/hahadir
* [root@server0 ~]# ls /usr/bin/hahadir
* [root@server0 ~]# /usr/bin/hahadir /mnt/test02
* [root@server0 ~]# ls /mnt/
* [root@server0 ~]# chmod u+s /usr/bin/hahadir #賦予Set UID
* [root@server0 ~]# ls -l /usr/bin/hahadir
* [root@server0 ~]# su - student
* [student@server0 ~]$ /usr/bin/mkdir abc01
* [student@server0 ~]$ ls -l
* [student@server0 ~]$ /usr/bin/hahadir abc02
* [student@server0 ~]$ ls -l