Wednesday 19 November 2014

Solution for Zero Byte SharePoint 2010 Log files

If your SharePoint 2010 Log files are of  zero byte i.e. SharePoint is unable to record the Log information then perform the following steps to resolve it

Make sure the login account of “Windows SharePoint Services Tracing V4” is member of Local Administrators group.

Make sure you have restarted the “Windows SharePoint Services Tracing V4” service after performing step 1.


Wednesday 12 November 2014

SharePoint: Health Analyzer: Databases require upgrade or not supported

Situation, the health analyzer points out there is a problem with the SharePoint environment:“Databases require upgrade or not supported” is the message received.

Clicking on the link within the error message will get show the details of the problem encountered.
The image below gives us an idea, it shows that the problem is the version of the database and the remedy is running the Upgrade-SPContentDatabase cmdlet (i.e. PowerShell script) or running the PSConfig.exe for all other types of databases.


In the remedy section there is a link, this link references the general SharePoint products page. It is not very helpful to remedy the error. The text below will explain how to upgrade the content databases and how to upgrade all other databases.

Finding the databases that need upgrading.
Opening “Central Administration”.
Click “Upgrade and Migration”
Click “Review Database Status”
The administration will show a screen with all the Sql Server Instances, the database names, the type of the database and their status. The Status will show whether or not an upgrade is required.


Upgrading content databases require the GUID of the database that is linked to the site-collection. The site-collection is the key with which we can find the GUID of the database. The name of the content database should supply a clue.


In the case used for this example the content database that was serving the Central Administration Site needed an upgrade. To make sure validating the assumption is always a good idea.

Validating the connection between the content database and the site collection.
In the Central administration –> “Application Management”
Under “Databases” –> “Manage content databases”
Select the Web Application which you think is linked to the content database that needs upgrading.


If the content database shows up under the Database Name, the content database and the web application are validated to have a relation with each other.

Upgrading Content databases using SharePoint 2010 Management Shell
Start the “SharePoint 2010 Management Shell”
In the Shell enter : Get-SPContentDatabase –site [url towards your site collection]


The yellow marked text shows the GUID of the content database.

Cut and paste the GUID to the following command:Upgrade-SPContentDatabase [guid]


It will take some time before the 100% appears.

Upgrading ‘all other’ type of databases using psconfig.exe
Open a command box in ‘run as administrator’ mode.
Navigate to the bin directory of the SharePoint root. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN
Run the following command: PSConfig.exe -cmd upgrade -inplace b2b -force -cmd applicationcontent -install -cmd installfeatures
The PSConfig.exe tool will go though several steps to upgrade all the databases in the correct sequence.

Validate that all the databases where updated successfully.

Open “Central Administration”.
Click “Upgrade and Migration”
Click “Review Database Status”
When the process is complete all of the databases should say ‘no action required’

Thursday 6 November 2014

Blob Cache in SharePoint

1. What is Blob Cache?

Disk-based Caching for Binary Large Objects
Disk-based caching controls caching for binary large objects (BLOBs) such as image, sound, and video files, as well as code fragments. Disk-based caching is extremely fast and eliminates the need for database round trips. BLOBs are retrieved from the database once and stored on the Web client. Further requests are served from the cache and trimmed based on security.


2. Enabling and modifying disk-based caching for SharePoint sites.

Disk-based caching is disabled by default. To enable and customize the disk-based cache, you must modify the following statement in the web.config file for the SharePoint Web application.
By default, it looks like this:
<BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" enabled="false" />
In order to improve the performance of your site, the BlobCache should be enabled.
<BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" enabled="true" />
Example:
<BlobCache location="C:\blobCache" path="\.(gif|jpg|png|css|js)$" maxSize="10" max-age="86400" enabled="false"/>
In the preceding example:
• location is the directory where the cached files will be stored
• path specifies in the form of a regular expression which files are cached based on the file extension
• maxSize is the maximum allowable size of the disk-based cache in gigabytes
• max-age specifies the maximum amount of time in seconds that the client browser caches BLOBs downloaded to the client computer. If the downloaded items have not expired since the last download, the same items are not re-requested when the page is requested. The max-age attribute is set by default to 86400 seconds (that is, 24 hours), but it can be set to a time period of 0 or greater.
• enabled is a Boolean that disables or enables the cache.


