歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Solaris ZFS文件系統實例配置

Solaris ZFS文件系統實例配置

日期:2017/2/28 14:45:22   编辑:Linux教程

ZFS文件系統是Solaris 10的重要特性,實例配置可以更容量的了解ZFS文件系統配置。

一、Solaris磁盤基礎
1. 磁盤查看方法
# format
AVAILABLE DISK SELECTIONS:
0. c0d1 <xxx cyl 6524 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@7,1/ide@1/cmdk@1,0
1. c1t0d0 <VMware,-VMwareVirtualS-1.0 cyl 1302 alt 2 hd 255 sec 63>
/pci@0,0/pci15ad,1976@10/sd@0,0
2. c1t1d0 <VMware,-VMware Virtual S-1.0-10.00GB>
/pci@0,0/pci15ad,1976@10/sd@1,0
3. c1t2d0 <VMware,-VMware Virtual -1.0 cyl 1303 alt 2 hd 255 sec 63>
/pci@0,0/pci15ad,1976@10/sd@2,0
4. c1t3d0 <VMware,-VMware Virtual S-1.0-10.00GB>
/pci@0,0/pci15ad,1976@10/sd@3,0
Specify disk (enter its number): 3
# quit 退出

2. 磁盤容量查看方法
# iostat -E

二、ZFS文件系統配置
1. 創建zpool(raid0)
創建名為first的zfs文件系統
# zpool create -f first c1t0d0 c1t1d0 c1t2d0
'first' successfully created, but with no redundancy; failure of one
device will cause loss of the pool
說明:
# 提示三塊盤沒有做冗余,壞一盤全壞。
# 加入pool的硬盤是整塊盤,這樣便於pool對硬盤的管理。
# 由於加入pool的磁盤之前曾經使用過ufs,所以在創建過程中需要使用-f選項來忽視ufs文件格式將硬盤強制加入pool中。

對pool進行擴容
# zpool add first c1t3d0
-n 模擬擴容之後結果
-f 強制執行
# zpool add -n -f first c1t3d0
would update 'first' to the following configuration:
first
c1t0d0
c1t1d0
c1t3d0

2. 創建鏡像pool,通常兩塊盤一樣大小容(raid1)
# zpool create -f first mirror c1t0d0 c1t1d0

3. 創建mirror pool(raid 10)
# zpool create -f first mirror c1t0d0 c1t1d0 mirror c1t2d0 c1t3d0

4. 創建raidz zpool (raid5)
# zpool create first raidz2 c1t0d0 c1t1d0 c1t2d0 c1t3d0

5. 創建raidz zpool並加入一塊熱備盤
# zpool create first raidz2 c1t0d0 c1t1d0 c1t2d0 spare c1t3d0
(1)熱備盤的添加
# zpool add first spare c1t3d0
(2)熱備盤的刪除
# zpool remove first c1t3d0

6. 鏡像和拆鏡像
(1) 創建鏡像
如果創建zpool時,物理盤為單,可以對其進行鏡像,命令格式為
# zpool attach first 老的磁盤 新的磁盤
# zpool attach first c1t0d0 c1t1d0
(2) 拆分鏡像(與境像過程相反,因為影響數據)
# zpool detach first c1t1d0

7. 刪除zpool
# zpool destroy poolname
# zpool destroy -f poolname

8. 查看zpool列表,狀態
# zpool list
# zpool status [-x][-v]
# 校驗的目的
# zpool scrub poolname
# 校驗的目的,這一般會花費很長的時間,
# zpool status 查看校驗進度,最好在硬件出現問題,解決後都校驗一次以保證一切正常。

9. 創建一個文件系統

經典使用示例
1) 創建u01文件系統
# zfs create first/u01
2) 掛載到/u01目錄,不掛載也可以直接使用
# zfs set mountpoint=/u01 first/u01
3) 設置磁盤配額
# zfs set quota=20G first/u01

創建快照
1) 創建快照
# zfs snapshot first/u01@ok
2) 恢復快照
# zfs rollback first/u01@ok
3) 刪除快照及ZFS文件系統
說明:刪除u01的快照時,加-R參數連同源一起刪除,慎用。
# zfs destroy -R first/u01@ok

創建ZFS克隆:
通過快照創建zfs目錄
# zfs clone first/u01@ok first/bak

Copyright © Linux教程網 All Rights Reserved