Archive

Wordpress 2.5 wrecked K2 wrecked Wordpress

Just a quick post to try out the new WP 2.5 interface ... and also to say it completely wrecked the back-end of the blog since I use the K2 theme to manage some of my presentation settings. I was getting the following error, along with a bunch of other people on t'internet since upgrading Wordpress:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/web778/web/wp-includes/widgets.php:1307) in /var/www/web778/web/wp-includes/pluggable.php on line 689

I surfed onto the K2 website and found a blog post 4 days old explaining this was fixed in the latest SVN release. Quick fix was to grab the SVN using:

svn checkout http://kaytwo.googlecode.com/svn/trunk/ kaytwo-read-only

Then trash the K2 directory on my Wordpress site and replace the files with the latest and greatest. It worked a treat for me. Actually my sidebar has stopped working now and all of my posts are 'uncatagorised' ... looks like I'll be going back to a default theme for now. I wonder if I can get my catagories back from a backup ...

How to migrate a VM using SCP

ESX Starter and Foundation editions do not provide a built in function to migrate a virtual machine to another ESX host. In the absence of these options, you can do this by logging on to the console operating system using Putty, and then using the SCP utility to copy the VM files. Then on the destination server, add the server to the inventory and mount the VM.

The software you need to do this is already installed on the source and destination server, but has to be enabled in the virtual infrastructure client first on both servers:

  • Log into VIC as root
  • Click on ESX Server in the tree (top level)
  • On the Security tab, click on Security (may be called Security Profile)
  • Click on the "Properties ..." link
  • Tick the boxes for SSH Client and SSH Server
  • Click OK

Log on to the destination server using Putty. We need to find out the real name of the data store directory.

ls /vmfs/volumes

It should look something like this:

View of /vmfs/volumes
View of /vmfs/volumes

The dark blue text is the real name of the directory. The light blue is a symbolic link to that directory. Make a note of the full path of the data store you want to migrate to, e.g:

/vmfs/volumes/47cd0bf3-b4b7eef9-5985-0017a4f6b9f1

Now log on to the source server using Putty.

  • Before you do anything, remember to shut down the guest VM you are copying
  • Navigate into your data store where the source VM is held, e.g:
cd /vmfs/volumes/ SERVERNAME\ Storage
  • Pull up the directory listing using ll (this is an alias of ls -l)
  • Again, make sure this VM is powered off
  • Use SCP to copy the whole directory to the destination server. The syntax is as follows below.
  • Note that your source_directory will typically be the name of your VM
  • Your destination is the name of your target ESX server
scp -r -C -o CompressionLevel=6 source_directory root@destination: /vmfs/volumes/data_store_name

Using compression is optional, but it will speed things up a bit. You can leave this bit out if you want: -C -o CompressionLevel=6

If you receive this message, say yes:

The authenticity of host 'server (10.11.2.120)' can't be established.
RSA key fingerprint is 49:04:65:6e:20:40:e0:fc:a6:75:14:10:bf:6e:a7:70.
Are you sure you want to continue connecting (yes/no)?

  • Once finished, log on to the destination ESX using VIC
  • On the summary tab browse the datastore where the VM was copied to
  • Right-Click on the vmx file and select 'Add to inventory'
  • Fill in the form with relevant values
  • Power up the VM and create a new identifier for the VM if prompted
  • Check if everything is working correctly
  • Backup the VM on the source server before deleting the files

Technorati Tags:

Vista: Run a script at shutdown

I wanted to configure my Vista Home Premium machine to run a script at shutdown, to synchronise "My Documents" to my file server. On my old XP workstation this was done by editing the local group policy and specifying a shutdown script, and then configuring PathSync (a nice free app) to sync the files to a remote location. The challenge this time is there is no local group policy editor on Vista Home premium.

Options
1. Install some software that modifies the shutdown routine
I didn't really want to do this. I've only had this machine a few weeks and want to keep it free of software that could mess things up. I also don't want to pay for a solution, if possible.

2. Windows registry editing
Every local group policy has a corresponding registry entry, so I wondered if in the absence of the group policy editor, I would just be able to create the relevant registry keys and values to run a script at shutdown. Microsoft kindly provide a list of group policies and where they are configured in the registry, so I downloaded it to have a look. Sadly I couldn't find what I needed in here.

I also wondered if I would just be able to export the existing key from my XP machine into Vista, I tried this but that didn't work either - looks like this was because it references the name of a local group policy, which of course didn't exist on my new machine.

3. Windows task scheduler
The Vista task scheduler is actually very good. You can schedule tasks to run when specific events are written to the event log, such as Event 4634 in the security log (Log Off). I tested and found this would actually work if I used the log off feature, but when shutting down, the OS does not wait for scheduled tasks to finish so it only gets to run for a few seconds.

4. Use a VBScript to sync and shutdown
This is how I've implemented this solution - for now. I've created a VB Script which brings up an "Are you sure you want to shutdown" dialog, if you click yes, it syncs to my remote machine and then shuts down. Then I created a shortcut to the script and added it to the quick launch buttons, next to the start menu button. As a final touch I changed the icon to the same power icon that Vista uses for shutdown.

