Linux 虛擬機器網路介面卡從E1000改為VMXNET3,e1000vmxnet3
我們知道VMware的網路介面卡類型有多種,例如E1000、VMXNET、VMXNET 2 (Enhanced)、VMXNET3等,就效能而言,一般VMXNET3要優於E1000,下面介紹如果將Linux虛擬機器的網路介面卡類型從E1000改為VMXNET3。本文測試環境如下
作業系統 :Oracle Linux Server release 5.7
虛擬機器版本 :Vmware 5.1
如下所示,測試前,我們可以先看看網卡類型為e1000, 此版本的Linux似乎沒有設定檔/etc/udev/rules.d/70-persistent-net.rules。只有設定檔60-net.rules.具體資訊請見
方法1:在vSphere Client中更改適配器類型
我們通過vSphere Client用戶端,添加網路介面卡2(適配器類型為VMXNET3),然後刪除網路介面卡1,重啟伺服器
重啟後,在/etc/sysconfig/network-scripts/下,你會看到有ifcfg-eth0和ifcfg-eth0.bak兩個設定檔,系統自動產生了新的設定檔並將原來的設定檔重新命名了
如下所示,新產生的設定檔ifcfg-eth0是動態擷取IP,需要重新設定網路資訊,重啟網路服務即可即可解決問題。
[root@localhost ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0
# VMware VMXNET3 Ethernet Controller
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
HWADDR=00:50:56:af:09:7b
[root@localhost ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0.bak
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
HWADDR=00:50:56:AF:45:19
ONBOOT=yes
IPADDR=192.168.9.24
GATEWAY=192.168.9.8
NETMASK=255.255.255.0
注意,在我多次測實驗證過程中,如果伺服器沒有安裝Vmware Tools,那麼在操作過程中就會遇到“Device eth0 does not seem to be present, delaying initialization”,查看當前的eth裝置,你會發現只有lo裝置。怎麼都搞不定。這個可不像Linux 複製虛擬機器引起的“Device eth0 does not seem to be present, delaying initialization”那樣輕鬆搞定
[root@localhost1 ~]# ls /sys/class/net/
lo
[root@localhost ~]#
方法2:修改.vmx 檔案來更改適配器類型
1:關閉LNTEST虛擬機器。
2:選擇LNTEST,單擊右鍵選擇“從清單中移除”
3:在資料存放區瀏覽器中找到LNTest對應的目錄,找到LNTest.vmx檔案。找到參數ethernet1.virtualDev(有可能為ethernet0)將其值從"e1000"改為"vmxnet3"
vmotion.checkpointFBSize = "4194304"
softPowerOff = "TRUE"
tools.syncTime = "FALSE"
unity.wasCapable = "FALSE"
tools.remindInstall = "TRUE"
migrate.hostlog = "./LNTest-d958ff0f.hlog"
ethernet1.virtualDev = "vmxnet3"
ethernet1.pciSlotNumber = "32"
ethernet1.startConnected = "TRUE"
ethernet1.allowGuestConnectionControl = "TRUE"
ethernet1.features = "1"
ethernet1.wakeOnPcktRcv = "TRUE"
ethernet1.networkName = "VM Network"
ethernet1.dvs.switchId = ""
ethernet1.present = "TRUE"
ethernet1.addressType = "generated"
config.readOnly = "FALSE"
ethernet1.generatedAddress = "00:0c:29:0f:63:7e"
ethernet1.generatedAddressOffset = "10"
ethernet0.present = "FALSE"
4: 選擇vmx檔案,將其“添加到清單”,然後重啟電源,一切搞定,都不需要修改任何網路設定資訊。
方法3:使用PowerCLI修改網路介面卡類型
PowerCLI,即VMware vSphere PowerCLI 是一款功能強大的命令列工具來修改。 這個方法沒有實際驗證過,不過看其介紹,似乎是最簡單的一種方法。
Change the Adapter Type with PowerCLI
The easiest method to change the adapter type is by using this little PowerCLI command. Just replace <VM> with your virtual machines name. You can run this script without disruption while the virtual machine is running but it’s not active until you have powered off the virtual machine. A reboot does not activate the configuration.
Get-VM -name "<VM>" | Get-NetworkAdapter | Where { $_.Type -eq "E1000"} | Set-NetworkAdapter -Type "vmxnet3"
Prior to change please make sure that your operating system contains the vmxnet3 driver or you have installed the VMware Tools. To check the required kernel module type “modprobe vmxnet3“. If you don’t get an error message you should be fine.
參考資料:
http://www.virten.net/2013/02/migrate-e1000-adapter-to-vmxnet3-with-linux-virtual-machines/