Difference between revisions of "Vmware"

From KeegansWiki
Jump to navigation Jump to search
m
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
=Oracle Enterprise Linux=
 
=Oracle Enterprise Linux=
 
[http://pubs.vmware.com/guestnotes/wwhelp/wwhimpl/js/html/wwhelp.htm Click here]
 
[http://pubs.vmware.com/guestnotes/wwhelp/wwhimpl/js/html/wwhelp.htm Click here]
 +
 +
=CLI=
 +
==Check mounts==
 +
*''esxcfg-nas -l | grep unmount''
 +
*''esxcfg-nas -r'' to remount
 +
==Re mount==
 +
* esxcfg-nas -a -o 10.94.41.228 -s /v1_autobase_sata_vm_ds_dsna02_cn3a1_nas V1_AUTOBASE_SATA_VM_DS_DSNA02_CN3A1_NAS
 +
 +
==List all Vms on ESX Host==
 +
vim-cmd vmsvc/getallvms
 +
==Install vmware tools==
 +
vim-cmd vmsvc/tools.install 1123
 +
==Get Guest Information==
 +
vim-cmd vmsvc/get.guest 1504
 +
 +
=SDK=
 +
==Get VM Info==
 +
* ./vm/vminfo.pl --url https://vcenter.de-ent.com:443/sdk/vimService --username 'user' --password 'pass' --folder 'HR VM' --out /tmp/out
  
 
=Enabling Swap=
 
=Enabling Swap=
 
==Create partition on the disk==
 
==Create partition on the disk==
<pre>[root@dstolprddb03-oracle ~]# fdisk -u /dev/sdb1
+
<pre>[root@dstolprddb03-oracle ~]# fdisk -u /dev/sdb
 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 
Building a new DOS disklabel. Changes will remain in memory only,
 
Building a new DOS disklabel. Changes will remain in memory only,
Line 55: Line 73:
 
The new table will be used at the next reboot.
 
The new table will be used at the next reboot.
 
Syncing disks.</pre>
 
Syncing disks.</pre>
 +
 
==Enable swap==
 
==Enable swap==
 
* ''mkswap -L SWAP-sdb1 /dev/sdb1''
 
* ''mkswap -L SWAP-sdb1 /dev/sdb1''
Line 64: Line 83:
 
==Preparing Netapps==
 
==Preparing Netapps==
 
* Locate the volume where the current datastore is (also note the folder name under 'Edit Settings')
 
* Locate the volume where the current datastore is (also note the folder name under 'Edit Settings')
* Find snapmirror destination for the regular and swap volumes, break snapmirrors for both
+
* Find snapmirror destination for the regular and swap volumes, [[Netapp#Breaking Snapmirrors|break snapmirrors for both]]
 +
 
 
==Import the Virtual Machine==
 
==Import the Virtual Machine==
 
* Change vcenter view to Datastores
 
* Change vcenter view to Datastores
 +
** If adding a new DS, add the ds2data folder in the path
 
* Find the destination volume in the gui, click on 'Browse Datastore'
 
* Find the destination volume in the gui, click on 'Browse Datastore'
 
* Locate the folder name you found from the original VM datastore info, open it, and add the vmx file to inventory
 
* Locate the folder name you found from the original VM datastore info, open it, and add the vmx file to inventory
 
** Rename it appropriately
 
** Rename it appropriately
 +
 
==Update New Virtual Machine==
 
==Update New Virtual Machine==
 
* The swap disk usually gets mucked up, so remove it (do not remove from disk, just from the virtual machine) and re-add it
 
* The swap disk usually gets mucked up, so remove it (do not remove from disk, just from the virtual machine) and re-add it
Line 78: Line 100:
 
* Click Advanced, then change the locations there. Config & HD1 should be on the same datastore
 
* Click Advanced, then change the locations there. Config & HD1 should be on the same datastore
 
* Select Thin Provisioned format
 
* Select Thin Provisioned format
 +
 +
=Add new disk to CentOS=
 +
Once the disk is added in vmware:
 +
* fdisk -u /dev/sdc
 +
** p;
 +
** w
 +
* mkfs -t ext4 /dev/sdc1
 +
* use '''blkid''' to get the uuid
 +
 +
 +
=Mbralign and Scanning=
 +
==Running mbralign/mbrscan==
 +
Note: The VM can be powered on during a scan, but you must initiate the scan from an esx host on which the VM is not currently running. To do an mbralign, the VM must be powered off.
 +
'''Do not do this with centos6. They fixed it on their end.'''
 +
* ''/opt/netapp/santools/mbrscan *.vmdk''
 +
* ''/opt/netapp/santools/mbralign --sparse *.vmdk''
 +
 +
==Fixing Broken MBR / Grub==
 +
* Boot off a linux cd (rescue)
 +
** To do this, as soon as the VM powers on, hit 'escape' once to get the bio boot menu.
 +
* At the prompt, type ''linux rescue''
 +
* Once there, chroot to the location of the mounted image (should be /mnt/sysimage)
 +
* run ''fdisk -l'' to see which drive to install grub on
 +
* grub-install /dev/sda
 +
* Reboot, should work now.
 +
More info [[http://updates.mistral.net/netapp/ESX/mbralign1.2.pdf here]]
 +
 +
==Add Datastore to ESX Host in Vcenter==
 +
* Change view to Hosts & Clusters
 +
* Click on the ESX host, open config tab
 +
* Click Add Storage...
 +
 +
 +
=Errors=
 +
==Snapshot Error==
 +
    Clone virtual machine:Cannot create a quiesced snapshot because the (user-supplied) custom prefreeze script in the virtual machine exited with a nonzero return code.
 +
 +
Right click on the source VM, snapshots, snapshot manager, and delete snapshots.

Latest revision as of 11:29, 2 October 2014

Oracle Enterprise Linux

Click here

CLI

Check mounts

  • esxcfg-nas -l | grep unmount
  • esxcfg-nas -r to remount

Re mount

  • esxcfg-nas -a -o 10.94.41.228 -s /v1_autobase_sata_vm_ds_dsna02_cn3a1_nas V1_AUTOBASE_SATA_VM_DS_DSNA02_CN3A1_NAS

List all Vms on ESX Host

vim-cmd vmsvc/getallvms

Install vmware tools

vim-cmd vmsvc/tools.install 1123

Get Guest Information

vim-cmd vmsvc/get.guest 1504

SDK

Get VM Info

Enabling Swap

Create partition on the disk

[root@dstolprddb03-oracle ~]# fdisk -u /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 4177.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-67108800, default 63): 
Using default value 63
Last sector or +size or +sizeM or +sizeK (63-67108800, default 67108800): 
Using default value 67108800


Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to 82 (Linux swap / Solaris)


Command (m for help): p

Disk /dev/sdb1: 34.3 GB, 34359706112 bytes
255 heads, 63 sectors/track, 4177 cylinders, total 67108801 sectors
Units = sectors of 1 * 512 = 512 bytes

     Device Boot      Start         End      Blocks   Id  System
/dev/sdb1p1              63    67108800    33554369   82  Linux swap / Solaris

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

Enable swap

  • mkswap -L SWAP-sdb1 /dev/sdb1
  • swapon /dev/sdb1

fstab Entry

LABEL=SWAP-sdb1         swap                    swap    defaults        0 0

Importing VM from one datacenter to another

Preparing Netapps

  • Locate the volume where the current datastore is (also note the folder name under 'Edit Settings')
  • Find snapmirror destination for the regular and swap volumes, break snapmirrors for both

Import the Virtual Machine

  • Change vcenter view to Datastores
    • If adding a new DS, add the ds2data folder in the path
  • Find the destination volume in the gui, click on 'Browse Datastore'
  • Locate the folder name you found from the original VM datastore info, open it, and add the vmx file to inventory
    • Rename it appropriately

Update New Virtual Machine

  • The swap disk usually gets mucked up, so remove it (do not remove from disk, just from the virtual machine) and re-add it
  • Update network vlan

Migrate the VM to a new netapp / volume

  • Click Migrate
  • Change Datastore
  • Click Advanced, then change the locations there. Config & HD1 should be on the same datastore
  • Select Thin Provisioned format

Add new disk to CentOS

Once the disk is added in vmware:

  • fdisk -u /dev/sdc
    • p;
    • w
  • mkfs -t ext4 /dev/sdc1
  • use blkid to get the uuid


Mbralign and Scanning

Running mbralign/mbrscan

Note: The VM can be powered on during a scan, but you must initiate the scan from an esx host on which the VM is not currently running. To do an mbralign, the VM must be powered off. Do not do this with centos6. They fixed it on their end.

  • /opt/netapp/santools/mbrscan *.vmdk
  • /opt/netapp/santools/mbralign --sparse *.vmdk

Fixing Broken MBR / Grub

  • Boot off a linux cd (rescue)
    • To do this, as soon as the VM powers on, hit 'escape' once to get the bio boot menu.
  • At the prompt, type linux rescue
  • Once there, chroot to the location of the mounted image (should be /mnt/sysimage)
  • run fdisk -l to see which drive to install grub on
  • grub-install /dev/sda
  • Reboot, should work now.

More info [here]

Add Datastore to ESX Host in Vcenter

  • Change view to Hosts & Clusters
  • Click on the ESX host, open config tab
  • Click Add Storage...


Errors

Snapshot Error

    Clone virtual machine:Cannot create a quiesced snapshot because the (user-supplied) custom prefreeze script in the virtual machine exited with a nonzero return code.

Right click on the source VM, snapshots, snapshot manager, and delete snapshots.