Shutdown icon
Shutdown button

The snag is of course you have to remember to click on this button to shutdown if you want your documents to sync, if you forget and use the usual shutdown option on the start menu, you get no backup for that session. This also means that it doesn't sync when you reboot, and you also don't get the option to install Windows updates before the computer shuts down.

Anyway here is the script:

Set objShell = CreateObject("Wscript.Shell")
Set wshShell = WScript.CreateObject ("WSCript.shell")
strShutdown = "shutdown -s -t 0 -f"

Continue = MsgBox ("Are you sure you want to shutdown?",vbYesNo + VBCritical, "Shutdown computer")

If Continue = vbNo then

' Do nothing

Else

' This box will disappear after 5 seconds.
intReturn = objShell.Popup("The computer will now sync and shutdown.", 5, "Shutdown computer", VBInformation)

' Run synctoy - just change "MyDocs" to the name of your folder pair.
wshshell.run """c:Program FilesSyncToy 2.0 BetaSyncToyCmd.exe"" -RMyDocs", 6, True

' Shutdown the computer
objShell.Run strShutdown

End If

One slight annoyance is the SyncToy command prompt window opens minimised, but I can live with that for the moment. I tried a number of sync tools before settling with MS SyncToy. I did try using rsync which I thought may be a bit faster due to it's compatibility with Linux, but the scanning of the folders took forever.

Technorati Tags: , ,

Cheating with ESX Server Starter Edition

ESX Starter Edition is a standalone ESX server (i.e. no Virtual Centre), available at a lower cost than the ESX Infrastructure editions but missing some useful functions. Some of those functions are the ability to convert virtual machines to templates simply by right-clicking on them, and deploying VM templates with a single mouse click. With the Starter Edition this is how you can get around it:

Create template
Install and configure your virtual machine exactly how you want it. Give it a generic name like "TEMPLATE" and leave it in a workgroup. If your template is a Windows 2003 server "sysprep it" by following this article. Power your VM down and your template is now ready.

Deploy the template
This is how it works:

  • Create a new Windows 2003 VM, configure the disk to be as small as possible
  • After creation, edit the VM settings and delete the disk
  • Open an SSH session to the ESX server using Putty
    • cd /vmfs/volumes/ESXservername\ storage/TEMPLATE
  • Copy the VM disk to the new machine:
    • cp *.vmdk ../new_server_name
  • In VIC, edit the settings of the VM, add a new disk, point it to /storage/new_server_name/disk_file.vmdk
  • Boot the VM up run through sysprep
  • Let it run for about five minutes while sysprep takes place, set computer name and NIC details etc when prompted
  • The server will then restart.
  • The server is now ready and just needs to be joined to the domain.

The whole process should take no longer than half an hour.

Technorati Tags: ,

Vista backup is stupid.

I've been trying to get Vista to backup files to another computer on the network, and it's just not having it.

The remote machine is a Linux computer on the network. If I click open the Vista menu, and then type \\servername\backups, it opens straight away and I can drop files in there and do whatever I like in the remote location.

But, when I use "Backup status and configuration" to set up a new backup job and set the remote location to "\\servername\backups", first it asks for a password (which I enter - this is the Unix password for user Ben), then I get this message:

Error Message
Vista doesn't like Samba?

But that's not the end of it. If I then go back to my remote backup location, I can see a new file in there called SDT97DB.tmp and a folder with a randomly generated name - so, it clearly can access that location as it has created folders and files there!!

Not sure if this is a bug with Vista or a compatibility issue with Samba but it's damn annoying!

Technorati Tags: , ,

Script to remotely backup multiple IIS metabases

This is a script to backup IIS metabases to a network share. To run this script you need to create a file called iisservers.txt in the script's working directory and add the names of the IIS servers into it, one on each line. Substitute servername and sharename with the destination on your network. The forfiles statements will delete backups older than 7 days. The -7 variable can be changed to suit your needs.

Some of the text has wrapped to the next line due to the formatting of this blog but when copied and pasted the unnecessary line breaks are removed.

if exist o:\MetabaseBackup goto backup
net use o: /delete /Y
net use o: \\servername\sharename\London\Metabase

:backup
for /F %%i in (iisservers.txt) do cscript c:\windows\system32\iisback.vbs /backup /s %%i /b %%i_metabase /b %%i_metabase /overwrite
for /F %%i in (iisservers.txt) do xcopy \\%%i\C$\windows\system32\inetsrv\metaback\*.* o: /y

:cleanup
o:
forfiles /m *.MD* /D -7 /C "cmd /c del @file"
forfiles /m *.SC* /D -7 /C "cmd /c del @file"
c:
net use o: /delete /Y

The script can then be configured to run as a scheduled task, using an account with the appropriate permissions to your IIS Servers.

For backing up SSL certificates there is a vbscript on Technet that can do all certs in a batch job, as appose to one site at a time as with IISCertDeploy.vbs in the IIS 6 Resource Kit.

Technorati Tags: , , , ,

How to repair a trashed IP stack on Windows 2003

Last week I had a BSOD error on one of my MailSweeper servers. Afterwards when it booted into Windows it had disconnected itself from the network and the IPSec service would not start. I'm sure they were having a good laugh at Microsoft when they decided how to word this error message:

Cannot start the IPSec Service
What failed?

The winsock stack can be reset from a command prompt using:

netsh int ip reset resetlog.txt

However in my case it was throwing up this error:

Initialization Function InitHelperDll in IPMONTR.DLL failed to start with error code 10107
The following helper DLL cannot be loaded: DHCPMON.DLL.
The following helper DLL cannot be loaded: WINSMON.DLL.

Thinking back to my NT4 days it used to be possible to reinstall the IP stack by simply removing and adding the TCP/IP protocol, but in Windows 2003 (and XP) it's a core component of Windows and the 'Uninstall' button is disabled. So, if you need to do this then this technet article can be followed. If you're not doing this work on a DC, then booting up into Safe Mode is fine - that's what I did and it worked like a charm.

Technorati Tags: , , ,

Things that MIMESweeper can’t do

Question: What happens when a user sends a 1Mb e-mail to 2000 external recipients, and also requests delivery receipts?

Answer: MailSweeper delivery service will die and mail will start to queue on your server. Messages will build up in the 'domains' folders and in 'holding' as your the policy server becomes unable to deliver any more mail.

This happened to me today. It was noticed early as I use an spool watching utility (free on JMC's mswtools.org) which uses blat to send alerts when the number of files in the MSW spool directories go over certain thresholds.

According to the ClearSwift engineer I spoke to, the problem is to do with the way the delivery service can only handle 50 threads at a time. One would imagine a policy server would cope with 2000 messages being dumped on it but apparently this will just keel it over. Multiple reboots did seem to give enough short bursts to clear the 'domains' queues apart from one internal domain containing around 800 delivery receipts and 100 business e-mails. The problem was, on most of these delivery receipts and delivery failures the original message was attached, and the queue was standing at around 900Mb. This would not clear and forcing a retry seemed to make the processing just freeze up. Unfortunately MailSweeper lacks controls on this part of the homepage to delete items in the delivery queue, so to purge all of the delivery receipts I had to delete the corresponding files in the file system on the PS. The problem to overcome then is, how do you make sure you only delete the delivery receipts when the folder is full of randomly named RCP files? I used the following commands within that domain folder to achieve this:

findstr /S /M "Message relayed" *.RCP > output.txt
FOR /F %I IN (output.txt) DO del %I

Tomorrow I'll be implementing a much lower limit on the number of recipients per message that can be sent through Exchange, and of course suggesting a better method of delivering this PDF in the future. I'm thinking Morse code ...

Edit: Just found the default in Exchange 2003 is a maximum of 64000 recipients per message!

Technorati Tags: ,

Upgrade ESX from 3.0.0 to 3.0.1

There seems to be some debate on whether in-place upgrades of ESX server are a good idea, or whether it's better to abandon old versions and go for clean installs. My opinion is that if your server is healthy and you don't have any issues or problems, then there's no need to be scared about upgrading your existing installation.

First download it from vmware and untar it:

tar zxfv 3.0.1-32039-full.tgz
cd 32039
ls

You will the tarball contains a load of .rpm files. Updating from this directory should then be as easy as:

/usr/sbin/esxupdate -n update

However if you have already done some patching on your server you may receive the following error:

INFO: 1 packages need to be downgraded.
Please use the --force option and try again.

Do not use the --force option in this situation as doing so will downgrade your previously installed patches. Instead, check your update log and see which packages are flagging the errors.

grep -i downgrade /var/log/vmware/esxupdate.log

Then use the -x switch to exclude those patches from the esxupdate.

/usr/sbin/esxupdate -x VMware-esx-scripts.i386 -x krb5-libs.i386 -n update

The -n switch supresses an automatic reboot so you can review the output of the command, but you will need to restart your server when the update has finished.

Technorati Tags: ,

Patch ESX Server, the easy way

I've discovered a really great tool for patching ESX servers from Windows: VMTS Patch Manager. It's a bit like WSUS in that all patches are downloaded once to a central repository and you select what you want pushed out from there. You don't need to log on to any ESX servers or spend any time at the command line, and it integrates with Virtual Centre which enables you to manage the patching of your whole virtual infrastructure by connecting to one place. All this is packaged in an easy-to-use GUI and available to download for free.

ESX Patch Manager
VMTS Patch Manager

It's also clever enough to recognise patches that will downgrade your system or are not required, and it will not install them for you. It's not quite perfect and does have a few quirks and rough edges, but I would definitely recommend the download if you have an ESX deployment that needs patching. I've seen a few alternatives to VMTS Patch Manager that are basically perl scripts and http repositories, but nothing else I've seen is as good as this.

Technorati Tags: , ,