Wednesday 20 March 2013

AlwaysOn Availability Groups SQL 2012

Overview:  SQL 2012 offers AlwaysON Availability Groups (AOAG)

Notes:
  • All SP2013 dbs support Synchronous Replication via AOAG.
  • Most SP2010 excludes Search, Profiles and Syn (I think).  SP2010 needs SP 1 to use SQL2012 features including AOAG.
  • Synchronous replication requires 1GB+ bandwidth and less than a 10ms latency
  • For AOAG you need Windows 2008 R2 Enterprise edition.  SQL 2012 Enterprise edition
  • Databases need to be in the Full Recovery Model to use AOAG
Download the PS to add databases to existing AG's.

AOAG only support databases that are set to use the "FULL" recovery model.  Multiple SharePoint database are set to use the "Simple" recovery model.  I haven't found anything saying MS will support switching all the databases to the "Full" recovery model.  Performance wise "Simple" runs faster but the benefit of having AOAG is generally worth the change to the recovery model.

Note: SP2010 has several databases that use a simple recovery model (Search, Profile, sync, usageandhealth dbs). 

Note: SP2010 has several databases that use a simple recovery model (4 Search dbs: Search, search_analytics, search_Crawl, search_linkstore.  5) Profile 6) Sync 7) Social 8) UsageandHealth).

Note: The listener and the cluster are created within AD and are added as Computers, this will only use the 1st 16 characters for adding the listen and the cluster, it cuts off the rest.  Make sure the listen and cluster are less than 17 chars.

Note: FS4SP I added the Administrators database for resilience.
FASTSearchAdministors (Full Recovery model) - AOAG works
FAST_ContentService (Simple)
FAST_ContentService_CrawlStore (Simple)
FAST_ContentService_PropertyStore (Simple)
FAST_QueryService (Simple)
FAST_QueryService_CrawlStore (Simple)
FAST_QueryService_PropertyStore (Simple)

Tip: I was performing backups that we corrupting my databases.  Before doing the backup and
Restore to perform the AOAG sync, delete the old backups.

References:
http://www.slideshare.net/michaeltnoel/sql-2012-alwayson-availability-groups-for-sharepoint-2013-sharepoint-connections-amsterdam-2012
http://technet.microsoft.com/en-gb/library/jj715261.aspx
http://blogs.msdn.com/b/sambetts/archive/2013/04/24/sharepoint-2013-and-sql-server-alwayson-high-availability-sharepoint.aspx

"No need for Aliases..".  Aliase have 2 purposes:
1) the database goes down, you get pointed to the alternative database.  AOAG listener does the exact same function so I agree that there is no point in using an alaise for failover.
2) SQL Alaises allow you to split up which database you are working with.  So by having let's say a single AOAG with 2 aliases that point to the same AOAG listener is perfect as later you can move the Search databaases to another AOAG instance and you don't need to re-run the config wizard. 

Minor point but I'd still use aliases on top of AOAG listeners.

The script below runs thru the databases on the 1 server in the AOAG and if they are set to use the "Simple" Recovery Model, it changes the SQL Recovery Model to "FULL".  In my case I have used AutoSPInstaller to build my SP2013 farm.  This has prefixed all my databases with AutoSP_, this allows me to make sure I am only targeting SP database for my change to the recovery model (See line 11).
 

Tuesday 19 March 2013

Automating SharePoint Environment Builds using Team City


"TeamCity is a closed source, Java-based build management and continuous integration server from JetBrains" - Wilipedia.

And for SharePoint build automation it is a nice tool.  I have build scripts for various SharePoint environments and these are automated to run daily or on an adhoc basis.  TFS could achieve all the build pieces I have put together for automating my environment creation consisting of:
  • Create VM's using PowerCLI on VMware ESXi 5.0;
  • Create SQL 2012 databases servers with Always on high availability groups;
  • SharePoint 2013 or SharePoint 2010 with FAST using AutoSPInstaller;
  • Deploying the SharePoint code and creating the sites, webs, activating the features and deploying web parts. 
Below are the screen shots of Team City.


 

Monday 18 March 2013

PowerShell SharePoint web site Warm-up Script

Overview: Useful PowerShell Script to check when a SharePoint website is up and running, I use this a a trigger in my build process.  It can also be used as a warm up script for demo's.

Download SharePoint Warmup script.
Another Nice SP Warmup script for SharePoint.

For public websites you can also use a monitoring service to ensure your website is constantly warm such as AlertFox.

Another Script:
http://www.justinkobel.com/post/2013/08/16/My-SharePoint-2013-(and-2010)-Warm-up-Script.aspx

