How to Build and Configure vMA Server and ghettoVCB
Information about Building and Configuring vMA Server
This document will explain how to Build/Install the vMA Server for ESX and ESXi Host. vMA is a 'VMware Managment Assistant' Virtual Server used to manage Virtual Machines on ESX/i Hosts.
The VMware vSphere Management Assistant (vMA)
is a prepackaged Linux virtual machine in which administrators can
deploy scripts and select third-party agents to manage ESX and ESXi systems. Software included in vMA includes vSphere CLI, an authentication component that supports non-interactive login, and a log collection component.
This
document will also explain how to install and run ghettoVCBg2 to
perform weekly backups and utilize the excuteCommandUsingFastPass.pl
script to create and delete snapshots by calling the snapshotmanager.pl
script.
Document Creator
Todd Walters
Requirements
- ESX Host and VMs to 'manage'
- Download vMA 4.0: vMA 4.0
- Currently saved to SDIEVC001://D:\Software\VMWare\vMA-ovf-4.0.0-161993
- Review the vSphere Management Assistant Guide
- Download the ghettoVCBg2 script from the vGhetto Script Repository
- Currently ghettoVCBg2.pl run's via Cron Job weekly on Sunday Mornings.
- Download the excuteCommandUsingFastPass.pl script.
- Custom scripts are stored and run in /home/vi-admin/bin directory.
- snapshotmanger.pl script is in /usr/lib/vmware-vcli/apps/vm/snapshotmanager.pl
- Create and Remove snapshot scripts run via cron.
Section I: Installing vMA Server
You can deploy vMA using a file or from a URL. To deploy from a file, download and unzip the vMA ZIP file before you start the deployment process.
To deploy vMA
- Log in to a 4.0 vSphere Client connected to an ESX/ESXi 4.0, ESX/ESXi 3.5 Update 2 or later, or vCenter Server 4.0 system.
- If connected to a vCenter Server system, select the host to which you want to deploy vMA in the inventory pane.
- Select File > Deploy OVF Template. The Deploy OVF Template wizard appears.
- Select one of these options:
- Deploy from file
- Select this option if you have already downloaded and unzipped the vMA virtual appliance package. Click Browse, select the OVF, and click Next.
- Deploy from URL
- Select this option and click Next. Type http://www.vmware.com/go/importvma/vma4.ovf into the field and click Next.
- Click Next when the download details are displayed.
- Accept the license agreement.
- Specify a name (optional) and select a location for the virtual machine when prompted. If you are connected to a vCenter Server system, you can select a folder.
- If connected to a vCenter Server system, select the resource pool for the virtual machine. You can leave the default, which is the top‐level root resource pool.
- If prompted, select the datastore to store the virtual machine on and click Next.
- Select the network mapping and click Next.
- Review the information and click Finish.
The wizard deploys the vMA virtual machine to the host that you selected. The deploy process can take several minutes. Next you configure your vMA virtual machine. You perform this task when you log in to vMA the first time.
For the IE Environment we named the vMA Server sdie0vma01 with IP address 192.168.0.111
Enable vi-admin Account
- Setup password via Console on 1st Boot.
- Login via putty with username vi-admin
- Type 'sudo passwd vi-user' to setup password for vi-user and enable account
- Enter password and retype to confirm.
Section II: Configure and Run ghettoVCBg2.pl Script
- SCP to new vMA server the ghettoVCBg2.pl script to the vi-admin home directory in /home
- Add ESX hosts to vMA management using vifp or bulkAddServer.pl
- Add ESX hosts to /etc/hosts file because not in DNS.
- sudo vi /opt/esx_hosts and add ESX hostnames to file
- [vi-admin@my0vma01 ~]$ cat /opt/esx_hosts
my0esx001my0esx002 - Change directory to /opt/vmware/vima/samples/perl
- Run [vi-admin@sdie0vma01 perl]$ sudo ./bulkAddServers.pl --filename /opt/esx_hosts
- Do you want to use the same password for all of the hosts (yes/no): yes
Enter common root password:- You can also add servers with 'sudo vifp addserver' command
- Verify Servers are in list:
- [vi-admin@my0vma01 perl]$ sudo vifp listservers
[2009-09-14 17:04:15.496 'App' 47251497088944 info] Current working directory: /opt/vmware/vima/samples/perlmy0esx002 ESXmy0esx001 ESX
Enable vi-fastpass for all ESX Servers
- vifpinit my0esx001
- vifpinit my0esx002
Verify you can run a vSphere CLI command without authentication:
vicfg-nics -l --vihost sdie0esx001
Configure the following items for the ghettoVCBg2.pl script:
Edit the 'Backup Datastore' location
my $VM_BACKUP_DATASTORE = "ssdie-cx500-4lun30";
Edit the 'Backup Directory' location. (you must create this directory)
my $VM_BACKUP_DIRECTORY = "backups";
Edit the 'Number of Backups' to Keep
my $VM_BACKUP_ROTATION_COUNT = "3";
Edit the 'Disk backup type'
my $DISK_BACKUP_FORMAT = "thin";
Edit the 'Supported Adapter Types'
my $ADAPTER_FORMAT = "lsilogic";
Edit the 'VM Snapshot & Memory Quiesce'
my $VM_SNAPSHOT_MEMORY = "1";
my $VM_SNAPSHOT_QUIESCE = "1";
Create file that lists Virtual Machines to backup
vi ~/vm-list and add VM Servers to backup
Run the following command to backup Virtual Machines manually:
[vi-admin@sdie0vma01 ~]$ ./ghettoVCBg2.pl -output /home/vi-admin/logs/backup.log -vmlist /home/vi-admin/vm-list &
Review backup.log to verify backup job ran successfully.
cat /home/vi-admin/logs/backup.log
Look for this line: 09-14-2009 17:35:07 -- Backup completed for "NS3"!
Add script to run via 'Cronjob' every week on Sunday mornings.
type crontab -e to edit cron file and add the following line:
05 00 * * 0 /home/vi-admin/ghettoVCBg2.pl -output /home/vi-admin/logs/backup.log -vmlist /home/vi-admin/vm-list &
Section III: How to Create Snapshots
To create Snapshots, we will modify the excuteCommandUsingFastPass.pl script to use snapshotmanager.pl.
- Login to VCenter Server and download excuteCommandUsingFastPass.pl script to D:\Software\VMWare\scripts
- Launch WinScp and copy the perl script above to vi-admins home directory.
- Login via putty to my0vma01 with vi-admin account.
- Copy executeCommand.pl to createsnap.pl script.
- [vi-admin@sdie0vma01 ~]$ cp executeCommandUsingFastPass.pl bin/createsnap.pl
- Change directory to /home/vi-admin/bin and edit createsnap.pl script
- Change the my $cmd_result = line between backticks `` and add the command you want to run to create snapshots. `/usr/lib/vmware-vcli/apps/vm/snapshotmanager.pl --server "$server" --username "$username" --password "$password" --operation create --snapshotname IEsnaps`;
- --operation create is the option you want to run.
- --snapshotname IEsnaps is the name of the snapshot you will create.
- Edit the vi-admin crontab and add the following line to cron.
- [vi-admin@my0vma01 ~]$ crontab -e
00 00 * * 1-6 /home/vi-admin/bin/createsnap.pl --hostlist /opt/esx_hosts --config /home/vi-admin/.visdkrc > /home/vi-admin/logs/createsnap.log- This will run at midnight Monday through Saturday and create a log file in /home/vi-admins/logs.
Section IV: How to List Snapshots
To list all snapshots on all Virtual Machines on all ESX Host run the following command:
[vi-admin@sdie0vma01 bin]$ ./vm_snapshot.pl --list
sdie0vMA01
name: IEsnaps
description: Snapshot created for Virtual Machine my0vMA01
state: poweredOff
vm type: VirtualMachine
time created: 2009-09-23T15:43:47.555887-07:00
test_redhat1
name: IEsnaps
description: Snapshot created for Virtual Machine test_redhat1
state: poweredOff
vm type: VirtualMachine
time created: 2009-09-23T15:43:40.195774-07:00
sdie0test01
name: IEsnaps
description: Snapshot created for Virtual Machine srv0test01
state: poweredOff
vm type: VirtualMachine
time created: 2009-09-23T15:43:12.477038-07:00
SDIEDSAM01
name: IEsnaps
description: Snapshot created for Virtual Machine srvSAM01
state: poweredOff
vm type: VirtualMachine
time created: 2009-09-23T15:43:43.889907-07:00
NS3
name: IEsnaps
description: Snapshot created for Virtual Machine srvNS3
state: poweredOff
vm type: VirtualMachine
time created: 2009-09-23T15:43:08.80481-07:00
Section V: How to Remove Snapshots
To
remove snapshots I created a custom shell script called removesnap.sh.
The script is located in /home/vi-admin/bin directory. We do not use
this snapshotmanager.pl script inside the excutecomand.pl script becuase we need to remove multiple snapshots at the end of the week and need to use the --vmname option. The function of the script is as follows:
Define two variables
# Set Variables
HOME=/home/vi-admin
SCL=$HOME/vi-admin/bin
Create file called vms that lists all the Virtual Machines on ESX Hosts
# Create List of Virtual Machines
$HOME/getAllVMGuestHostname.pl | grep -A10 - | awk '{ print $1 }' > $HOME/vms
Use for loop to read in list of VM names and use snapshotmanager.pl with removall operation
for vm in `cat $HOME/vms`;
do /usr/lib/vmware-vcli/apps/vm/snapshotmanager.pl --operation removeall --vmname $vm
done
exit
Add /home/vi-admin/bin/removesnap.sh script to vi-admin crontab file.
[vi-admin@srv0vma01 bin]$ crontab -e
00 00 * * 0 /home/vi-admin/bin/removesnap.sh > /home/vi-admin/logs/removesnap.log
This runs at Midnight Every Sunday Morning and creates a removesnap.log file.
No comments:
Post a Comment