说明
本文只是陈述了一种方法,不必评判谁对谁错谁好谁坏,选择适合自己的即可。
环境
|----------------|----------------|---------|-----------------------------------------------------------------|-------------|----------------------------------|
| 站点名称 | vCenter版本 | vSAN集群 | 集群主机 | 主机版本 | 磁盘组 |
| vcsa67.lab.com | vCenter 6.7 U3 | cluster | esxi-b1.lab.com esxi-b2.lab.com esxi-b3.lab.com esxi-b4.lab.com | ESXi 6.7 U3 | 每台主机有两个磁盘组 每个磁盘组一个闪存盘 每个磁盘组两个容量盘 |
| vcsa.lab.com | vCenter 7.0 U3 | vsan01 | esxi-a1.lab.com esxi-a2.lab.com esxi-a3.lab.com esxi-a4.lab.com | ESXi 7.0 U3 | 每台主机有两个磁盘组 每个磁盘组一个闪存盘 每个磁盘组两个容量盘 |
内容
本文内容涉及到以下几个部分:
- 将vcsa67站点上ESXi主机从vSAN集群cluster中撤出,并从vCenter中移除
- 在vcsa站点上新建集群vsan02,并将esxi-b1到esxi-b4主机加入该集群
- 将esxi-b1到esxi-b4主机的ESXi版本升级到vcsa站点上的主机版本(ESXi 7.0 U3)
- 在vsan02集群中启用vsan,并申明esxi-b1到esxi-b4主机的vSAN磁盘
过程
一、将vcsa67站点上ESXi主机从vSAN集群cluster中撤出,并从vCenter中移除
注意:集群中不得存在任何虚拟机、文件,已全部迁走。
1.将主机置于维护模式。SSH登录到主机esxi-b1,不迁移数据。
esxcli system maintenanceMode set -e true -m noAction
esxcli system maintenanceMode get

2.删除主机上的vSAN磁盘组。有两种方式,一是根据磁盘组UUID,二是磁盘组名字。
esxcli vsan storage list | grep "VSAN Disk Group UUID"
esxcli vsan storage list | grep "VSAN Disk Group Name"
esxcli vsan storage remove -u "VSAN Disk Group UUID"
esxcli vsan storage remove -s "VSAN Disk Group Name"
esxcli vsan storage list

注:其实 "VSAN Disk Group UUID"和"VSAN Disk Group Name"就是磁盘组中闪存盘的UUID和名字,删除闪存盘就删除了整个磁盘组。
3.将主机退出vSAN群集。
esxcli vsan cluster leave
esxcli vsan cluster get

4.将主机从vCenter中移除。由于该主机的vSAN网络vmkernel适配器创建在分布式交换机vds上,所以先将vmkernel适配器从主机中删除,再将主机从vds中移除,最后再从vCenter中移除。
第一步:删除vmkernel适配器。通过powershell工具连接到vcsa67的vCenter。
Connect-VIServer vcsa67.lab.com -Username administrator@vsphere.local -Password xxxxxxxx //环境中SSO用户名和密码

使用命令删除用于vsan流量的vmkernel适配器
Get-VMHostNetworkAdapter -VMHost esxi-b1.lab.com -PortGroup vsan | Remove-VMHostNetworkAdapter //环境中分布式端口组名字为vsan

第二步:从分布式交换机vds中移除主机。
Remove-VDSwitchVMHost -VDSwitch vds -VMHost esxi-b1.lab.com //环境中分布式交换机名字为vds

第三步:从vCenter中移除主机。
Get-VMHost -Name esxi-b1.lab.com | Remove-VMHost

此时esxi-b1主机已从vSAN集群及vCenter中移除。
按上述方式完成esxi-b2主机到esxi-b4主机的删除过程。本小节完。
二、在vcsa站点上新建集群vsan02,并将esxi-b1到esxi-b4主机加入该集群
1.远程SSH连接到vcsa的vCenter,并登录RVC命令行控制台。
rvc localhost //运行后输入vCenter的sso用户名和密码

