# Dell EMC Unity VSA - Part3: 建立存儲空間
###### tags: `dellemc` `unity`
使用 Unisphere CLI 設定 UnityVSA 的存儲池及 VMware 資料存放區
[toc]
# 管理存取主機
這裡以建立單一 ESXi 主機作為範例。其他類型主機的應用應該大同小異。
## 建立 ESXi 主機
使用以下命令完成。
```bash
esxi01='esxi01.metaage.lab'
esxi01_descr='LAB ESXi 01 '
esxi_user='root'
esxi_pass='VMware1!VMware1!'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/esx create -addr ${esxi01} -username ${esxi_user} -passwd ${esxi_pass} -descr "${esxi01_descr}"
```
使用以下命令可以查詢加入的 ESXi 主機。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/esx -id ${esxi01_id} show
1: ID = Host_1
Name = esxi01.metaage.lab
vCenter = Not managed by a vCenter
Address = esxi01.metaage.lab
Port = 443
```
從 Unisphere GUI 界面 **ACCESS** > **VMware** > **ESXi Hosts** 也可以檢視相關清單。

## 刪除 ESXi 主機
後續我們將使用 vCenter Server 加入 ESXi 主機。所以以指定的 ESXi 主機識別編號進行刪除。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/esx -id Host_1 delete
```
## 建立 vCenter
在 Unisphere GUI 建立 vCenter 主機的步驟 **ACCESS** > **VMware** > **vCenters**,需要點擊 **`Find`** 探索管理的 ESXi 主機,並選擇要加入的 ESXi 主機後才能進行後續步驟。

使用以下命令就可以探索指定 vCenter 主機(尚未加入)下所管理的 ESXi 主機。
```bash
vcsa01='vcsa01.metaage.lab'
vcsa01_user='administrator@vsphere.local'
vcsa01_pass='VMware1!VMware1!'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/esx discover -vcAddr ${vcsa01} -username ${vcsa01_user} -passwd ${vcsa01_pass}
1: Name = esxi01.metaage.lab
2: Name = esxi02.metaage.lab
Operation completed successfully.
```
既然都要加入 vCenter 管理服務了,自動加入所有已發現的 ESXi 主機吧!
加上 **`-createAll`** 參數就可以了。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/esx discover -vcAddr ${vcsa01} -username ${vcsa01_user} -passwd ${vcsa01_pass} -createAll
```
建立完成後,使用以下命令查詢 vCenter 主機資訊。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/vc show -detail
1: ID = mss_8
Address = vcsa01.metaage.lab
Description =
VASA provider state = Not registered
```
使用以下命令查詢加入的 ESXi 主機。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/esx show -detail
1: ID = Host_2
Name = esxi01.metaage.lab
vCenter = mss_8
Address = vcsa01.metaage.lab
Port = 443
Description =
NFSv4 supported = yes
NFS username =
2: ID = Host_3
Name = esxi02.metaage.lab
vCenter = mss_8
Address = vcsa01.metaage.lab
Port = 443
Description =
NFSv4 supported = yes
NFS username =
```
從 Unisphere UI 界面 **ACCESS** > **VMware** > **vCenters**,可顯示加入的 vCenter 主機清單。

從 Unisphere UI 界面 **ACCESS** > **VMware** > **ESXi Hosts**,可顯示加入的 ESXi 主機清單。

### 特殊狀況
如果在新增 vCenter 主機時並未探索並加入所管理的 ESXi 主機,在 Unisphere UI 界面 **ACCESS** > **VMware** > **vCenters**,選擇指定的 vCenter 主機,之後選擇 **More Actions** > **Find ESXi Hosts** 便可處理。
當然,使用以下等效命令也可達成相同目標。
```bash
## 僅新增 vCenter 主機
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/vc create -addr ${vcsa} -username ${vcsa_user} -passwd ${vcsa_pass}
ID = mss_10
Operation completed successfully.
## 探索管理的 ESXi 主機
vcsa_id='mss_10'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/esx discover -vc ${vcsa_id}
1: Name = 10.7.150.5
2: Name = 10.7.150.2
3: Name = 10.7.150.3
## 新增探索到的 ESXi 主機
hosts=('10.7.150.2' '10.7.150.3' '10.7.150.5')
for host in ${hosts[@]}; do
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/esx create -addr ${host} -vc ${vcsa_id} -resolveConflicts yes
done
ID = Host_4
Operation completed successfully.
ID = Host_5
Operation completed successfully.
ID = Host_6
Operation completed successfully.
```
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/esx -vc ${vcsa_id} show 1 ↵
1: ID = Host_4
Name = 10.7.150.2
vCenter = mss_10
Address = vcsa67.sysagelab.com
Port = 443
2: ID = Host_5
Name = 10.7.150.3
vCenter = mss_10
Address = vcsa67.sysagelab.com
Port = 443
3: ID = Host_6
Name = 10.7.150.5
vCenter = mss_10
Address = vcsa67.sysagelab.com
Port = 443
```
從 Unisphere UI 界面可檢視相關狀態。


