Author Archive for Ben Stokes

Exchange mailbox store restores

This week I've had to refresh my memory with something I've not done in a long time. I had to recover a mailbox store for an urgent mailbox restore, but in this case the server that was the home of the mailbox at the date they wanted had been decommissioned long ago. This presents a problem with a) the recovery storage group, as the 'add database to recover' dialog will not show the store, and b) backup exec, which wants to log on to the old server for some reason! This is how it was done (our servers are all Exchange 2003 SP2 (native mode) and backup exec is 11d).

Also for a quick sanity check before kicking off the restore I had checked the database tab on all the stores, just to check 'this database can be overwritten by a restore' was not checked.

For an older Exchange restore (Exchange 5.5) you would need a temporary server to rebuild to replicate your old 5.5 environment.

Starting up

1.    Recall the tape!
2.    Inventory the drive and catalog the tape. Note the mailbox store name that contains your target mailbox.
3.    On the server you are using for recovery, create the recovery storage group (this can have any name, just ensure there is enough disk space for the database files where you create it)
4.    Say for example the store you need to recover is called “Mailbox Store 1 (SVHEXBETEMP01)”. Obviously when you right click on the RSG and select “add database to recover”, this database will not be in the list. To get around this, you have to create a new mailbox store that has this name. You can do this on any server in your org. The name has to match exactly with the store you are recovering.
5.    Now right click on the RSG and select ‘add database to recover’ and add the new store.
6.    Go back to Backup Exec. Click Restore -  new restore job (not by wizard)
7.    Change beginning backup date as required.
8.    View by resource, and drill down to the required store
9.    Under Microsoft Exchange Redirection, check ‘Redirect Exchange sets’. Enter the server name to redirect to
10.    Under Microsoft Exchange, select ‘Restore all transaction logs until point-in-time; skip transaction logs after this time’
11.    Change path for storage of temporary files to a volume that has plenty of free space.
12.    Uncheck mount database after restore.
13.    Run now!

Restoring the mailbox

1.    If the mailbox you are restoring still exists in your org, migrate the mailbox to your new store (e.g. “Mailbox Store 1 (SVHEXBETEMP01)”)
2.    If they mailbox does not exist, create one with the same name in this store.
3.    In the RSG, right click on the target mailbox and use the recovery option. Select the target (you probably will not be able top modify this option)
4.    Copy option is safer than Merge.
5.    Now you can use ExMerge to extract the PST, or just tell the user their data has been recovered.

Cleaning up

1.    Migrate the user back to their original location.
2.    Delete the temporary mailbox store.
3.    Delete the recovered mailbox store and recovery storage group.
4.    Delete the database files from disk.

Run a scheduled task using VBS

One of our users has an occasional requirement to manually run a scheduled task on a server. I wanted him to do this without logging on via RDP. Scheduled tasks can be run remotely using the SVHTASKS program (on Windows XP and Server 2003) so I started writing a VB Script to call this app. The tricky part was capturing the output of the command and displaying that back to the user, so he would know if it was a success or failure. It turns out this is actually quite difficult to do, so I hacked up various other scripts I found on the web until I eventually got this to work. The working version is below.

strServer = "your_server_name"
strTask = "task_name"

Continue = MsgBox ("Scheduled job " & strTask & " will run on " & strServer & ". Are you sure?",vbYesNo + VBQuestion, "Run scheduled task")

If Continue = vbYes then

Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1

sExe = "SCHTASKS /Run /S " & strServer & " /TN " & strTask

Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
sTempFile = oFSO.GetSpecialFolder(2).ShortPath & "\" & oFSO.GetTempName

oShell.Run "%comspec% /c " & sExe & " >" & sTempFile, 0 , True

Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist, OpenAsASCII)

' capture  output and inject into a variable
sResults = fFile.ReadAll
fFile.Close
oFSO.DeleteFile(sTempFile)

MsgBox sResults , vbInformation , "Result"

Else

wscript.quit

End If

Resize swap partitions on Red Hat Linux

First of all a little disclaimer - although I've done this a few times and never had any problems, one should never consider resizing partitions a completely foolproof exercise. Things can go wrong. With regards to swap though, don't worry if your swap partition is destroyed as this will not harm your system - most healthy systems will not ever need swap and unlike Windows, Linux only starts using swap when it needs it and can quite easily survive without it. You can trash it and format it as many times as you like as long as it's not in use. And of course take backups of any important data first!

