分类目录归档:虚拟化

将多个vmware的vmdk文件转化成单个文件的方法

通过vmware workstation软件创造出来的虚拟机,在虚拟机目录下有时会出现多个以vmdk后缀名结尾的文件,多个文件占用的空间都很大,感觉很乱,并且这样虚拟机运行的效率也很低。

出现这种情况的原因是在创建虚拟机时,在指定硬盘容量时,选择了Split virtual disk into multiple files,并且下面有说明,这种多个文件模式更易于将虚拟机转移到其他的电脑上,并且会降低性能且会占用更多的硬盘空间。

如果选择Store virtual disk as a single file模式,虚拟机就会在一个文件中,不仅会提高性能减少占用硬盘空间,而且看着更舒服。

但是这两个模式之间可以转换吗,通过vmware workstation自带的一个工具就可以做到。

在vmware workstation的安装目录下,有一个vmware-vdiskmanager.exe文件,在命令行下执行,可以看到这个软件的用法,如下:

VMware Virtual Disk Manager – build 471780.
Usage: vmware-vdiskmanager.exe OPTIONS <disk-name> | <mount-point>
Offline disk manipulation utility
  Operations, only one may be specified at a time:
     -c                   : create disk.  Additional creation options must
                            be specified.  Only local virtual disks can be
                            created.
     -d                   : defragment the specified virtual disk. Only
                            local virtual disks may be defragmented.
     -k                   : shrink the specified virtual disk. Only local
                            virtual disks may be shrunk.
     -n <source-disk>     : rename the specified virtual disk; need to
                            specify destination disk-name. Only local virtual
                            disks may be renamed.
     -p                   : prepare the mounted virtual disk specified by
                            the mount point for shrinking.
     -r <source-disk>     : convert the specified disk; need to specify
                            destination disk-type.  For local destination disks
                            the disk type must be specified.
     -x <new-capacity>    : expand the disk to the specified capacity. Only
                            local virtual disks may be expanded.
     -R                   : check a sparse virtual disk for consistency and atte
mpt
                            to repair any errors.
     -e                   : check for disk chain consistency.
     -D                   : make disk deletable.  This should only be used on di
sks
                            that have been copied from another product.

  Other Options:
     -q                   : do not log messages

  Additional options for create and convert:
     -a <adapter>         : (for use with -c only) adapter type
                            (ide, buslogic, lsilogic). Pass lsilogic for other a
dapter types.
     -s <size>            : capacity of the virtual disk
     -t <disk-type>       : disk type id

  Disk types:
      0                   : single growable virtual disk
      1                   : growable virtual disk split in 2GB files
      2                   : preallocated virtual disk
      3                   : preallocated virtual disk split in 2GB files
      4                   : preallocated ESX-type virtual disk
      5                   : compressed disk optimized for streaming
      6                   : thin provisioned virtual disk – ESX 3.x and above

     The capacity can be specified in sectors, KB, MB or GB.
     The acceptable ranges:
                           ide adapter : [1MB, 2040.0GB]
                           scsi adapter: [1MB, 2040.0GB]
        ex 1: vmware-vdiskmanager.exe -c -s 850MB -a ide -t 0 myIdeDisk.vmdk
        ex 2: vmware-vdiskmanager.exe -d myDisk.vmdk
        ex 3: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 0 destinationDisk.vm
dk
        ex 4: vmware-vdiskmanager.exe -x 36GB myDisk.vmdk
        ex 5: vmware-vdiskmanager.exe -n sourceName.vmdk destinationName.vmdk
        ex 6: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 4 -h esx-name.mycomp
any.com \
              -u username -f passwordfile “[storage1]/path/to/targetDisk.vmdk”
        ex 7: vmware-vdiskmanager.exe -k myDisk.vmdk
        ex 8: vmware-vdiskmanager.exe -p <mount-point>
              (A virtual disk first needs to be mounted at <mount-point>)

用法已经说的很清楚了,这里假设需要转化的虚拟机位于F:windows.vmdk,那么通过以下命令操作来实现将多个vmdk文件转化成一个文件:

vmware-vdiskmanager.exe -r “F:\windows.vmdk” -t 0 “F:\b.vmdk”

注意目标文件和源文件名不能一样,转换后原有虚拟机仍然存在,删除并新建后,使用现有磁盘添加新的vmdk文件即可。

DELL MD3200I存储ISCSI映射到ESXi5.1主机的方法

一、ESXi5.1主机上的操作,使用vsphere client连接ESXi5.1物理主机,连接后做以下操作:

