Wednesday, July 22, 2009

Virtual Iron > XenServer Raw LUN Server Conversion

Several of our Virtual Iron VMs where created without making a virtual storage disk and where mounted as raw LUNs instead. Servers without a virtual storage disk in VI can't be exported via the VI gui.

For this I ran a P2V conversion using XenConvert v2.0.1.


  1. Log into the server needing converted.
  2. Install XenConvert
  3. Remove Virtual Iron Tools and reboot
  4. From "This Machine (machine name)" To "Xen Virtual Appliance"
  5. Select the disk to convert and a location to store the conversion. In order to get this to work I had to map a network drive to the server with a drive of E (C for local disk and D for cdrom). According to the XenConvert guide this is a known issue.
  6. Conversion took a long time on a 20GB drive. This was due to it pulling the drive into a .vhd and then converting the .vhd into XVA.
  7. Import the ova.xml the same as outlined in Virtual Iron > XenServer Conversion

Important: the initial boot of the server was fine, but after a shutdown I began to receive the error "NT Detect Failed" when booting. I was able to fix this by booting to the installation CD and running a repair (R). Once at the prompt I ran chkdsk /r which resolved the issue

Note: I found it extremely important to remove the VI Tools before the conversion. Otherwise a lot of issues would begin on the second boot of the VM.

Tuesday, July 21, 2009

XenServer iSCSI SAN Setup/Config

There are 2 ways to setup iSCSI SAN connections in XenServer. Via cli or gui.

Create Bonded connection
  1. Click your Pool
  2. Click a Host
  3. Click NICs tab
  4. Click Create Bond
  5. Add NICs
  6. Create
  7. I then recommend going to Network and naming the bond that shows something understandable
GUI Method
  1. Click Server drop down then Management Interfaces
  2. Click New Interface at the bottom
  3. Name the MI and select the Network NIC
  4. Enter IP information

CLI Method

  1. Open the cli for the server needing connection to the iSCSI SAN
  2. Type "xe pif-list" to get the uuid of the pif you want to alter (note that eth0 is listed at the bottom)
  3. xe pif-reconfigure-ip mode=Static uuid=(enter uuid) ip=IPaddresshere setmask=255.255.255.0
  4. xe pif-param-set disallow-unplug=true uuid=(enter uuid)
  5. xe pif-param-set other-config:management_purpose="Storage" uuid=(enter uuid)
  6. At this point you should be able to ping an iSCSI storage node from the server console
  7. Don't make the same mistake I did... remember to give the server node access permissions within your SAN management interface so that it can discover the Target IQN. To find the IQN of the node type simply open the server node properties. On the General tab it is listed at the bottom. Change it to a desired IQN.
  8. Click Storage and select iSCSI
  9. Type in the IP of the Storage server target host
  10. Click discover IQNs then discover LUNs. Click Finish. Note that you will want to ensure that you have exported your VI server prior to connecting to any existing VI LUNs as it will format the disk for XenServer use.

At this point I went on to import the converted VI server onto the disk. Note that initial attempts to import a 19.99GB export onto a 20GB disk failed saying that their wasn't enough space. To get around this I edited the volume to have an additional .5GB. Less than this would have likely been sufficient. I then followed the import steps from Virtual Iron > Citrix XenServer Conversion to successfully import the VM.

Monday, July 20, 2009

Virtual Iron > Citrix XenServer Conversion

With the purchase of Virtual Iron by Oracle we decided to move away from VI/Oracle and into the realm of either MS HyperVisor or Citrix XenServer. This lead us to the need of converting Virtual Iron VM's to XenServer VM's as we tested out Citrix XenServer.

I began by removing the Virtual Iron tools installation and then exporting a test server that was created with a Virtual Iron logical disk (ie boot source of "Disk") to a .vhd format. Download and Open XenConvert v2.0 and convert from VHD to Xen Virtual Appliance format. This will create an ova.xml and related directories for importing into XenServer (you could convert directly into XenServer as well). Open XenServer and select Import > Browse > change file types to "XenServer Virtual Appliance Version 1 (ova.xml) > select the ova.xml file > Select Home Server > Select Storage > Click Import.

A 20 Gig .vhd took approx 20 mins to import and I didn't see a progress bar. Instead when it was completed the option for starting the server became available. Once the VM was started I removed the VI tools and installed the XenServer tools.

I haven't attempted a server that is raw LUN boot (ie boot source of SAN), but will post when I do and whether it's successful or not.