3. Flushing the Disk-based Cache:

We can flush the current site collection object cache. To do this, browse to the following location on the web site,
Site collection administration -> site collection object cache -> disk based cache reset.
If we have multiple WFEs in the farm, each WFE will maintain its own copy of Disk-based Cache. SharePoint does not have a Web user interface (UI) to flush the disk-based cache on all the servers in a farm and neither is there an option to select a specific WFE.
4.The option provided in the Administration page for flushing the cache is only to the flush the cache on the web front end to which you are currently browsing.
if you would like to flush the complete binary large object (BLOB) caches associated with a specific Web Application on different Web front-end computers in a farm, then you can use the STSADM command to do so.
STSADM -o setproperty -propertyname blobcacheflushcount -propertyvalue 11 -url http://web:port 


5. Internals of the blob cache functionality within SharePoint:

After enabling blob cache in web.config, do an IISRESET and browse to the /settings.aspx first, instead of home page (Collaboration portal site).
When we browse to the settings.aspx, it will create the following files change.bin, dump.bin and flushcount.bin (all the files will be 1KB in size).
Browse to the home page now, it will create a folder PUBLISHINGIMAGES, all the images rendered from the database will be stored here and the above bin files will also get updated (we can see the difference in file size).
Every time when a new image file is rendered from the database, the image folder gets a copy of the image. The bin files (index) will get updated with an additional entry for the new file.
Every request from client will check the index file first. It will only check the cache index and not the image folder directly for the image. If the index file does not have an entry for the image, then the request is served from the database. During this time, a copy of the image will be stored in the images folder and the index file also gets updated, so that the next request will not go to the database.


6. What happens I manually delete just the image file in the cache folder or the image file in the cache folder gets corrupted?

We will not see the image on the client page; we get a broken image ‘X’.


7. How are these cache files stored?

Filename.extension.cache is the file naming format.


8. What can I do if the cached file gets corrupted?

Recommendation: We can reset the index file. Site settings -> Site collection object cache -> Check the box for “Force this server to reset its disk based cache”. It will completely delete all the images and reset the bin files back to 1KB, so that next request will go to database and the complete index will get rebuilt.
Workaround: If you do not want to reset the complete index. Find out the missing image and copy just that file to the cache folder, name it as “filename.extension.cache”
Refresh the page now; it should pick up the image.


9. How is the Index file maintained?

Every time when the web.config initializes, the index file is loaded from the blobcache folder to memory. All new entries will keep getting updated in index file when in memory.
IISRESET /stop will flush the updated index file from memory to disc within the blobcache folder.
IISRESET /start will load the index file from blobcache folder to memory.
As long as the application pool is alive the index file will be getting updated in memory itself.


10. Can an Index file get corrupt?

Index file corruption is possible only when IIS crash or the index file is overwritten with wrong information. When IIS tries to load the index file from blobcache to memory and identifies that it is a corrupted file (not a valid file), it will get completely rebuilt (flush) as fresh file (1KB), all the old entries and images will be lost.


11. In a farm environment, is there any way of having all the WFEs' blob caches synchronized among each other?

No, this cannot be done because SharePoint maintains the index and the cache files individually on each server.


12. In a single WFE environment using web gardening, how does blob caching function? Is there any sync that happens among the working processes?

Web gardening is not supported.


13. What would be the best way of using blob cache in a farm environment (best practices)?


If the requirement is to “centralize” static cached files, then 3rd party content distribution network (CDN) solutions like Akamai need to be used.
What are the limitations of SharePoint and blob caching in a farm environment?
a. Blob caching does not work with Web Gardening.
b. Blob caching does not synchronize data across WFEs – so we might be seeing different versions of the files for a short duration across different WFE servers.