Using vmWare to host OSX Server instances offers all the benefits of running virtual machines:
- easy to spin up new servers as needed
- allows use of more robust hardware due to economies of scale
- easy to backup the entire server, by shutting down the instance and making a backup copy of the .vmwarevm bundle
- provides easy fallback in case of botched server upgrades etc
Ideally, we want to have thin vmWare instances with data stored on the native hardware RAID, outside of the instance virtual hard drive.
- A vmWare virtual hard drive is never going to have the performance and reliability characteristics of a RAID.
- Large data shares just cannot be effectively managed by the vmware file-based virtual hard drive mechanism.
- Separation of data from server VM instance makes it easier to backup the data and makes the instances more disposable/ easily replaced
Setting up the host vmWare Server
For our solutions, we are using the new MacPro with massive memory and a Promise Pegasus2 thunderbolt RAID. The idea here is to have no services other than providing a vmWare host. All services will be running on VMs under vmWare, so we want the host to be stripped down and fast, dedicated to this purpose.
- Start up new machine
Ensure it works out-of-box
Setup main admin user account - Settings:Users
Create ‘emergency’ admin user account
Set to auto login as base admin user (so vmware starts on power up) - Settings: Sharing
Set computer name
Turn on remote administration for admin users only - Settings: App Store: Disable auto install of software updates
- Install memory, run all updates
- Disable spotlight
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
ref: http://osxdaily.com/2011/12/10/disable-or-enable-spotlight-in-mac-os-x-lion/ - Disable wifi
- Energy Saver:
Enable ‘Prevent computer from sleeping automatically when the display is off'
Disable ‘Put hard disk to sleep when possible’
Enable Wake for network access
Enable ‘Start up automatically after power failure'
Disable Power Nap - Screensaver
Change to ‘Message'
Start after 5m
Set hot corners: TL = start screensaver, BL disable screensaver - Finder Preferences
Show hard drives on desktop
Show connected servers desktop
New Finder window shows (machine name)
Sidebar: Show Devices (machine name)
Advanced: Show all filename extensions - Security and Privacy
Require password 1 min after screen saver begins - Install MenuMeters
Enable all - Install vmWare
- Set vmWare to start on login of main admin user
- Delete unnecessary OSX applications
GarageBand
iMovie
iPhoto
Keynote
Numbers
Pages - Promise RAID
Download and install latest utilities:
http://www.promise.com/support/download.aspx?m=93®ion=en-global
Determine if default RAID5 should be replaced with something better:
https://www.icc-usa.com/raid-calculator/
Background Activitites: Add schedule for monthly Media Patrol, weekly spare check, bi-weekly redundancy check
Promise Utllity:Preferences:General Automatically check for updates
Promise Utllity:Preferences:Email Setup email notifications
If a Pegasus RAID is being used:
- Desktop: Set desktop to solid color: RED: this indicates improper Startup Disk
- Use CCC to copy Macintosh HD to partition on Pegasus
- Set Pegasus partition as Statup Disk
- Reboot, then change desktop to solid color: BLUE: this indicates proper Startup Disk
Any server instance requiring a physical hard drive will require a drive partition. An example is OSX Server and needing to maintain file permissions. The file-based vmWare virtual drive is not suitable for large data shares, shared folders do not allow for proper control of sharing privileges, so this is the only way file permissions and ACLs can be properly maintained by OSX Server. It's a good time to reduce the size of the single partition using Disk Utility and create any additional partitions your will need for your VM server instances.
After setup, consider using Carbon Copy Cloner to copy the physical boot drive to the RAID, then use the RAID as the startup device. Be sure to set the desktop background color to RED on the non-RAID drive so it is clear if boot occurred from it.
Deploy the host vmWare Server
Take the host server and deploy at client location.
- Network: Set static IP address
- Test remote access
- Promise RAID Utility: :Preferences:Email Test email notifications
- Setup UPS so that it powers down the host on power loss. See UPS Shutdown Notes below.
OSX Server VM Issues
There are some issues with using OSX Server VMs due to shortcomings of the server software:
10.8 Mountain Lion | vmWare Shared Folders do not appear in File Sharing, so all shared files must be resident on the virtual drive | Attempting to upgrade directly to Yosemite causes DNS services to not start, no errors in named.log. Upgrade to Mavericks first. | |
10.9 Mavericks |
vmWare Shared Folders may be shared in File Sharing, but Shared Folders do not appear in the new Storage list, so no way to force propagation of privileges down the share if a permissions problem occurs. Storage pane in Server app allows use of alternate drive to store server data. (Does this work well? Can we use vmWare Shared Folders for this?) DoveCot repeatedly crashes with error : |
||
10.10 Yosemite |
On upgrade MySQL will no longer autostart on boot, web server is off, and PHP disabled. See http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/ |
||
Shrinking the Virtual Drive
OSX
Sometimes the VMware disk file gets really bloated, although the actual files used are a small fraction of the whole. Bloat of 100+GB have been seen.
In VMware Fusion 6.0.4 with Mac OS X 10.9.4 as the host, Mac OS X 10.10 as the guest, and VMware Tools installed in the guest OS, of course, you can shrink the virtual disk at once with the following command issued in the command line of the guest OS:
sudo /Library/Application\ Support/VMware\ Tools/vmware-tools-cli disk shrink /
Most of this process is done while the guest OS is running and available (albeit sluggish due to disk i/o). When it reaches 99%, you will see "out of disk space" and "reduce scrolling memory buffer" warnings, which should be ignored. Shortly thereafter, the guest OS will be unavailable and if you are looking at the UI in VMware, you will see a "Shrinking Disk" banner and gauge indicating progress in the copying of the large vmdk into a new -tmp vmdk. This part of the process can take quite awhile.
If the process is interrupted, I have no idea what will happen (which is why a backup is desirable), but it may be possible to just delete the tmp vmdk in the vm bundle. You should also pause any services which affect data, such a mail server, so that no data is lost if reverting to a backup is necessary.
Ref: https://communities.vmware.com/message/2399910
Windows
To shrink Windows VMs, first (make a backup!, then) defragment the disk in Windows. Ref: Defragmenting, shrinking, and cleaning up VMware Fusion virtual machine disks (1001934).
How to Convert a Physical Mac into a VM Guest under VMware Fusion
If you want to migrate an existing Mac system to a virtual machine, here are the best instructions:
http://fortysomethinggeek.blogspot.com/2013/03/convert-physical-mac-into-vm-guest.html
http://krypted.com/mac-os-x/how-to-move-a-physical-machine-server-to-a-vmware-vm/
Installing VMware Tools on Unix
It's not as straightforward as one would hope, but instructions are here. If VMware Tools stop working they should be re-installed. Sometimes they must be manually deleted first.
Using VMware Shared Folders on OSX
VMware Shared Folders are a great way to keep the VM drive image tiny and portable. Put all your active data into a Shared Folder, and then it's all stored on the host file system. Unfortunately it's not as straightforward as one would expect: the share is not directly accessible from the command line.
If you are having problems getting Apache or some other command line app to access the Shared Folder, behold the power of the link!
Hard links are akin to OSX aliases, which depend upon file system inodes instead explicit file system paths. The advantage of hard links is that the file system will preserve the link regardless if you move the directory. For some reason VMware Tools do not integrate with the file system properly, so you must use symbolic links, which rely solely on the file system path.
Setup Shared Folders and normally: Create a folder in the host file system, turn on Shared Folders and share the folder. On the guest OS, you'll see a mounted volume: VMware Shared Folders.
Create a link to the Shared Folder on the guest OS:
sudo ln -s /Volumes/VMware\ Shared\ Folders/{shared-folder-name}/ {path-to}/{shared-folder-link-name}
where:
- {shared-folder-name} : is the name of the Shared Folder on the host file system
- {path-to} : is the path to wherever you want the link to live
- {shared-folder-link-name} : whatever you want to name the link file
Now, on the guest OS use the full path to the link file as the path to access the files. This allows access to the files where before the path could not be resolved.
Adding a raw physical disk to a Fusion VM
VM Fusion for Mac provides no direct means to attach a raw physical volume on the host to the guest OS on a virtual machine. This is extremely important if:
- the VM has share a huge number of files, and the file-based VM disk image is just too inefficient, or
- if the VM is a file server and needs to be able to manage permissions.
To attach raw physical disk, see here.
UPS Shutdown Notes
It desirable for the host to shutdown on power loss, suspending all VMs until power is suitably restored. This is much simpler than setting up each and every VM to talk to the UPS.
If the UPS uses a USB cable, just attach it and adjust the settings in Energy Saver.
If you have a big, fancy UPS with a network card, see APC UPS Network Shutdown.
Bonding Ethernet Channels