1、配置—网络,vsphere标准交换机—属性—vSwitch—添加,选择VMkernel,网络标签填写ISCSI或者其他的文字说明即可,下一步后使用以下IP设置,填写192.168.130.103,因为DELL MD3200i存储的0号、、1号ISCSI口默认的IP地址为192.168.130.101/24和192.168.131.101/24,所以配置在一个网段即可。

2、配置—存储适配器,添加—添加软件iSCSI适配器,在刚添加的iSCSI Software Adapter上的WWN号上右击属性—动态发现,添加iSCSI服务器192.168.130.101和192.168.131.101,端口都是默认的3260,添加后点击静态发现,会自动发现DELL MD3200i存储。

二、DELL MD3200i存储上的操作,使用DELL MDSM软件连接到存储,新建好虚拟磁盘后,在主机映射中,创建主机组,将新建的虚拟磁盘都添加到主机组中,在主机组中创建主机,将主机端口识别符添加到主机的方法,选择“通过已知的无关联主机端口标识符来进行添加”,选择ESXi5.1的WWN号,用户标签输入主机信息,点击添加,主机操作系统选择VMWARE。

三、在ESXi5.1主机上,配置—存储器—全部重新扫描,会发现数据存储中增加了DELL存储上的虚拟磁盘,操作完成。

DELL MD3200i存储控制器解锁方法详见http://www.eumz.com/2013-06/910.html

——————————————————————————————————

附:DELL MD3200i存储管理软件MDSM下载地址:http://www.dell.com/support/drivers/us/en/555/DriverDetails/Product/powervault-md3600f?driverId=JJW99&osCode=WS8R2&fileId=3084846822

vmrun的简单用法

Power Commands Description Parameters
start

Starts a virtual machine (.vmx file) or team (.vmtm file).

The default gui option starts the machine interactively,

which is required to display a VMware user interface.

The nogui option suppresses the user interface,

including startup dialog box, to allow noninteractive

scripting.

<path to .vmx or .vmtm file>

[ gui | nogui ]

stop

Stops a virtual machine (.vmx file) or team (.vmtm file).

Use the soft parameter to power off the guest after

running shutdown scripts. Use the hard parameter to

power off the guest without running scripts, as if you

pressed the power button. The default is to use the

powerType specified in the .vmx file, if present.

<path to .vmx or .vmtm file>

[ hard | soft ]

reset

Resets a virtual machine (.vmx file) or team (.vmtm file).

Use the soft parameter to run shutdown scripts before

rebooting the guest. Use the hard parameter to reboot

the guest without running scripts, as if you pressed the

reset button. The default is to use the powerType

specified in the .vmx file, if present.

<path to .vmx or .vmtm file>

[ hard | soft ]

suspend

Suspends a virtual machine (.vmx file) or team (.vmtm)

without shutting down, so local work can resume later.

The soft parameter suspends the guest after running

system scripts. On Windows guests, these scripts release

the IP address. On Linux guests, the scripts suspend

networking. The hard parameter suspends the guest

without running the scripts. The default is to use the

powerType specified in the .vmx file, if present.

To resume virtual machine operation after suspend, use

the start command. On Windows, the IP address is

retrieved. On Linux, networking is restarted.

<path to .vmx or .vmtm file>

[ hard | soft ]

pause

Pauses a virtual machine (.vmx file). You can use this

either to pause replay, or to pause normal operation.

<path to .vmx file>
unpause

Resumes operation of a virtual machine (.vmx file) from

where you paused replay or normal operation.

<path to .vmx file>

 

使用vmrun轻松实现虚拟机开机启动

很多人都在使用vmware workstation版本来创建虚拟机,利用虚拟机来做实验显得非常轻松。并且很多人也希望实现开机后虚拟机能随物理机上的操作系统自动启动,在网络上搜索也能发现很多文章,大部分搜索到的文章都要使用微软提供的两个小工具:instsrv.exe和sryany.exe,使用这两个工具虽然可以实现,但是较为繁琐,而且vmware早就为我们提供了更好的工具——vmrun。

vmware workstation至少在6.5版本以后就加入了vmrun工具,使用vmrun可以轻松实现对虚拟机的操作,比如开机、关机、重启等,命令如下:

“D:\vmrun.exe” start “D:\Windows XP Professional.vmx”
这里vmrun位于D盘根目录,要启动的Windows XP Professional.vmx也位于D盘根目录,可按具体情况修改。