Edit: The import progress bar is displayed on the logs tab.

Note: I found it extremely important to remove the VI Tools before the conversion. Otherwise a lot of issues would begin on the second boot of the VM.

Monday, June 29, 2009

PHP Error Logging

Enable php error logging
Edit php.ini
Find the variable "error_reporting"
Set "error_reporting = E_ALL"
Find the variable "log_errors"
Set "log_errors = On"
Find the variable "error_log"
Set "error_log = \path\to\valid\logs\phperrors.log"

http://www.mwusers.com/wiki/index.php?title=PHP_Configuration#Enable_php_error_logging

Saturday, June 27, 2009

Install MediaWiki on Server 2008

MediaWiki successfully installed/running on Windows 2008 with the following:
Windows Server 2008 Standard SP1 (Virtual Machine)
PHP v5.2.9
MySQL v5.1.34
MediaWiki v1.14

Install IIS7 on Windows Server 2008
  • Open Server Manager
  • Add Role - Web Server
  • Click - Add Required Features
  • Next, Next
  • Select CGI option under Application Development
  • Click Install
  • Install update for FastCGI - KB954946


Install PHP v5.2.9-2
  • Create a new directory: C:\PHP
  • Extract the contents of php-5.2.9-2-Win32.zip to C:\PHP
  • Navigate to C:\PHP and change the name of "php.ini-recommended" to "php.ini"
  • Open php.ini and uncomment the following (uncomment by removing the ;)
    1. open_basedir (then add the following = "C:\inetpub\wwwroot"
    2. extension_dir (then change to show as "./ext"
    3. cgi.force_redirect = 0 (change from 1 to 0)
    4. cgi.fix_pathinfo=1
    5. fastcgi.impersonate = 1
    6. extension=php_mysql.dll
    7. extension=php_mysqli.dll
    8. upload_tmp_dir="C:\inetpub\wwwroot\WikiName\upload" Create a new folder in C:\inetpub\wwwroot\WikiNam named "upload"
    9. session.save_path = "C:\php\session" Create a new folder in C:\PHP named "session".
    10. IMPORTANT - Ensure that the session and upload folders created have write permissions for Users.
  • At command prompt navigate to C:\PHP and type enter php -info (ie C:\PHP\php -info) You should see the config of php or a lot of information scroll across the screen
  • Open IIS Manager
  • Open Handler Mappings
  • Select "Add Module Mapping"
    1. Request path = *.php
    2. Module = FastCgiModule
    3. Executable = C:\PHP\php-cgi.exe
    4. Name = PHP via FastCGI
  • Click OK, then Yes when prompted
  • Navigate to C:\inetpub\wwwroot and create a new file named phpinfo.php then edit the contents to show (I can't seem to get blockquote to work for anything so...) Starts with lesser than sign (no space) then ?php phpinfo(); ? followed by greater than sign (no space)
  • Open IE and navigate to http://localhost/phpinfo.php the site should display as PHP Version 5.2.9-2 with other config data on the rest of the page


Install MySQL v5.1.34
  • Run mysql-5.1.34-win32.msi to install
  • Typical install
  • Default Location
  • Configure the MySQL Server now option checked
  • Change to standard configuration
  • Install as Windows Service (Default)
  • Uncheck Modify Security Settings (This will be changed later)
  • Execute (note that it may have errors and fail, if so hit cancel)
  • From a command prompt navigate to C:\Program Files\MySQL\MySQL Server 5.1\bin
  • Type mysqladmin -u root password NEWPASSWORD


Install MediaWiki v1.14
  • Create new directory C:\inetpub\wwwroot\WikiName
  • Copy mediawiki-1.14.0 contents to C:\inetpub\wwwroot\WikiName
  • Run the following at a command prompt to grant permissions to the config folder (so that it can write the localsettings file) icacls %SystemDrive%\Inetpub\wwwroot\MediaWiki\config /grant BUILTIN\IIS_IUSRS:(W)
  • Open IE and navigate to http://localhost/WikiName/config/index.php
  • Enter Wiki name: WikiName
  • Database Config
    1. Database name = WikiName
    2. Username = root
    3. Password = MySQL root password
  • Click "Install MediaWiki!"
  • At the bottom of the next page you should see "Installation Successful!"
  • Close IE
  • Copy the localsettings.php from C:\inetpub\wwwroot\WikiName\config to C:\inetpub\wwwroot\WikiName
  • Open IE and navigate to http://localhost/WikiName/index.php You should see the Main page "MediaWiki has been successfully installed"
  • Delete the config folder
  • Change permissions on the WikiName\Images folder so that Users and IUSR have write access (for uploads to work)


Other Goodies to enable:
Uploads
* $wgEnableUploads = true;
* $wgFileExtenstions = array('png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'pdf');
* $wgVerifyMimeType = false;

Disable reading by anonymous users
* $wgGroupPermissions['*']['read'] = false;
But allow them to read e.g., these pages:
* $wgWhitelistRead = array ("Main Page", "Special:Userlogin", "Help:Contents");
* $wgGroupPermissions['*']['edit'] = false;

Custom Logo
* wgLogo = "{$wgScriptPath}/ImageName.jpg"; (image saved in the WikiName root folder)

Thursday, June 25, 2009

Batch File Date/Time in Filename

I wanted to create a batch file that made a mysql backup with the dbname, date, time in the filename:

for /f "tokens=1,2" %%u in ('date /t') do set d=%%v
for /f "tokens=1" %%u in ('time /t') do set t=%%u
if "%t:~1,1%"==":" set t=0%t%
set timestr=%d:~6,4%%d:~0,2%%d:~3,2%_%t:~0,2%%t:~3,2%

"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqldump" -u root --
password=YOURPASSWORD dbname > "C:\MySQLBackups\wikidbname\dbname-%timestr%.sql"

I then set it to look for and delete backups that where older than 14 days.

cd c:\MySQLBackups\wikidbname
forfiles /d -14 /c "CMD /c del @FILE"

Note: Make sure that there are NO FILES in the directory specified or they will be removed to include this batch file if you place it in that directory

Monday, June 22, 2009

WindowsUpdate_80070424

After fresh install of Windows Server 2008 I was recieving this error on Windows Update

Running the following fixed it:
REGSVR32 %SYSTEMROOT%\SYSTEM32\WUAUENG.DLL

Saturday, June 20, 2009

MySQL 5.1 Backup / Restore

Here is the process I came up with to backup and restore a MySQL v5.1.34 Database

To Backup:
mysqldump -u root --password=PASSWORD dbname > c:\mysqlbackups\backupfile.sql

This can then easily be entered into a batch file and run via scheduled tasks for regular backups.

To Restore:
mysql -u root --password=PASSWORD dbname < c:\mysqlbackups\backupfile.sql

Note: mysql and mysqldump are located in the installation directories bin folder

It's also important to note that the generated backup file could be used in other DB engines since it is just SQL statements that recreate the DB and populate the data.

Wednesday, June 17, 2009

"The system cannot find the drive specified" Windows 7

Windows Vista was a bust imo, I dislike it like I disliked Windows ME. So this week I downloaded Windows 7 RC to see how it fairs.

Download was long, but I just let it run overnight and then continued with the install in the morning.

Installation:
I installed Windows 7 RC into a Virtual Iron virtualization environment. Install was easy with no issues at all. I gave the install 2GB RAM, 2 CPU's at 2.66GHZ each and 20GB HD (the VI backend storage is iSCSI SAN). Installation was actually very fast and I was up in no time.

Experience:
Icons in the task bar seem so large and take up to much space imo. Right click, properties, check use small icons. Only problem I see at this point is that each button needs several pixels shaved off each size so they aren't as wide anymore. Just an annoyance.

------------------- SOLVED - Solution below -----------------
Open cmd prompt, U: enter.... "The system cannot find the drive specified"
Hmm... Try it on XP, works just fine. K. Look under Computer and yep, all my drives where mapped from the domain logon script. I do have a U: drive according to the "Computer" view along with all my other normal mapped drives, but the U and I notice that my R drives do not have permissions. Being a Domain Admin I most definitely do have permissions. Strange, then I realized that the missing drives are DFS mapped drives... All non-DFS drives show up.
After a little research I figure out that using the Pre-Windows 2000 domain name is what doesn't work. If I enter the FQDN then it works fine.

This is actually more of an issue that it sounds like. With 250 users with shortcuts mapped out to the pre-windows 2000 domain name changing this will break a lot of links in documents and shortcuts.
-----------------------
This was actually a very simple fix. Simply remove the workstation from the domain and then rejoin. The Win7RC workstation had been restored to a prior state from a snapshot that was made on the iSCSI SAN. From the time that the snapshot was made to the time of the restore the computers domain password had changed. As such it no longer matched up and didn't have the proper permissions as a result.

Block unwanted sites with HOSTS File

The other day I got a call from colleague asking about antivirus software. During the conversation he had asked if I was using the HOSTS file from mvps.org. I wasn't but checked it out as it sounded very intriguing.

I've since then applied it to my workstation and I'm seriously considering pushing it down to other users.

Check it out:
http://www.mvps.org/winhelp2002/hosts.htm

Sunday, June 14, 2009

Citrix - Printer Errors

For a long time our environment has been plagued by an issue that "seems" random where Citrix user logs in, attempts to print from x application, fails with random error.

The errors usually go along the lines of

  • Select a printer
  • No printers installed
The user can't print from some applications while other apps still work fine. Usually the default printer in the applications that do print is not set according to what shows in the Printer Management screen. The printer in question is listed in the Printer Management screen.

Attempting to delete the printer from the Print Management screen results in a error "Cannot delete client printer" (the error is a little longer, but I don't have the exact error in front of me atm)

From there simply adding the printer again fixes the issue and even allows the printer to be deleted.

Looking at the users profile hive in the registry shows that the printer is listed under HKUSERS/UserSID/Printers and removing it here removes the printer in the Print Manager screen, then adding the printer back resolves the issue.

Things to note:
All drivers are either:
  • Native Drivers
  • Stress Tested
This does not occur with "auto-created" printers, but rather normally with printers that are assigned via Citrix print policies.

What really annoyed me was that the user couldn't delete the printer unless they re-added the printer first. This led me to believe that perhaps the printer registry keys do not have the proper permissions for the user to remove them (simular to the administrator access denied issue)

With this new informmation I began searching and found this: http://forums.citrix.com/thread.jspa?threadID=73770&tstart=0
which in turn quickly led to this: http://support.citrix.com/article/CTX106744

I have since added the x2 to my DefaultPrnFlags key to make it now appear as 0x28004000

8000000 for the auto Creation event log errors and 4000 for adding the administrator permissions to the printers.

Time will tell if this fixes the problem for Windows2003 (note the article mentions that it is fixed in Windows2008 since w2k8 maps the printers differently)

Thursday, June 11, 2009

Disable UAC

Here's how to disable UAC in Vista, Windows 7, and Server 2008

Vista and 2008
Control Panel > User Accounts > Turn User Account Control on or off

Windows 7
Control Panel > System and Security > Action Center "Change User Account Control settings"
Use the slider up and down to set the UAC level.

Wednesday, June 10, 2009

Mass file copy

Recently I needed to copy a shortcut to a mass number of users. Since we utilize Citrix this made the task considerably easier for me. We redirect all user settings to a central location so I was able to easily script out the copy using a Text file that contained the names and Loop through all the user names.

Created the shortcut to be copied and the text file in the following format:
username1,username2,username3,etc

Code:
Dim FSO
Dim fREM, fLOC, answer, cUser
Const ForReading = 1
Set FSO = Wscript.CreateObject("Scripting.FileSystemObject")
answer = MsgBox("Run the file copy?", 1)
If answer = 2 Then
msgbox "You pressed cancel"
Else
Set objTextFile = FSO.OpenTextFile("c:\ShortcutCopy\names.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
cUSER = Split(strNextLine , ",")
Do
fLOC = "C:\ShortcutCopy\ShortcutName.lnk"
fREM = "\\path\path\path\" & cUSER(i) & "\path\desktop\ShortcutName.lnk"
msgbox "Copying to " & fREM
FSO.CopyFile fLOC , fREM, True
i = i + 1
Loop While i<20
Loop
msgbox "Copy completed"
End If

Friday, June 5, 2009

Citrix Printers - Creation Errors

Default installs of Citrix have creation logging turned on by default. This can cause a lot of excess errors in the eventvwr which generally are not useful.

Add the following
HKEY_LOCAL_MACHINE\Software\Citrix\Print
"DefaultPrnFlags"=dword:08000000

You can combine this one with the Access key by making the dword:08004000 Citrix Printers - Access Denied

Tuesday, June 2, 2009

Citrix Printers - Access Denied

By default I've found that in Citrix admins do not get permissions to auto-created printers.
Add the following
HKEY_LOCAL_MACHINE\Software\Citrix\Print
"DefaultPrnFlags"=dword:00004000