Tuesday 5 March 2013

Create Web Service Installer using MSI

Overview: The post show how to create an MSI or exe that can be used to deploy assets onto servers.  In this post it will look at packaging up a web service that is added to the msi installer and a custom project is created that will build the IIS instance to host the web service.






http://www.codeproject.com/Articles/16767/How-to-Pass-Command-Line-Arguments-to-MSI-Installe

Thursday 21 February 2013

PS3 with ISE

Key new features:
  • Intellesense
  • Autocomplete with the tab key
  • Regions - not only using the regions keyword but you can also fold up statements for easier reading of code.  A good example is if statments can be foldeed down.
  • Snippets - Can add you own custom snipptes, to see the ISE custom snippets when writing PS click "ctrl + j".  Easy to add you woen snippets.
  • "Show Command2 tool option in ISE is powerful for building PS.
Note: Don't use PowerShell 3 with AutoSPInstaller 3.2 for SP2010 (including using the version switch i.e. -version 2), it doesn't work and even changing AutoSPInstallers internal web call fail. It can be made to work with the version 2 switch but it isn't worth the effort.

Wednesday 13 February 2013

Reboot and Resume and RunOnce PowerShell Script

Overview:  It is fairly common to need a reboot and you want to automatically run some PowerShell once the server is back up.

This package contains 2 PS 1 files (download):
  • Restart-VM.ps1 (Contains all the code to reboot the server and lainch the function from here)
  • Restart-VM-Custom.ps1  (2 functions to add your custom logic.  You can add either to the Pre-shut down code to execute or the PS to run once the server has restarted)
Steps
  1. Extract both PS1 files into the same folder on your machine;
  2. Edit the file "Restart-VM-Custom.ps1", noteably create your custom scripting logic within the "CustomRestartActions" function; and
  3. Run "Restart-VM.ps1" as the administrator.
PS to reboot remote machines:
PS> Restart-Computer -computer 192.168.1.2 -force

RunOnce Example (Download)

1 PS files: 
1st file changes the registry to autologgon and run the runonce.


2nd ps file creates a folder, removes the autologin and reboots

Remote RunOnce using PS, useful for remote builds (Download)

Run on build server to setup RunOnce on the remote server
 Run on the target Remote Machine


Remote PS using Invoke-Remote
 
Updated 10 June 2013: I am using a REG_EXPAND_SZ Registry key type and I have discovered that the value needs to be less than 255 characters.  Mine was 270 odd characters as it had multiple attributes.  E.g.
RunOnce>c:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command " .'C:\Windows\Temp\SQLInstall\Start-ServerCustomisation-SQL-All.ps1' 'k:\SQLInstallerInput-Test.xml' 'k:\\192.168.1.199\c$\LocationNotingDeployment\vSphere\Test /user:xxxxxxxxxxxxxxxxxxxxxxx P@aassssss'"</RunOnce>

My runonce was not firing, however the RunOnce registry key was saved correctly (270 chars).  The command could be executed from the cmd prompt with the longer length but to automate the Reg-Expand_SZ key value needs to be less than 255 characters long.

Friday 1 February 2013

PS functionality - logging, xml, local permissions, remote PS

Read config values from an xml file - download zipped files

Download contains:
PS-Logging.Ps1 - Allows for an optional paramter to set the XML file to read from. Of the input xml is not valid or specified revert to reading a predefined xml file from the same location in the directory that PS-logging.PS1 is saved to.
PS-LoggingMore.Ps1 - Easy way to log the PowerShell consoles actions. As it doesn't work with PowerGui, it will check the IDE.
AutoInput.xml - Is an xml files that is used for configuration of these examples.
PS-Logging.png - describes the workings of the files (ignore).

Other:
Import External Functions (download) - ability to write separate PS files and call the functions within from the main/starting PS file.

Specifying Input Parameters Strict Example:
param(
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]
$configLocation
)

**************************************************

Ability to Execute PS on a remote trusted computer

The PS below has 2 simple functions to illustrate:
  • running a remote PS commands (tip, ensure the PS window is running using a network account that has administrator rights on the 2 remote servers) and
  • adding a domain user account or AD group to the local machine administrators group.


Invoke-Command -computername sp-srch1, sp-srch2 -command {
 $computer = [ADSI]("WinNT://" + $env:COMPUTERNAME + ",computer")
 $Group = $computer.psbase.children.find("administrators")
 $acc = "demo/sp_searchservice"
 $Group.Add("WinNT://" + $acc)
 Restart-Service -Name SPSearchHostController  # Restart the windows service
 Restart-Service -Name OSearch15
}