2.使用RVC命令cluster.create创建集群vsan02。
cluster.create /localhost/datacenter/computers/vsan02

3.使用RVC命令cluster.add_host将esxi-b1到esxi-b4主机添加到集群vsan02中,主机默认进入维护模式。
cluster.add_host /localhost/datacenter/computers/vsan02/ esxi-b1.lab.com -u root -p xxxxxxxx //ESXi用户名和密码
cluster.add_host /localhost/datacenter/computers/vsan02/ esxi-b2.lab.com -u root -p xxxxxxxx
cluster.add_host /localhost/datacenter/computers/vsan02/ esxi-b3.lab.com -u root -p xxxxxxxx
cluster.add_host /localhost/datacenter/computers/vsan02/ esxi-b4.lab.com -u root -p xxxxxxxx

4.查看所有主机都已经加入集群vsan02成功。本小节完。
ls /localhost/datacenter/computers/vsan02/

三、将esxi-b1到esxi-b4主机的ESXi版本升级到vcsa站点上的主机版本(ESXi 7.0 U3)
ESXi主机升级的方式有多种,比如只有几台或少数主机的情况下,使用esxcli software命令一台一台的升级,如果主机较多的话推荐使用VUM基于基准的方式进行升级,当然仅在6.x及7.x版本中可用,在8.x以后的版本中仅支持vLCM基于单个映像的方式进行主机升级。本环境只有四台主机,所以就采用esxcli software命令进行升级。
VMware ESXi产品升级路径:

1.将升级包上传至esxi-b1主机的本地存储。

2.查看补丁的映像配置文件。
esxcli software sources profile list --depot=/vmfs/volumes/65a744d5-442a4976-59cb-00505687d430/VMware-ESXi-7.0U3o-22348816-depot.zip

3.安装更新ESXi7 U3O。由于环境中的硬件CPU不受支持,所以在命令中加了-f强制更新,--no-hardware-warning忽略硬件警告。(生产环境No!!!)
esxcli software profile update --profile=ESXi-7.0U3o-22348816-standard --depot=/vmfs/volumes/65a744d5-442a4976-59cb-00505687d430/VMware-ESXi-7.0U3o-22348816-depot.zip -f --no-hardware-warning

4.重启主机后,查看版本已经跟新到VMware ESXi 7.0 U3。

5.按上述方式完成esxi-b2到esxi-b4的更新操作。本小节完。
四、在vsan02集群中启用vsan,并申明esxi-b1到esxi-b4主机的vSAN磁盘
1.SSH连接到vCenter,运行RVC管理控制台。
rvc localhost
2.使用vds.create_vds命令创建一个新的分布式交换机vds2。
vds.create_vds localhost/datacenter/networks/vds2

3.使用vds.add_hosts命令将主机加入到vds2分布式交换机,并指定uplink端口为vmnic1。
vds.add_hosts --vmnic=vmnic1 /localhost/datacenter/networks/vds2/ /localhost/datacenter/computers/vsan02/hosts/esxi-b1.lab.com/
vds.add_hosts --vmnic=vmnic1 /localhost/datacenter/networks/vds2/ /localhost/datacenter/computers/vsan02/hosts/esxi-b2.lab.com/
vds.add_hosts --vmnic=vmnic1 /localhost/datacenter/networks/vds2/ /localhost/datacenter/computers/vsan02/hosts/esxi-b3.lab.com/
vds.add_hosts --vmnic=vmnic1 /localhost/datacenter/networks/vds2/ /localhost/datacenter/computers/vsan02/hosts/esxi-b4.lab.com/
4.使用vds.create_portgroup命令创建分布式端口组vsan-pg。
vds.create_portgroup /localhost/datacenter/networks/vds2/ vsan-pg