Resize swap partition in Red Hat Linux

  • Download gparted (Gnome Partition Manager), burn the iso and then boot into it.
  • Gparted will identify the filesystems on each partition so your target will be clearly labelled as swap.
  • Reize your partitions as required. Try to minimise the overall number of resize and move operations as this can take several hours to complete.

When you reboot swap not be enabled - if you check using top (or htop) or free -m, you will see 0 mb of swap available. The reason for this is the UUID of the partition changed when it was resized by GParted, and this confuses the system when it tries to mount the volumes in /etc/fstab. The solution is to relabel your swap partition, by reformatting it as swap and specifying the correct label.

fdisk -l | grep swap

Note down the device name of your swap partition. e.g:

/dev/cciss/c0d0p3 1926 3837 15358140 82 Linux swap

Make a note of the label for the swap partition from fstab:

cat /etc/fstab | grep swap

e.g.

LABEL=SW-cciss/c0d0p3 swap

Now format your partition as swap, specifiying the label exactly as shown in the fstab.

mkswap /dev/cciss/c0d0p3 -L SW-cciss/c0d0p3

You can then enable the swap space straight away by using swapon devicename, or just reboot and check with free -m again, and all should be ok.

bash vs vbs (bash wins)

I've been asked by a group of users if they can have a daily report of everything the fax server has sent. Since the fax software we're using doesn't have this feature, I thought I'd write some vb script to pull all of lines containing yesterday's date from the log file (called sendlog.txt) and email them to a public folder. This took an hour or so to create and looks like this:

Const ForReading = 1

Dim fso, TempFile, yesterday, strSubject
yesterday = Date - 1

Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = yesterday

Set objFSO = CreateObject("Scripting.FileSystemObject")

If (objFSO.FileExists("C:\temp\output.txt")) Then
 objFSO.DeleteFile "C:\temp\output.txt"
End If

Set objFile = objFSO.OpenTextFile("C:\Program Files\GFI\FaxMaker\sendlog.txt", ForReading)
Set TempFile = objFso.CreateTextFile("C:\Temp\output.txt", True)
Set wshShell = WScript.CreateObject ("WSCript.shell")

TempFile.Write "Fax Server sendlog for " & yesterday & vbCRLF & "----------------------------------" & vbCRLF & vbCRLF

Do Until objFile.AtEndOfStream
    strSearchString = objFile.ReadLine
    Set colMatches = objRegEx.Execute(strSearchString) 
    If colMatches.Count > 0 Then
        For Each strMatch in colMatches   
           TempFile.Write strSearchString & vbCRLF
        Next
    End If
Loop

objFile.Close
TempFile.Close

strSubject = "FaxMaker_Sendlog_" & yesterday
wshShell.run "C:\monitoring\blat262\full\blat.exe" & " " & "C:\temp\output.txt" & " -to " & "myaddress@mydomain.com" & " -subject " & strSubject

Partial credit goes to the MS Scripting Guy who had already published part of this for me. Also you'll notice I called blat to email the file, which is considerably less complex than sending it in the vbs (or cheating, as some might call it) ... using vbs to send the message would have doubled the amount of code!

To accomplish the same task using a bash script, you could do it like this:

echo "Fax server sendlog for `date +%d/%m/%y`" > /tmp/tempfile.txt
cat /var/log/sendlog.txt | grep `date +%d/%m/%y` >> /tmp/tempfile.txt
mail -s "Fax Server log for `date +%d/%m/%y`" myaddress@mydomain.com < /tmp/tempfile.txt

Much simpler I think - only 3 lines of code!! People say Linux is harder than Windows but I think this proves that is not always the case. Manipulating files and data in Linux can take considerably less effort if you know which tools to use and how to use them.

Oracle RAC, CentOS and GFS

One thing I'm currently working on is a 2 node CentOS cluster using GFS as the shared file system, with the storage on a fibre attached HP MSA SAN. This is a proof of concept before investing in RHEL AS licences (which will be the better part of £2000). CentOS is free and is intended to clone RHEL as closly as possible, removing the Red Hat branding and of course professional support. The cluster suite and GFS are available in CentOS as they are both open source.

The hardware I am using is 2 HP DL580 G4 servers with 12GB of RAM, Qlogic HBA's, and an MSA1000 SAN. I'm using this guide on Red Hat's website and have been making my own notes along the way. I've got as far as installing cluster suite on one node but I'm unable to choose the grand unified lock manager as it doesn't appear as an option. I expect this may take a bit of reading to get working ... I'll post a mini howto here when I make some decent progress.