## 其他
- 若要調整 vCenter 或 ESXi 主機的說明描述或認證資訊,使用以下命令完成。
```bash
## 編輯 vCenter 說明
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/vc -id mss_8 set -descr "LAB X - vCSA01"
ID = mss_8
Operation completed successfully.
## 編輯 ESXi 說明
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/esx -id Host_2 set -descr "LAB X - ESXi1"
ID = Host_2
Operation completed successfully.
```
- 若要刪除 vCenter 主機紀錄,使用以下命令完成。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/vc -id ${vcsa01_id} delete
```
- 若要重新掃描所有已配置的 vCenter 主機詳細資訊,可使用以下命令完成。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /virt/vmw/vc refresh [-scanHardware]
```
- 完成以下主機配置
- 名稱: MyHost
- 描述: Work VM for TEST
- IP 位址: 10.7.155.101
- 作業系統: other(Photon OS)
```bash
host_name='MyHost'
host_descr='Work VM for TEST'
host_ip='10.7.155.101'
host_os='other'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /remote/host create -name ${host_name} -descr ${host_descr} -type host -addr ${host_ip} -osType ${host_os}
ID = Host_7
Operation completed successfully.
```
顯示新建的主機資訊。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /remote/host -name ${host_name} show
1: ID = Host_7
Name = MyHost
Description = Work VM for TEST
Type = host
Address = 10.7.155.101
Netmask =
OS type = Other
Ignored address =
Host group =
Health state = OK (5)
Health details = "The component is operating normally. No action is required."
```

# 管理磁碟
## 新增虛擬磁碟
透過 GOVC 可以輕鬆地在 UnityVSA 虛擬設備中增加虛擬磁碟。
這個技巧在 [Dell EMC Unity VSA - Part2: 初始化組態](https://hackmd.io/vGLsjWoGRwiQfeZXZTVkIw#建立-2-組虛擬磁碟作為存儲空間) 和 [Dell EMC Unity VSA - Part3: 系統管理](https://hackmd.io/kV0m0FweRESnzge-J3SRcw#管理磁碟) 中已經使用過了!這裡再建立 3 組虛擬磁碟,並進階完成後續配置,以便建立另一個存儲池。
使用以下命令完成。
```bash
unityVm='Richard-dellemc-UnityVSA01'
disks=('vDisk3' 'vDisk4' 'vDisk5')
diskCount=${#disks[@]}
diskSize=100
for ((i=0;i<${diskCount};i++)); do
govc vm.disk.create -vm ${unityVm} -name ${unityVm}/${disks[$i]} -size ${diskSize}G
done
```
檢視建立的虛擬磁碟狀態。
```bash
$ uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /env/disk -unused show
1: ID = vdisk_3
SCSI ID = 0:5
Health state = OK (5)
Tier =
User capacity = 107373002752 (99.9G)
Pool ID = Unconfigured
Pool = Unconfigured
2: ID = vdisk_4
SCSI ID = 0:6
Health state = OK (5)
Tier =
User capacity = 107373002752 (99.9G)
Pool ID = Unconfigured
Pool = Unconfigured
3: ID = vdisk_5
SCSI ID = 0:8
Health state = OK (5)
Tier =
User capacity = 107373002752 (99.9G)
Pool ID = Unconfigured
Pool = Unconfigured
```
在 UnityVSA 佈署完成後,已經陸續透過 `uemcli` 命令建立了 5 組 100 GB 的虛擬磁碟。從 vSphere Web Clinet 可以檢視相關組態。

從 Unisphere UI 的 **System** > **System View** > **Virtual** 可檢視磁碟狀態。

## 變更磁碟設定
新增虛擬磁碟後,在 UnityVSA 中必須對於每個虛擬磁碟給定**存儲層級(Storage Tier)**。在實體 Unity 設備佈署,則以實際磁碟類型自動進行層級給定。
存儲層級分為 3 種級別:
- **Extreme Performance**: Flash
- **Performance**: SSD
- **Capacity**: NL-SAS
:::warning
**注意**
- 變更磁碟設定需指定**磁碟識別碼(ID)**。
- **沒有層級(Tier)的磁碟無法用於存儲池配置**。加入存儲池的磁碟必須先指定層級,否則無法添加成功。
- 這裡層級的配置並無實質的意義,只是為了配置不同存儲等級,了解其層級使用狀態(Fast VP)。
:::
使用以下命令分別將 3 組虛擬磁碟完成設定。
| Disk_ID | Tier |
| --- | --- |
| vdisk_3 | Capacity |
| vdisk_4 | Performance |
| vdisk_5 | Extreme (Performance) |
```bash!
diskTier=('capacity' 'performance' 'extreme')
diskId=('vdisk_3' 'vdisk_4' 'vdisk_5')
diskCount=${#diskId[@]}
for ((i=0;i<${diskCount};i++)); do
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /env/disk -id ${diskId[$i]} set -tier ${diskTier[$i]}
done
```
檢視(未使用 unused)磁碟的層級設定。
```bash!
$ uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /env/disk -unused show
1: ID = vdisk_3
SCSI ID = 0:5
Health state = OK (5)
Tier = Capacity
User capacity = 107373002752 (99.9G)
Pool ID = Unconfigured
Pool = Unconfigured
2: ID = vdisk_4
SCSI ID = 0:6
Health state = OK (5)
Tier = Performance
User capacity = 107373002752 (99.9G)
Pool ID = Unconfigured
Pool = Unconfigured
3: ID = vdisk_5
SCSI ID = 0:8
Health state = OK (5)
Tier = Extreme Performance
User capacity = 107373002752 (99.9G)
Pool ID = Unconfigured
Pool = Unconfigured
```

# 管理存儲池
## 建立存儲池
UnityVSA 屬於**虛擬佈署設備,存儲池僅支援傳統模式(Tranditional Pool),並不支援動態模式(Dynamic Pool)**。
使用以下命令,將 3 組虛擬磁碟加入至存儲池 **vPool_02**。
```bash
diskId=('vdisk_3' 'vdisk_4' 'vdisk_5')
diskCount=${#diskId[@]}
pool_name='vPool_02'
pool_descr='Virtual Pool 2'
pool_disk=$(echo ${diskId[@]} | sed 's/ /,/g')
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/config/pool create -name ${pool_name} -descr "${pool_descr}" -disk ${pool_disk}
```
從 Unisphere UI 也可檢視出相同結果。且在右側顯示該存儲池包含 **3 組磁碟(Drives)**,而且剛好這 3 組磁碟各組態成 1 種存儲層級,所以該存儲池包含 **3 種存儲層級(Tier)**。

:::warning
因為 UnityVSA 屬於虛擬設備,對於實體 Unity 設備建立動態存儲池(Dynamic Pool)時,需要帶入**磁碟群組(drive group)**及**存儲配置文件(Storage Profile:RAID Type)**。
所以在實體 Unity 設備環境下建立存儲池前,請先使用以下命令確認相關資訊。
- **`/stor/config/profile show`** 顯示存儲配置文件。
- **`/stor/config/dg show`** 顯示磁碟群組。
以下是使用存儲配置文件 `profile_1`, `profile_2` 和磁碟群組 `dg_2` 中的 6 組磁碟及磁碟群組 `dg_28` 中的 10 組磁碟,建立一組名為 `MyPool` 動態儲存池的範例命令:
```bash
uemcli -d 10.0.0.1 -u admin -p MyPassword456! /stor/config/pool create -name MyPool -descr"dynamic pool" -diskGroup dg_2,dg_28 -drivesNumber 6,10 -storProfile profile_1,profile_2 -type dynamic -hotSpareCapacity 1,2
```
- 虛擬設備使用的是 `-disk`,實體設備則是使用 `-diskGroup`,並要加上 `-drivesNumber` 參數指定加入磁碟數量。
- 另外指定 `-drivesNumber` 時需要配合 `-storProfile` 存儲配置文件(Storage Profile)中 RAID 配置,否則操作有可能失敗。若沒有指定存儲配置文件,則使用預設 RAID 配置。
- NL-SAS: RAID 6 with strip length: 8
- SAS: RAID 5 with strip length: 5
- Flash: RAID 5 with strip length: 5
- 在支援動態存儲池設備上需要建立傳統存儲池,上述命令可修正參數 **`-type traditional`** 建立傳統存儲池。不過,目前已經都建議客戶採用**動態存儲池**。
- `-hotSpareCapacity` 是搭配動態存儲池使用的參數。另外該配置也用於層級(Tier),所以相同層級的磁碟群組將會共用熱備援空間?
:::
## 擴展存儲池磁碟
再次使用 GOVC 添加 2 組 100GB 虛擬磁碟至 UnityVSA 虛擬設備中。
```bash
unityVm='Richard-dellemc-UnityVSA01'
disks=('vDisk6' 'vDisk7')
diskCount=${#disks[@]}
diskSize=100
for ((i=0;i<${diskCount};i++)); do
govc vm.disk.create -vm ${unityVm} -name ${unityVm}/${disks[$i]} -size ${diskSize}G
done
```
確認添加的虛擬磁碟狀態。
```bash
$ uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /env/disk -unused show
1: ID = vdisk_6
SCSI ID = 0:9
Health state = OK (5)
Tier =
User capacity = 107373002752 (99.9G)
Pool ID = Unconfigured
Pool = Unconfigured
2: ID = vdisk_7
SCSI ID = 0:10
Health state = OK (5)
Tier =
User capacity = 107373002752 (99.9G)
Pool ID = Unconfigured
Pool = Unconfigured
```

確認要添置的存儲池的識別碼(ID)。預計目標存儲池為 **`vPool_2`**,其識別碼為 **`pool_2`**。目前**組成磁碟為 3 顆**。
```bash!
$ uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/config/pool -id pool_2 show
1: ID = pool_2
Name = vPool_02
Total space = 319438192640 (297.5G)
Remaining space = 319438192640 (297.5G)
Flash percent = 33%
Subscription percent = 0%
Number of drives = 3
RAID level =
Stripe length =
Rebalancing = no
Health state = OK (5)
Protection size used = 0
Non-base size used = 0
```
使用以下命令添加磁碟至指定存儲池 **vPool_02**。**注意**,這裡添加虛擬磁碟至群組的同時,一併給定存儲層級以簡化操作流程。
```bash!
diskTier=('capacity' 'performance')
diskId=('vdisk_6' 'vdisk_7')
pool_name='vPool_02'
pool_id='pool_2'
## vdisk_6 -> performance
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/config/pool -id ${pool_id} extend -disk ${diskId[0]} -tier ${diskTier[1]}
## vdisk_7 -> capacity
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/config/pool -id ${pool_id} extend -disk ${diskId[1]} -tier ${diskTier[0]}
```
查看添加完成後的存儲池狀態。目前**組成磁碟數量為 5 顆**。
```bash!
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/config/pool -id pool_2 show -detail
1: ID = pool_2
Name = vPool_02
Description = Virtual Pool 2
Total space = 532575944704 (496.0G)
Current allocation = 0
Preallocated = 0
Remaining space = 532575944704 (496.0G)
Subscription = 0
Flash percent = 19%
Subscription percent = 0%
Alert threshold = 70%
Drives = 1 x 100.0G Virtual; 1 x 100.0G Virtual; 1 x 100.0G Virtual; 1 x 100.0G Virtual; 1 x 100.0G Virtual
Number of drives = 5
RAID level =
Stripe length =
Rebalancing = no
Rebalancing progress =
Health state = OK (5)
Health details = "The component is operating normally. No action is required."
Protection size used = 0
Non-base size used = 0
Auto-delete state = Idle
Auto-delete paused = no
Auto-delete pool full threshold enabled = yes
Auto-delete pool full high water mark = 95%
Auto-delete pool full low water mark = 85%
Auto-delete snapshot space used threshold enabled = no
Auto-delete snapshot space used high water mark = 25%
Auto-delete snapshot space used low water mark = 20%
Data Reduction space saved = 0
Data Reduction Percent = 0%
Data Reduction Ratio = 1.00:1
All flash pool = no
```
從 Unisphere UI 中的磁碟檢視可以查看所屬存儲池。

選定存儲池後,也可檢視所包含的磁碟組成。

:::info
無法直接從存儲池中移除指定(已使用)的磁碟,只能直接刪除存儲池。
:::
# 管理 LUN
LUN 是存儲系統的單個存儲單元,用以表示 Fibre Channel(FC) 或 iSCSI 存儲的特定存儲池和數量。每個 LUN 皆與名稱和邏輯單元號碼識別(logical unit number identifier, LUN ID)相關聯。
建立 LUN 之前,必須先進行存儲池配置可供使用。
## 建立 LUN
根據以下設定建立 LUN:
- 名稱: MyLUN
- 描述: My First LUN
- 存儲池: vPool
- 空間: 100 MB
使用以下命令建立所設定的 LUN 資源。
```bash!
lun_name='MyLUN'
lun_descr='My First LUN'
lun_type='primary'
lun_size='100M'
lun_thin='yes'
lun_spOwner='spa'
## startHighThenAuto(default), auto, highest, lowest
lun_fastvpPolicy='startHighThenAuto'
lun_host=''
pool_id='pool_1'
pool_name='vPool'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/prov/luns/lun create -name "${lun_name}" -descr "${lun_descr}" -type ${lun_type} -poolName "${pool_name}" -size ${lun_size} -thin ${lun_thin}
```
在 Unisphere UI 中,**STORAGE** > **Blocks** > **LUNs** 檢視建立完成的 LUN。

## 更改 LUN
根據以下設定建立 LUN:
- 名稱: MyTierLUN
- 描述: My First Tier LUN
- 存儲池: vPool_02
- 空間: 100 MB
- Thin: **no**
- SP: SPA
- Fast VP Policy: **highest**
使用以下命令建立所設定的 LUN 資源。
```bash!
lun_name='MyTierLUN'
lun_descr='My First Tier LUN'
lun_type='primary'
lun_size='100M'
lun_thin='no'
lun_spOwner='spa'
## startHighThenAuto(default), auto, highest, lowest
lun_fastvpPolicy='highest'
lun_host=''
pool_id='pool_2'
pool_name='vPool_02'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/prov/luns/lun create -name "${lun_name}" -descr "${lun_descr}" -type ${lun_type} -poolName "${pool_name}" -size ${lun_size} -thin ${lun_thin} -spOwner ${lun_spOwner} -fastvpPolicy ${lun_fastvpPolicy}
```
在 Unisphere UI 中,**STORAGE** > **Blocks** > **LUNs** 檢視建立完成的 LUN。

:::info
**MyTierLUN** 這個 LUN 建立時並沒有啟用 Thin,所以注意 **Allocated(%)** 比例是 **100%**。
:::
將剛剛建立的 LUN `MyTierLUN` 大小改為 **2 GB**,且分層策略調整為 **Auto-Tier**。
```bash
lun_size='2G'
lun_fastvpPolicy='auto'
lun_host='Host_2'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/prov/luns/lun -name "${lun_name}" set -size ${lun_size} -fastvpPolicy ${lun_fastvpPolicy} -lunHosts ${lun_host}
The original lun Host Access will be reset to the new host(s):Host_2 to grant access to.
Do you want to proceed?
yes / no: yes
ID = sv_3
Operation completed successfully.
```


## 刪除 LUN
在刪除 LUN 之前,**必須先將所有具備存取權限的主機資源移除**,才能正常執行刪除作業。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/prov/luns/lun -name "${lun_name}" set -lunHost ''
The original lun Host Access will be reset to the new host(s): to grant access to.
Do you want to proceed?
yes / no: yes
ID = sv_3
Operation completed successfully.
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/prov/luns/lun -name "${lun_name}" delete
Operation completed successfully.
```
# 管理 iSCSI
## 建立 iSCSI 界面
```bash
if_type='iscsi'
if_port='spa_eth0'
if_addr='10.7.155.87'
if_netmask='255.255.255.0'
if_gateway='10.7.155.254'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /net/if create -type ${if_type} -port ${if_port} -addr ${if_addr} -netmask ${if_netmask} -gateway ${if_gateway}
ID = if_3
Operation completed successfully.
```

:::info
另外在研讀文件時,看到 **管理 iSCSI 連結(Manage iSCSI connections)**,這部份應該是應用於存儲設備間的 iSCSI 連線,與一般主機連線並不相同。
並不清楚該如何從 Unisphere GUI 界面執行。若要建立及檢視,可參考以下命令。
```bash
iscsi_connection_name='iscsiConnect1'
iscsi_connection_descr='Connection for MyTierLUN'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /remote/iscsi/connection create -name ${iscsi_connection_name} -descr "${iscsi_connection_descr}"
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /remote/iscsi/connection show
1: ID = iscsiConnection_1
Name = iscsiConnect1
Description = Connection for MyTierLUN
```
:::
# VMware 整合
如果是 VMware 環境,建議可以使用 Unity 提供的整合功能進行存儲空間的設定作業,Unity 會完成所有相關流程,透過與 vCenter 的整合,將 ESXi 主機上的存儲介面卡及設備、存儲路徑和 iSCSI 探索一併完成設定,真的會讓設定管理工作負載降低不少。
VMFS 存儲區以 LUN 形式提供 ESXi 數據存儲使用。ESXi 主機可透過 iSCSI 或 FC 協定與這些 LUN 連接。
## 執行條件
- 完成 vCenter 服務主機加入 [(#管理存取主機)](#管理存取主機)
- 建立存儲池 [(#管理存儲池)](#管理存儲池)
- 建立 iSCSI 界面 [(#建立 iSCSI 界面)](#建立-iSCSI-界面)
## 建立 VMFS 資料存放區
根據以下需求建立 VMFS 資料存放區。
| | |
| --- | --- |
| VMFS 版本(Version) | VMFS6 |
| 名稱(Name) | LAB_Unity_VMFS01 |
| 描述(Description) | VMFS01 via UnityVSA |
| 存儲池(Pool) | vPool_02 |
| 分層政策(Tiering Policy) | startHighThenAuto |
| 容量(Size) | 150G |
| Thin | yes |
| 存取主機(Access Hosts) | Host_4, Host_5 |
```bash!
## VMFS datastore info.
datastore_ver=6
datastore_name="LAB_Unity_VMFS01"
datastore_descr='VMFS01 via UnityVSA'
datastore_type='primary'
datastore_size='150G'
datastore_thin='yes'
datastore_spOwner='spa'
#datastore_replDest='no'
#datastore_dataReduction='no'
#datastore_advencedDedup='no'
## startHighThenAuto(default), auto, highest, lowest
datastore_fastvpPolicy='auto'
datastore_accessHost='Host_4,Host_5'
## Storage pool info.
pool_id='pool_2'
pool_name='vPool_02'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/prov/vmware/vmfs create -name "${datastore_name}" -descr "${datastore_desc}" -poolName "${pool_name}" -size ${datastore_size} -thin ${datastore_thin} -spOwner ${datastore_spOwner} -fastvpPolicy ${datastore_fastvpPolicy} -vdiskHosts "${datastore_accessHost}" -version ${datastore_ver}
ID = res_3
Operation completed successfully.
```
開始執行後,Unity 會連線 vCenter 在允許存取主機上執行一連串動作。
- 新增 iSCSI 靜態目標
- 重新掃描 HBA
- 重新掃描 VMFS
- 重新整理主機儲存區系統
- 建立 VMFS 資料存放區
可從 vSphere Web Client 觀察得知。若是採用一般方式新增資料存放區,管理者就要手動在存取主機上完成這些必要動作。


分別從 ESXi 主機的儲存裝置界面卡和儲存裝置,可以檢視建立的對應資訊。
- 介面卡-靜態探索

- 介面卡-裝置

- 儲存裝置資訊

從資料存放區頁籤,可檢視建立 VMFS 存儲區 `LAb_Unity_VMFS01` 的相關資訊。
- 存放區設定內容

- 存放區已連線主機

## 查看 VMFS 資料存放區
回到 Unisphere GUI 管理界面 **STORAGE** > **VMware** > **Datastores**,可檢視建立的存儲區內容。


使用以下命令檢視 VMFS 存儲區資訊。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/prov/vmware/vmfs show -detail
1: ID = res_3
LUN = sv_9
Name = LAB_Unity_VMFS01
Description = VMFS via UnityVSA
Type = Primary
Base storage resource = res_3
Source =
Original parent =
Health state = OK (5)
Health details = "The component is operating normally. No action is required."
Storage pool ID = pool_2
Storage pool = vPool_02
Size = 161061273600 (150.0G)
Maximum size = 4398046511104 (4.0T)
Thin provisioning enabled = yes
Data Reduction enabled = no
Data Reduction space saved = 0
Data Reduction percent = 0%
Data Reduction ratio = 1.00:1
Advanced deduplication enabled = no
Current allocation = 46530560 (44.3M)
Preallocated = 2369388544 (2.2G)
Total Pool Space Used = 3804626944 (3.5G)
Protection size used = 0
Non-base size used = 0
Family size used = 3804626944 (3.5G)
Snapshot count = 0
Family snapshot count = 0
Family thin clone count = 0
Protection schedule =
Protection schedule paused =
SP owner = SPA
Trespassed = no
Version = 6
Block size =
Virtual disk access hosts = Host_4, Host_5
Host LUN IDs = 0, 0
Snapshots access hosts =
WWN = 60:06:01:60:C1:50:20:2D:AA:E6:59:63:86:75:94:F7
Replication destination = no
Creation time = 2022-10-27 02:02:17
Last modified time = 2022-10-27 02:02:17
FAST VP policy = Auto-tier
FAST VP distribution = Extreme Performance: 61%, Performance: 0%, Capacity: 39%
IO limit =
Effective maximum IOPS = N/A
Effective maximum KBPS = N/A
```
:::warning
由 VMware 整合方式建立的 LUN,並不會顯示在 **STORAGE** > **Block** > **LUNs**。

:::
## 更新 VMFS 資料存放區
使用以下命令增加 3 部 ESXi 存取主機。
```bash
datastore_id='res_3'
access_Hosts='Host_2,Host_3,Host_4,Host_5,Host_6'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/prov/vmware/vmfs -id ${datastore_id} set -vdiskHosts "${access_Hosts}"
The original VMware VMFS Datastore Host Access will be reset to the new host(s):Host_2,Host_3,Host_4,Host_5,Host_6 to grant access to.
Do you want to proceed?
yes / no: yes
ID = res_3
Operation completed successfully.
```
從 Unisphere GUI 檢視該 VMFS 存儲區的 Host Access 內容。

:::warning
使用 **`-vdiskHosts`** 除了要加入新的主機列表,原有已有存取權限的主機,也必須要同時指定,該參數值為覆蓋選項。
:::
## 刪除 VMFS 資料存放區
若想移除現有的 VMFS 資料存放區,可以使用以下命令達成。
- 首先要移除 ESXi 主機存取權。
```bash!
remove_datastore='unityVSA_150GB'
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/prov/vmware/vmfs -name "${remove_datastore}" set -vdiskHosts ""
The original VMware VMFS Datastore Host Access will be reset to the new host(s): to grant access to.
Do you want to proceed?
yes / no: yes
ID = res_2
Operation completed successfully.
```
- 接著就將資料存放區移除,釋放空間。
```bash
uemcli -sslPolicy accept -noHeader -d ${unity} -u ${admin_user} -p ${admin_new_pass} /stor/prov/vmware/vmfs -name "${remove_datastore}" delete -deleteSnapshots yes
Operation completed successfully.
```
:::info
使用 VMware NFS Datastore 的部份,之後有時間再測試吧。實際應用的機會應該不大!
:::
# 參考
- Dell Unity 資訊中心:產品文件和資訊 [[中文]](https://www.dell.com/support/kbdoc/zh-tw/000126652/dell-emc-unity-%E8%B3%87%E8%A8%8A-%E4%B8%AD%E5%BF%83-%E7%94%A2%E5%93%81-%E6%96%87%E4%BB%B6-%E5%92%8C-%E8%B3%87%E8%A8%8A), [[英文]](https://www.dell.com/support/kbdoc/zh-tw/000126652/dell-emc-unity-info-hub-product-documents-and-information?lang=en)