5.使用vds.create_vmknic命令在分布式端口组vsan-pg中给每台主机创建一个vmkernel端口vmk1,用于主机的vSAN流量端口。
vds.create_vmknic /localhost/datacenter/networks/vds2/portgroups/vsan-pg/ /localhost/datacenter/computers/vsan02/hosts/esxi-b1.lab.com/
vds.create_vmknic /localhost/datacenter/networks/vds2/portgroups/vsan-pg/ /localhost/datacenter/computers/vsan02/hosts/esxi-b2.lab.com/
vds.create_vmknic /localhost/datacenter/networks/vds2/portgroups/vsan-pg/ /localhost/datacenter/computers/vsan02/hosts/esxi-b3.lab.com/
vds.create_vmknic /localhost/datacenter/networks/vds2/portgroups/vsan-pg/ /localhost/datacenter/computers/vsan02/hosts/esxi-b4.lab.com/

6.为了方面,给每台主机对象分别打一个标记。
mark esxib1 /localhost/datacenter/computers/vsan02/hosts/esxi-b1.lab.com/
mark esxib2 /localhost/datacenter/computers/vsan02/hosts/esxi-b2.lab.com/
mark esxib3 /localhost/datacenter/computers/vsan02/hosts/esxi-b3.lab.com/
mark esxib4 /localhost/datacenter/computers/vsan02/hosts/esxi-b4.lab.com/

7.使用rvc esxcli命令查看主机esxib1的接口地址信息。
esxcli ~esxib1 network ip interface ipv4 get

8.使用rvc esxcli命令给所有主机的vmkernel网卡vmk1配置一个静态地址,并查看是否已配置成功。
esxcli ~esxib1 network ip interface ipv4 set -i vmk1 -t static -p 11.1.1.1 -n 255.255.255.0
esxcli ~esxib2 network ip interface ipv4 set -i vmk1 -t static -p 11.1.1.2 -n 255.255.255.0
esxcli ~esxib3 network ip interface ipv4 set -i vmk1 -t static -p 11.1.1.3 -n 255.255.255.0
esxcli ~esxib4 network ip interface ipv4 set -i vmk1 -t static -p 11.1.1.4 -n 255.255.255.0
esxcli ~esxib1 network ip interface ipv4 get
esxcli ~esxib2 network ip interface ipv4 get
esxcli ~esxib3 network ip interface ipv4 get
esxcli ~esxib4 network ip interface ipv4 get
9.使用rvc esxcli命令将所有主机的vmkernel端口vmk1配置为vSAN流量。
esxcli ~esxib1 vsan network ip add -i vmk1
esxcli ~esxib2 vsan network ip add -i vmk1
esxcli ~esxib3 vsan network ip add -i vmk1
esxcli ~esxib4 vsan network ip add -i vmk1
10.使用rvc esxcli命令查看所有主机的vSAN网络。
esxcli ~esxib1 vsan network list
esxcli ~esxib2 vsan network list
esxcli ~esxib3 vsan network list
esxcli ~esxib4 vsan network list
11.使用vsan.enable_vsan_on_cluster命令开启集群vsan02的vSAN功能,并关闭磁盘自动申明。
vsan.enable_vsan_on_cluster /localhost/datacenter/computers/vsan02/ --disable-storage-auto-claim

12.SSH登录到主机esxi-b1上,使用vdq命令查看本机的所有磁盘。准备将T1~T6磁盘用于vSAN磁盘组,T1、T3、T4为一个磁盘组,T2、T5、T6为一个磁盘组,共两个磁盘组。
vdq -q | grep "Name\|IsSSD\|Size"