A while ago I undertook a similar exercise and had problems getting the HP ACU to see the SAN under Red Hat, I had to get HP involved as there were specific versions of the kernel and drivers required for it to work properly. I've noticed I have the same problem time time, but now I am on CentOS and it's the x64bit version, so it looks like I will have to experiment with driver versions and see what I can get to work without any support this time.

Red Hat Summit 2008 - closing post

In short - it's been good, a valuable use of my time. The presentation throughout the summit was of a very high standard, and this included the catering too.

If I had to summarise the summit I would do so using the following 5 buzzwords:

1. Virtualisation. Guess what ...? Red Hat has their own virtualisation product. It looks very promising but if I am brutally honest (and Red Hat would kill me for saying this), they are pretty much in the same boat as Microsoft. By that I mean they are leagues behind what VMWare are offering right now. But it wasn't just Red Hat banging on about virtualisation. All the vendors in the exhibition hall were touting their products with the big V in mind.

2. Green/Energy saving. Everyone is working towards making their products consume less energy, while giving the user much more back. Red Hat and intel are working towards more closely unifying hardware and software, so that their OS can have much greater control of how much power a device on the system should consume.

3. Cloud computing. Everyone was talking about this. Offload your computing power to other computers in the cloud when you have extreme amounts of processing to do. It's a bit like clustering except you only dip into the cloud when you need to, and the computers in the cloud don't have to be on your network.

4. Red Hat Satellite. A lot of the speakers talked about how they use Satellite to administer their Red Hat servers. And of course there was the big announcement about Spacewalk.

5. Open Source. Red Hat love talking about it and they are very proud about being open source. They even talked about the importance of CentOS and Ubuntu, which surprised me! Moreover, I was astonished that CentOS will be a supported product by Spacewalk. When questioned about Ubuntu, the reply was Ubuntu is not a rival of Red Hat ... as it's going to take more than one player to topple Microsoft!

