Thursday, July 22, 2010

Steps to remember when copying a Virtual Machine

I recently copied a VM to reuse and encountered a networking issue.  Part of the process of editing the .vmx file prior to starting the VM should include changing the MAC address of the Network Card.

Simply adjust the .vmx file with the necessary changes ie "nvram, and displayName" along with adding the example below to the end of the file.

Example (to avoid an ipv6 address conflict):

ethernet0.address = "00:50:56:00:00:01"

VMware Server 2.0 - Tuning

I made the following enhancements in an attempt to improve my VMware performance on a Debian 2.6.26-1-686-bigmem. 

Edit VMware configuration file and add the following:

vi /etc/vmware/config

mainMem.useNamedFile tells VMWare where to put it's temporary workspace file. This file contains the content of the Virtual Machine memory which is not used. By default it is placed in the directory with the virtual machine, however that can seriously impact performance so we'll turn it off.
mainMem.useNamedFile = FALSE

tmpDirectory is the default path for any temp files. We need to change that to be a shared memory filesystem (in RAM).
tmpDirectory="/dev/shm"

prefvmx.useRecommendedLockedMemSize and prefvmx.minVmMemPct tell VMWare to either use a fixed sized memory chunk or balloon and shrink memory as needed. With 4GB of memory we'll use a fixed size of memory to reduce disk IO.

prefvmx.useRecommendedLockedMemSize="TRUE"
prefvmx.minVmMemPct="100"


Be sure to install VMware tools followed by:

Set the time in the Virtual Machine to the hosts time.

tools.syncTime = "TRUE"

Force gracefully stop on each VM.

autostop = "softpoweroff"

I don't care about collapsing memory into a shared pool, this tells the VM to not share which saves CPU cycles:

mem.ShareScanTotal=0
mem.ShareScanVM=0
mem.ShareScanThreshold=4096
sched.mem.maxmemctl=0
sched.mem.pshare.enable = "FALSE"


This basically performs the same action as the configuration I put in /etc/vmware/config by telling the VM to eliminate the temp files and not to balooning and shrink memory, however it doesn't hurt anything to have it in both locations:

mainMem.useNamedFile = "FALSE"
MemTrimRate = "0"
MemAllowAutoScaleDown = "FALSE"


In order for the VMWare configuration to work properly with shared memory, you'll need to increase the default shared memory size for tmpfs to match the amount of memory in your system. This can be done by editing /etc/default/tmpfs:

SHM_SIZE=4096

Wednesday, July 21, 2010

OpenVPN - Linux Client

How-to connect a Linux server to another Linux server via OpenVPN, command line style.

apt-get install openvpn

Copy the example client.conf file

cp /usr/share/doc/openvpn/examples/sample-config-files/client.conf /etc/openvpn

I then edited the client.conf file down as listed below for my initial testing.  Please be sure to adjust according to your own Server configuration as well as proper names for the ca, key and crt files.


#---- OpenVPN Client.conf --------------
dev tap0
proto tcp
resolv-retry infinite
nobind
persist-key
persist-tun
remote hostname.com 1194
ca ca.crt 
cert hostname.crt
key hostname.key
verb 3
 
Restart OpenVPN

/etc/init.d/openvpn start
Test by pinging or logging into the remote server