13.由于主机上全是SSD磁盘,所以在创建全闪磁盘组之前,需要先将用于容量盘的磁盘标记为容量闪存盘。
esxcli vsan storage tag add -d mpx.vmhba0:C0:T3:L0 -t capacityFlash
esxcli vsan storage tag add -d mpx.vmhba0:C0:T4:L0 -t capacityFlash
esxcli vsan storage tag add -d mpx.vmhba0:C0:T5:L0 -t capacityFlash
esxcli vsan storage tag add -d mpx.vmhba0:C0:T6:L0 -t capacityFlash

14.在主机上创建两个磁盘组,T1和T2作为闪存盘,T3~T6作为容量闪存盘。
esxcli vsan storage add -s mpx.vmhba0:C0:T1:L0 -d mpx.vmhba0:C0:T3:L0 -d mpx.vmhba0:C0:T4:L0
esxcli vsan storage add -s mpx.vmhba0:C0:T2:L0 -d mpx.vmhba0:C0:T5:L0 -d mpx.vmhba0:C0:T6:L0

15.主机上查看刚刚已创建好的所有vSAN存储设备。
esxcli vsan storage list | grep -A 5 "Device"

使用上述方式,完成esxi-b2~esxi-b4主机vSAN磁盘组的创建。
16.主机上查看vSAN集群状态。
esxcli vsan cluster list

17.主机上查看vSAN集群中其他主机的单播代理状态。
esxcli vsan cluster unicastagent list

18.主机上查看vSAN集群健康状态。
esxcli vsan health cluster

19.在vCenter上使用RVC命令host.exit_maintenance_mode将所有主机退出维护模式。
host.exit_maintenance_mode ~esxib1
host.exit_maintenance_mode ~esxib2
host.exit_maintenance_mode ~esxib3
host.exit_maintenance_mode ~esxib4