I'm off home now, but first I'm due a visit to the duty free shop for an extremely large bottle of whisky. Thank you very much HP (but sorry, I'm not keeping the t-shirt) :)

Spacewalk - Red Hat Satellite for free!

Red Hat have made another important announcement at this years Summit - RH Satellite has been made open source! At first I was excited, because:

  • Red Hat customers can save hundreds of dollars as it's now free - you don't have to buy an RHAS licence for a RH Satellite (that is, unless you want support for it).
  • You can run it on Fedora!
  • Community users can add to the code and make it better. By this I mean they can (and will) fix bugs and add enhancements.
  • This is beneficial for Red Hat as these improvements can (and will in due course) be loaded back into the paid RHAS Satellite packages.

BUT .... what you can't do with Spacewalk is update RHEL systems with it - you can only use it to manage Fedora and CentOS systems for now (according to the FAQ). So it's no use to me at the moment as we're a Red Hat shop only .... I guess I'll be waiting for my RHAS system after all.

Red Hat Summit - Day 2

Red Hat logoThere were 2 seminars that stood out for me today after Joel Cowen's (Executive producer of The Simpsons) amusing Keynote speech - did you know The Simpsons is rendered on Red Hat?

The first of the noteworthy seminars was Michael Stahnkage on how to manage RHEL updates. He's one of the few speakers who kept it human and maintained an interesting session throughout with a mix of his own experiences, some real world scenarios, and a bit of dry humour to keep the audience awake. I made plenty of notes which I will be taking with me to begin planning an update strategy for my company's Red Hat servers. For my own reference - the slides are here (in Open Office format).

The other session of interest was a business pitch from IBM (IMO, to a room full of the wrong people) on Red Hat as a desktop alternative for the enterprise. The cost savings are incredible particularly when you replace Microsoft Office with Open Office (or Symphony, as IBM call it). It started to drag towards the end but got more interesting when someone asked about the new Office 2007 formats and compatibility with Symphony, just because we got to see some very senior people from IBM squirming and getting very defensive. They also didn't have an answer for any decent Visio alternative on Linux. I thought their strategy was very interesting and an honourable thing to do, but I think the average consumer will be difficult to migrate from Windows to something alien, especially while sharing documents with Windows users is not straightforward, and application compatibility with browsers other than IE is still an important issue.

Bounty!
I have accumulated a lot of free stuff over the last 2 days:

  • A Tux foam penguin
  • 1GB HP Branded USB key
  • Flashing bouncy ball and stress ball
  • Red Hat baseball cap
  • HP Lip ice sunscreen!
  • HP T-shirt (XL - looks like a tent on me)
  • r1soft.com T-Shirt (XXL - blimey, how big??)
  • zenoss T-Shirt (Medium - which is actually alright!)
  • Red Hat bag and USB key which all attendees received

The HP T-Shirt also had a secondary purpose. If you wear one around the Summit there is a chance to win iPods and iPhones (and other Apple goodies), if you get stopped by HP and correctly answer some questions about ICE-Linux - an HP SIM plugin for managing Linux servers. I opted into this and wore my huge T-Shirt, and when I was stopped and answered my question correctly .... I won $50 in Amex vouchers! Nice - free duty free alcohol for me on the way home!

ZenOss was an interesting product as well, it's a monitoring solution based on Cacti and RRD but with some extra features and paid support thrown in (like viewing your servers on a Google Maps mashup). Really I'm not sure if it's worth it - if you already use Cacti and have time to invest in beefing up your existing environment with all the best plugins available (like threshold monitoring, alerting, syslogs), then you will get pretty close to a ZenOss install out of the box. But that said, if you don't have time or want professional and friendly assistance to set up a comprehensive monitoring solution, then ZenOss could be for you.

In general the exhibition part of the Summit was a bit small, but I've found all of the vendors very friendly and they wanted to discuss how I used Open Source (and Red Hat) in my own workplace, avoiding the hard sell of their own products.

Red Hat Summit - Day 1

Red Hat logoDay 1 has been pretty interesting. The surprise highlight for me was the keynote speech from Dr John Halamka (CIO, Harvard Medical School) about the challenges he faces with computerising patient records for the state of Massachusetts, and how he is using Red Hat and open source technologies to do this. He also described the process of genetically sequencing people, and how some of these records are being stored in an open source Google-powered vault (aptly named Google Health) for access by medical professionals (this process now only costs a mere $10,000 per individual!). The IT Infrastructure he is responsible for is huge. The main data centre in Boston has 250 Red Hat VM's and 500Tb of information that can fail over to a DR site with only 1 second of lost information.

The workshop seminars started off slowly. Kernel optimisation is a fairly dry subject already, so being lectured by Red Hat experts (geeks) in the subject made for a sleepy beginning to the morning. But there were 3 other seminars that stood out for me.

A few months ago I started reading about RH Satellite server and put in a request for the Red Hat AS licence so we could get one running on our network at work. Today I sat in on a case study on Satellite server by PMC-Sierra which made me want one even more. The highlight was discovering you can add your Red Hat boxes to "configuration channels" on the Satellite so that they can automatically receive settings (such as DNS, NTP, etc) and also files and directory structures automatically. Given that the Red Hat infrastructure at my place will probably consist of 10 front end application servers with the same configuration in the future (with a clustered Oracle back end), this means a Satellite will save me a lot of work. For example, each time I wanted to add a new front end, I could just add it to the relevant configuration channel and it would get all of the files it needs automatically. In addition, any hotfixes and updates to the system would just need to be made once to the config on the satellite server, and then the changes could be pushed out to all 10 servers in one hit (or a new config could be created with the hotfix included, which would allow easy rollback to the old configuration in a few mouse clicks). RH Satellite also comes with 24/7 support and the option of professional services to get it set up, which all sounds very appealing.

The other 2 seminars of interest were an introduction to SELinux, including all the things I should have read about already but never got round to, and how to harden a Red Hat server against attacks, which was very handy for those that managed to make it through the dreary presentation. I will cover the highlights of that lecture in this blog (or maybe my Linux blog) in more detail at a later date.

Some pictures of the event are below. If you can't see them, please follow this link.

This SimpleViewer gallery requires Macromedia Flash. Please open it in your browser or get Macromedia Flash here.
This is a WPSimpleViewerGallery

Red Hat Summit 2008

RedHat LogoI've been given a fantastic opportunity to attend this years Red Hat Summit, being held in Boston next week. It's a 3 day event with opportunities to attend seminars, workshops and exhibitions, with a bit of socialising and networking thrown in as well. Hopefully I will come away from the event with some ideas on how my company's Red Hat infrastructure can be better managed and made more robust.

I feel lucky to have the chance to attend this at a time when work is so busy and home life is demanding - I will be leaving my wife at home with a 2 week old baby!

Whilst I'm there I will also be taking pictures and updating this blog with anything of interest.