将这条命令加入到批处理中,并放在开始菜单的启动文件夹下,就可实现开机自动运行Windows XP Professional.vmx这个虚拟机了。

更多关于vmrun的信息,详见vmrun的简单用法一文。

VMware vMotion虚拟机的实时迁移技术概述

vMotion

可在主机之间迁移正在运行的虚拟机,因此进行计划内服务器维护时无需中断应用的使用。

概览

vSphere vMotion 能在实现零停机和服务连续可用的情况下将正在运行的虚拟机从一台物理服务器实时迁移到另一台物理服务器上,并且能够完全保证事务的完整性。 vMotion 是创建动态、自动化并自我优化的数据中心所需的关键促成技术。

  • 即时迁移正在运行的虚拟机
  • 轻松管理和安排实时迁移

即时迁移正在运行的整个虚拟机VMware 客户中 80% 都在生产中部署了 vMotion 技术,此技术利用服务器、存储和网络连接的完全虚拟化,可将正在运行的整个虚拟机从一台物理服务器即刻迁移到另一台物理服务器中。 虚拟机会保留其网络标识和连接,从而确保实现无缝的迁移过程。 您将能够:

  • 在零停机、用户毫无察觉的情况下执行实时迁移
  • 持续自动优化资源池中的虚拟机
  • 在无需安排停机、不中断业务运营的情况下执行硬件维护
  • 主动将虚拟机从发生故障或性能不佳的服务器中移出

轻松管理和安排实时迁移迁移向导使您能从数以千计的客户经过多年生产验证的产品的可靠性和可管理性中轻松获益。

  • 执行任何虚拟机的多个并行迁移,虚拟机可以跨任何类型受 vSphere 支持的硬件和存储运行任何操作系统,包括审计追踪
  • 几秒钟内即可确定虚拟机的最佳放置位置
  • 安排迁移在预定时间发生,且无需管理员在场

vSphere vMotion 可以作为大多数 VMware vSphere 版本和 工具包的组件购买。

详细技术信息

使用 VMware vMotion 将虚拟机从一台物理服务器实时迁移到另一台物理服务器的过程是通过三项基础技术实现的。

  • 虚拟机的整个状态由存储在共享存储(如光纤通道或 iSCSI 存储区域网络 (SAN),或网络连接存储 (NAS))上的一组文件封装起来。 vSphere 虚拟机文件系统 (VMFS) 允许多个 vSphere 主机并行访问相同的虚拟机文件。
  • 虚拟机的活动内存及精确的执行状态通过高速网络快速传输,从而允许虚拟机立即从在源 vSphere 主机上运行切换到在目标 vSphere 主机上运行。 vMotion 通过在位图中连续跟踪正在进行的内存事务处理来确保用户察觉不到传输期。 一旦整个内存和系统状态已拷贝到目标 vSphere 主机,vMotion 将中止源虚拟机的运行,将位图的内容拷贝到目标 vSphere 主机,并在目标 vSphere 主机上恢复虚拟机的运行。 整个过程在以太网上需要不到两秒钟的时间。
  • 底层 vSphere 主机将对虚拟机使用的网络进行虚拟化。 这样可以确保即使在迁移后也能保留虚拟机网络标识和网络连接。 因为使用 vMotion 进行虚拟机迁移可以保留精确的执行状态、网络标识和活动网络连接,其结果是实现了零停机时间而且不中断用户操作。

vSphere 5.1 中的 vMotion 增强功能可将虚拟机实时迁移的方便性和灵活性提高到新的水平。 在 vSphere 5.1 之前,无论是 vMotion 还是 Storage vMotion 都需要共享存储才能执行虚拟机的实时迁移。 (vMotion 需要共享存储才能在主机之间执行 vMotion。 Storage vMotion 需要主机能够访问源和目标数据存储。)vSphere 5.1 不再需要共享存储。

即使两个主机没有任何共用的共享存储,vSphere 5.1 也能使虚拟机同时更改其数据存储和主机。 它不仅能够实现大型数据中心内多个集群之间的虚拟机迁移(这些集群之间可能并没有一组共用的数据存储),还能实现小型环境中虚拟机迁移,而无需访问昂贵的共享存储设备。

vSphere 5.1 允许将 vMotion 和 Storage vMotion 组合到一个过程中。 这种组合式迁移通过网络将虚拟机内存及其磁盘同时复制到目标主机。 发送所有内存和磁盘数据后,目标虚拟机将恢复,并且源虚拟机也将关闭。