20.在vCenter上使用RVC命令vsan.cluster_info查看vSAN集群vsan02的状态。本小节完。
> vsan.cluster_info localhost/datacenter/computers/vsan02
2024-01-26 11:54:11 +0800: Fetching host info from esxi-b3.lab.com (may take a moment) ...
2024-01-26 11:54:11 +0800: Fetching host info from esxi-b1.lab.com (may take a moment) ...
2024-01-26 11:54:11 +0800: Fetching host info from esxi-b2.lab.com (may take a moment) ...
2024-01-26 11:54:11 +0800: Fetching host info from esxi-b4.lab.com (may take a moment) ...
Host: esxi-b1.lab.com
Product: VMware ESXi 7.0.3 build-22348816
vSAN enabled: yes
Cluster info:
Cluster role: agent
Cluster UUID: 52783a01-cbdd-3691-ae7d-e1460dcb601e
Node UUID: 65a743cf-35f2-1ea3-5b85-00505687d430
Member UUIDs: ["65a743f9-1aad-f462-d1a8-005056875b25", "65a74405-7719-a1c0-5677-00505687cc0d", "65a743cf-35f2-1ea3-5b85-00505687d430", "65a74408-270e-ee81-2892-00505687df8b"] (4)
Node evacuated: no
Storage info:
Auto claim: no
Disk Mappings:
Cache Tier: Local VMware Disk (mpx.vmhba0:C0:T2:L0) - 10 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T6:L0) - 20 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T5:L0) - 20 GB, v15
Cache Tier: Local VMware Disk (mpx.vmhba0:C0:T1:L0) - 10 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T4:L0) - 20 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T3:L0) - 20 GB, v15
FaultDomainInfo:
Not configured
NetworkInfo:
Adapter: vmk1 (11.1.1.1)
Data efficiency enabled: no
Encryption enabled: no
Host: esxi-b2.lab.com
Product: VMware ESXi 7.0.3 build-22348816
vSAN enabled: yes
Cluster info:
Cluster role: master
Cluster UUID: 52783a01-cbdd-3691-ae7d-e1460dcb601e
Node UUID: 65a743f9-1aad-f462-d1a8-005056875b25
Member UUIDs: ["65a743f9-1aad-f462-d1a8-005056875b25", "65a74405-7719-a1c0-5677-00505687cc0d", "65a743cf-35f2-1ea3-5b85-00505687d430", "65a74408-270e-ee81-2892-00505687df8b"] (4)
Node evacuated: no
Storage info:
Auto claim: no
Disk Mappings:
Cache Tier: Local VMware Disk (mpx.vmhba0:C0:T2:L0) - 10 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T6:L0) - 20 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T5:L0) - 20 GB, v15
Cache Tier: Local VMware Disk (mpx.vmhba0:C0:T1:L0) - 10 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T4:L0) - 20 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T3:L0) - 20 GB, v15
FaultDomainInfo:
Not configured
NetworkInfo:
Adapter: vmk1 (11.1.1.2)
Data efficiency enabled: no
Encryption enabled: no
Host: esxi-b3.lab.com
Product: VMware ESXi 7.0.3 build-22348816
vSAN enabled: yes
Cluster info:
Cluster role: agent
Cluster UUID: 52783a01-cbdd-3691-ae7d-e1460dcb601e
Node UUID: 65a74408-270e-ee81-2892-00505687df8b
Member UUIDs: ["65a743f9-1aad-f462-d1a8-005056875b25", "65a74405-7719-a1c0-5677-00505687cc0d", "65a743cf-35f2-1ea3-5b85-00505687d430", "65a74408-270e-ee81-2892-00505687df8b"] (4)
Node evacuated: no
Storage info:
Auto claim: no
Disk Mappings:
Cache Tier: Local VMware Disk (mpx.vmhba0:C0:T2:L0) - 10 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T6:L0) - 20 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T5:L0) - 20 GB, v15
Cache Tier: Local VMware Disk (mpx.vmhba0:C0:T1:L0) - 10 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T4:L0) - 20 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T3:L0) - 20 GB, v15
FaultDomainInfo:
Not configured
NetworkInfo:
Adapter: vmk1 (11.1.1.3)
Data efficiency enabled: no
Encryption enabled: no
Host: esxi-b4.lab.com
Product: VMware ESXi 7.0.3 build-22348816
vSAN enabled: yes
Cluster info:
Cluster role: backup
Cluster UUID: 52783a01-cbdd-3691-ae7d-e1460dcb601e
Node UUID: 65a74405-7719-a1c0-5677-00505687cc0d
Member UUIDs: ["65a743f9-1aad-f462-d1a8-005056875b25", "65a74405-7719-a1c0-5677-00505687cc0d", "65a743cf-35f2-1ea3-5b85-00505687d430", "65a74408-270e-ee81-2892-00505687df8b"] (4)
Node evacuated: no
Storage info:
Auto claim: no
Disk Mappings:
Cache Tier: Local VMware Disk (mpx.vmhba0:C0:T2:L0) - 10 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T6:L0) - 20 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T5:L0) - 20 GB, v15
Cache Tier: Local VMware Disk (mpx.vmhba0:C0:T1:L0) - 10 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T4:L0) - 20 GB, v15
Capacity Tier: Local VMware Disk (mpx.vmhba0:C0:T3:L0) - 20 GB, v15
FaultDomainInfo:
Not configured
NetworkInfo:
Adapter: vmk1 (11.1.1.4)
Data efficiency enabled: no
Encryption enabled: no
No Fault Domains configured in this cluster
>
后续
主机升级到VMware ESXi 7.0以后,License Key将不再可用,在主机上使用vim-cmd命令配置主机的序列号。
vim-cmd vimsvc/license --set xxxxx-xxxxx-xxxxx-xxxxx-xxxxx(License Key)

新的vSAN集群也需要vSAN License Key,在vCenter上使用RVC命令vsan.apply_license_to_cluster配置vSAN集群的序列号。
vsan.apply_license_to_cluster /localhost/datacenter/computers/vsan02/ -k xxxxx-xxxxx-xxxxx-xxxxx-xxxxx(License Key)
