Wednesday, October 16, 2013

Administration SharePoint services

Administration service is not running:-

The Microsoft SharePoint Foundation Administration service is required to run on all servers in a Microsoft SharePoint Foundation 2010 farm. This service performs multiple operations on the local server computers that require local administrator permissions for operations; for example, creating and deleting Web applications and service applications, and starting and stopping services. If this service is not running on any server in a SharePoint Foundation 2010 farm, administrative operations can fail or partially succeed.

Cause: One or more of the following might be the cause:
·         The SharePoint Foundation Administration service was stopped by an administrator on a particular computer.
·         The user name or password for the account that the SharePoint Foundation Administration service is set to run as is incorrect.
·         An error condition in the SharePoint Foundation Administration service caused the service to terminate.

Resolution:   Start the administration service

·         Start the SharePoint Foundation Administration service
Central Admin à System Settings à Manages Services on server
·         By using the Services Microsoft Management Console (MMC) snap-in in Windows. Click Start, clickRun and type the following:


services.msc

Monday, October 14, 2013

Enabling Filestream and RBS with SharePoint 2010

 Note: This Post is applicable only to SQL server 2008, 2008 R2 with SharePoint 2010 only.

The user account that you use to perform the procedures that are described in this document must have the following memberships:
1)       Administrators group on the Web servers and application servers.
2)       SQL Server dbcreator and securityadmin fixed server roles on the computer that is running SQL Server 2008.
Note: Logon to SQL and Webserver with user account of SharePoint not local admin.
  
A)     Enable FILESTREAM on the database server
  1. On the Start menu, point to All Programs, point to Microsoft SQL Server 2008 R2, point to Configuration Tools, and then click SQL Server Configuration Manager.
  2. In the list of services, right-click SQL Server Services, and then click Open.
  3. In the SQL Server Configuration Manager snap-in, locate the instance of SQL Server on which you want to enable FILESTREAM.
  4. Right-click the instance and then click Properties.
  5. In the SQL Server Properties dialog box, click the FILESTREAM tab.
  6. Select the Enable FILESTREAM for Transact-SQL access check box.
  7. If you want to read and write FILESTREAM data from Windows, click Enable FILESTREAM for file I/O streaming access. Enter the name of the Windows share in the Windows Share Name box.
  8. If remote clients must access the FILESTREAM data that is stored on this share, select Allow remote clients to have streaming access to FILESTREAM data. 
  9. Click Apply. See below:

  10. In SQL Server Management Studio, click New Query to display the Query Editor.
  11. In Query Editor, enter the following Transact-SQL code:
             EXEC sp_configure filestream_access_level, 2
             RECONFIGURE
  12. Click Execute.





B)      
Provision a BLOB store for each content database
  1. Click Start, click All Programs, click Microsoft SQL Server 2008, and then click SQL Server Management Studio.
  2. Connect to the instance of SQL Server that hosts the content database.
  3. Expand Databases.
  4. Click the content database for which you want to create a BLOB store, and then click New Query.
  5. Paste the following SQL queries in Query pane, and then execute them in the sequence listed.
    use [WSS_Content]
    if not exists (select * from sys.symmetric_keys where name = N'##MS_DatabaseMasterKey##')create master key encryption by password = N'Admin Key Password !2#4'

    use [WSS_Content]
    if not exists (select groupname from sysfilegroups where groupname=N'RBSFilestreamProvider')alter database [WSS_Content] add filegroup RBSFilestreamProvider contains filestream

    use [WSS_Content]
    alter database [WSS_Content] add file (name = RBSFilestreamFile, filename = 'C:\Blobstore') to filegroup RBSFilestreamProvider
Note: In All the three queries replace [WSS_Content] with the content database name, and replacec:\BlobStore with the volume\directory in which you want the BLOB store created. The provisioning process creates a folder in the location that you specify. Be aware that you can provision a BLOB store only one time. If you attempt to provision the same BLOB store multiple times, you will receive an error.

             
             Commands should be successfully completed.

Verify:

Blobstore folder would be created under the path given. There would be a folder and a file in it.

             
  
C)      Install the RBS provider components on each server (SQL and Web Server)
Note: First install RBS on SQL server then First Web server then additional Servers.
To install RBS on SQL server and then First Web server follow the below steps.
  1. Browse to http://www.microsoft.com/download/en/details.aspx?id=16978 find rbs.msi download X64 Package.
    Note: Do not download the rbs_x64 link given in TechNet article 
    http://technet.microsoft.com/en-us/library/ee663474.aspx
  2. Run cmd prompt as Administrator and then click OK.
    Change the directory to the place where rbs.msi is downloaded on the machine.
  3. Copy and paste the following command into the Command Prompt window.

    msiexec /qn /lvx* rbs_install_log.txt /i RBS.msi TRUSTSERVERCERTIFICATE=true FILEGROUP=PRIMARY DBNAME="WSS_Content" DBINSTANCE="DBInstance Name" FILESTREAMFILEGROUP=RBSFilestreamProvider FILESTREAMSTORENAME=FilestreamProvider_1
    Note:Replace WSS_Content and DBInstance Name in the above command.

     rbs_install_log.txt is the installation log file generated in the same path where rbs.msi is located.

    Verify:1) The process of installation finishes in 1 min. See task manager, there would be two processes “msiexec.exe ” running with the SharePoint user account that you logged in. You can see these processes only if you enable show processes from all users.
                     
             2)  Verify if the Tables were created for the database WSS_Content. If there were no folders then the installation is not success. Verify Log file.
                      
            3)  Verify the programs installed in control panel, SQL Server 2008 R2 Remote Blob Store is installed.
                         
            4)  The size of the log file rbs_install_log.txt should be more than 1 MB. If you have less size then there should be some problem in the installation. 
Troubleshoot in file size is less:
Open the log file scroll to the bottom you can see an entry that Installation Completed Successfully, but never trust that message. Find for errors and resolve the same.

Mostly the parameters passed in the above command should be wrong- check for db instance name, server name and especially spelling mistakes.
Note: Follow the same process and command for First Web server.
D) To install RBS on all additional Web and application servers
  1. Browse to http://www.microsoft.com/download/en/details.aspx?id=16978 find rbs.msi download X64 Package.
    Note: Do not download the rbs_x64 link given in TechNet article 
    http://technet.microsoft.com/en-us/library/ee663474.aspx
  2. Run cmd prompt as Administrator and then click OK.
    Change the directory to the place where rbs.msi is downloaded on the machine.
  3. Copy and paste the following command into the Command Prompt window

    msiexec /qn /lvx* rbs_install_log.txt /i RBS.msi DBNAME="WSS_Content" DBINSTANCE="DBInstance Name" ADDLOCAL="Client,Docs,Maintainer,ServerScript,FilestreamClient,FilestreamServer"
Note: Replace WSS_Content and DBInstance Name in the above command.

rbs_install_log.txt is the installation log file generated in the same path where rbs.msi is located.
Verify:
The size of the log file rbs_install_log.txt should be less than 1 MB, vice versa for SQL and First Web Server.

Open the log file scroll to the bottom you can see an entry that Installation Completed Successfully, but never trust that message. Find for errors and resolve the same.

Mostly the parameters passed in the above command should be wrong- check for db instance name, server name and especially spelling mistakes .

E)      Enable RBS for each Content Database from Web Server:
             Open SharePoint PowerShell as Administrator and perform the steps below:

            $cdb = Get-SPContentDatabase –WebApplication 
            $rbss = $cdb.RemoteBlobStorageSettings
            $rbss.Installed()
            $rbss.Enable()
            $rbss.SetActiveProviderName($rbss.GetProviderNames()[0])

Verify:

1. Executing $rbss.Installed() should return true, if false this may be due to the reason that RBS is not installed properly or RBS is not installed on other Web servers.
Verify RBS installation log on all the servers. If you think something is wrong uninstall RBS from control panel and re-install using step C or D.

             

2. Type $rbss and verify that ActiveProviderName is not Null. See below


F)
      
Test the RBS Installation:
  1. Open the Web Application where blob store is enabled.
  2. Open a library or list where we can upload documents.
  3. Upload a document whose size limit is more than 60 KB.
  4. Browse to Blob Store Folder on the SQL server and verify the latest modified folder. The document should be present in it.


              The other way of checking this is to run below query on SQL database.              Select * from AllDocstreams where RBSID IS NOT NULL
Note: RBS_ID has some value indicates that the document is in Blob Store. If it is null then it indicates that the data was present in SQL database itself.

             
            
Note:
The Blob Threshold limit by default is 60 KB.  This explains that only documents whose size is more than 60 KB are being moved to Blob Store.
This setting can be verified by running the below query on the content database and checking the value for the column “extended_configuration” for the record matching your Filestream provider name stored in the "blob_store_name" column.

 Use [WSS_Content]
 
select * from mssqlrbs_resources.rbs_internal_blob_stores
G)     Adjust Blob Threshold:
            We can change the Blob Threshold limit for a content database my executing below commands as Powershell Administrator on any Web Sever .

             $cdb = Get-SPContentDatabase –WebApplication
             $cdb.RemoteBlobStorageSettings.MinimumBlobStorageSize=1048576
             $cdb.Update()
Note: 1048576 = 1MB, files size more than 1 MB would be moved to blob store.
 H)     Move Content In and Out of RBS:
            1)      Move Content from SQL to RBS:
                      The content database might be in use for many days and you have enabled RBS later, you want to move the content to RBS Blob Store. To achieve this execute the below commands as administrator of powershell on any Web
                      Server

                      $cdb = Get-SPContentDatabase –WebApplication
                      $rbss = $cdb.RemoteBlobStorageSettings
                      $rbss.Migrate()
Note :1.Please note that when you run this command the server begins copying data from the database to the file system. If you've got a lot of data in the database, it may take a while.

2. The Blob Threshold apply here, all the docs whose threshold limit is more than the specified values are pushed to the Blob Store.
Verify:Browse to Blob Store Folder on the SQL server and verify the latest modified folder, the documents should be present in it.
Execute the query  select* from AllDocStreams where RBSID IS NULL it should return zero results. The data from “content” column is pushed to ”RBSID” column and the Content Column is made NULL.


                     
           2)       Move Content from RBS to SQL:
                     We need to disable RBS and move the content back to SQL. To achieve this execute the below commands as administrator of powershell on any Web server.

                     $cdb = Get-SPContentDatabase –WebApplication
                     $rbss = $cdb.RemoteBlobStorageSettings
                     $rbss.SetActiveProviderName("")
                     $rbss.Migrate()
 
Note:SetActiveProviderName("") disables RBS, $rbss.Migrate() migrates the content back to SQL as ActiveProviderName is Blank.

The documents were copied to SQL but they were not deleted from Blob Store, so before performing this action plans that the SQL server has more free space.

If you want to move the content to another provider execute below commands.
$rbss.SetActiveProviderName("Name of the provider")
$rbss.Migrate()

Verify:
Execute the query  select* from AllDocStreams where RBSID IS NOT NULL it should return zero results. The data from column “RBSID” is pushed to “content” column and the RBSID column is made NULL.  
               

To double check that this, delete any known file manually from Blob Store and try to access the same from UI.
 I)        Enable RBS on another content database:

You may create a new content database to the same web application and you want to enable RBS on this  or you want enable RBS on another content database of a different web application. To achieve this follow the steps mentioned below:
  1. Open SQL server -> SQL Management Studio ->Databases -> Expand the content database for which you want to create a blob store -> Right Click-> New Query
  2. Execute below queries

    use [WSS_Content_NEW] if not exists (select * from sys.symmetric_keys where name = N'##MS_DatabaseMasterKey##') create master key encryption by password = N'Admin Key Password !2#4'

    use [WSS_Content_NEW] if not exists (select groupname from sysfilegroups where groupname=N'RBSFilestreamProvider') alter database [WSS_Content_NEW] add filegroup RBSFilestreamProvider contains filestream

    use [WSS_Content_NEW] alter database [WSS_Content_NEW] add file (name = RBSFilestreamFile, filename = 'c:\RBSStore') to filegroup RBSFilestreamProvider

    Note:

    For best performance, simplified troubleshooting, and as a general best practice, recommendation is to create the RBS data store on a volume that does not contain the operating system, paging files, database data, log files, or the tempdb file.
  3. Run CMD as Administrator and navigate to the path where rbs.msi is located and execute the below command.

    msiexec /qn /i rbs.msi REMOTEBLOBENABLE=1 FILESTREAMPROVIDERENABLE=1 DBNAME=”WSS_Content_NEW” FILESTREAMSTORENAME=FilestreamProvider_1 ADDLOCAL=EnableRBS,FilestreamRunScript DBINSTANCE=”DBInstanceName

    Note: 
    Make sure that you use same FILESTREAMSTORENAME that you used initially to install RBS. Use this command to check the name of file stream provider “$rbss.GetProviderNames()”
  4. Login to the Webserver and run the below commands

    $cdb = Get-SPContentDatabase  “WSS_Content_NEW
    $rbss = $cdb.RemoteBlobStorageSettings
    $rbss.Installed()   
    $rbss.Enable()
    $rbss.SetActiveProviderName($rbss.GetProviderNames()[0])
Verify:
1.     $rbss.Installed() should return true.
2.     Type $rbss and verify that ActiveProviderName is not Null. See below”

             


J)       Uninstall RBS on a Web Server:
Note: Perform uninstall of RBS only if RBS fails during its installation.
           Uninstall is achieved in 3 ways.
  1. Remove RBS from Control Panel
    Control Panel -> Add or Remove Features -> SQL Server 2008 R2 Blob Cache
         
  2. Run CMD as Administrator and navigate to the path where rbs.msi is located and execute the below command

    msiexec /qn /lvx* rbs_install_log.txt /x RBS.msi DBNAME="WSS_Content" DBINSTANCE="DBInstanceName" ADDLOCAL="Client,Docs,Maintainer,ServerScript,FilestreamClient,FilestreamServer"
  3. Double click on RBS.msi and uninstall (not recommended) 
             
  
K)      Completely remove RBS on a Content database and also from server:
  1. Backup 1st: Backup site collection with stsadm, backup SQL db, backup RBS blob storage.
  2. Migrate all content off RBS to SQL and disable RBS for content db:

    On Webserver execute the below commands.

    $cdb=Get-SPContentDatabase
    $rbss=$cdb.RemoteBlobStorageSettings
    $rbss.GetProviderNames()
    $rbss.SetActiveProviderName("")
    $rbss.Migrate()
    $rbss.Disable()
Verify:
Type $rbss and you should see that Activeprovidername is NULL and Enabled is false.

             

     3.   Change the default RBS garbage collection window to 0 on your content db:

                 Execute the below commands in SQL server on the query editor for the content database.
                                   exec mssqlrbs.rbs_sp_set_config_value 'garbage_collection_time_window','time 00:00:00'
                                    exec mssqlrbs.rbs_sp_set_config_value 'delete_scan_period','time 00:00:00'
    4.    Change the default RBS garbage collection window to 0 on your content db:

            On Sql server open CMD prompt as Administrator and navigate to the path “C:\Program Files\Microsoft SQL Remote Blob Storage 10.50\Maintainer”
            Execute the command “Microsoft.Data.SqlRemoteBlobs.Maintainer.exe -connectionstringname  RBSMaintainerConnection -operation GarbageCollection ConsistencyCheck ConsistencyCheckForStores -GarbageCollectionPhases rdo -     ConsistencyCheckMode r -TimeLimit 120”
See below:
       
                

        5.        Uninstall RBS:
                           On the content db RUN:
                          exec mssqlrbs.rbs_sp_uninstall_rbs 0

Verify the below:
             Only few tables are left in the database, all other tables have been deleted.
             
                   Execute Below commands on the content database:
                   ALTER TABLE [mssqlrbs_filestream_data_1].[rbs_filestream_configuration] DROP column [filestream_value]                  ALTER TABLE [mssqlrbs_filestream_data_1].[rbs_filestream_configuration] SET (FILESTREAM_ON = "NULL")
 Note: If you have mssqlrbs_filestream_data_2 run the below two commands as well.
                 ALTER TABLE [mssqlrbs_filestream_data_2].[rbs_filestream_configuration] DROP column [filestream_value]                 ALTER TABLE [mssqlrbs_filestream_data_2].[rbs_filestream_configuration] SET (FILESTREAM_ON = "NULL")
  Now you can remove the file and filegroup for filestream:
                 ALTER DATABASE WSS_Content Remove file RBSFilestreamFile;                ALTER DATABASE WSS_Content REMOVE FILEGROUP RBSFilestreamProvider;
Verify: This will remove the Blob Folder from the file system however still few tables exist as shown in the previous screen shot

Note: Perform all the above steps on other content databases if you want to remove RBS on them.

        6.    Perform the two steps below to completely remove RBS and file stream on SQL server.

               Uninstall from add/remove SQL Remote Blob Storage from SQL and Webservers.

               Disable filestream in SQL Configuration Manager for your instance (if you do not use it anywhere aside this single content db with sharepoint), run SQL reset and iis reset and test.
More Information:
1)       Site collection backup and restore and site import or export will download the file contents and upload them back to the server regardless of which RBS provider is being used. This process is known as a deep copy. However, the FILESTREAM provider is the only provider that is currently supported for SharePoint 2010 Products farm database backup and restores operations.
                 All the below scenarios works perfectly, no data loss at all.

                Export  / Import from RBS content db to normal content db
                Export  / Import from normal content db to RBS enabled content db
                Export  /Import from RBS enabled content db to RBS enabled content db
                Backup / Restore from RBS enabled content db to Normal content db
                Backup / Restore from normal content db to RBS enabled content db
                Backup / Restore from RBS enabled content db to RBS enabled content db
                Backup / Restore from CA
                Attach / Detach Content db – After attaching using powershell Run rbss.installed() on Webserver
2)       Content stored in remote BLOB stores cannot be restored by using DPM
3)       If you plan to store BLOB data in an RBS store that differs from your SharePoint Server 2010 content databases, you must run SQL Server 2008 with SP1 and Cumulative Update 2 or SP2
            Note: Make sure you use RBS.msi for SQL server 2008 R2. Do not use SQL server 2008 RBS file.


Sunday, October 6, 2013

SharePoint 2010 Cache Configuration

Cache is a very important feature when you think about end user response time and also server load. In my case, I was tweaking the configuration for a internet public sites in order the have a better user experience.

BLOB Cache

To improve the end user response time a good approach is to configure the BLOB Cache on the SharePoint 2010 Web Front End (WFE) servers. The BLOB cache caches files on the WFEs disk to make it faster for IIS to retrieve the files and return them to the browser. It can also send some HTTP headers telling the browser to cache the file for a certain amount of time.
We need to change the web.config to enable the BLOB cache. Find the BlobCache tag on the configuration/SharePoint node on the web.config. Here is an example of a configured Blob Cache:
The location attribute defines where SharePoint is going to save the cached files.
The path attribute represents a regex defining the file extensions to be cached.
The maxSize attribute defines the maximum size of the cache in Giga bytes.
The enabled attribute defines if the cache is enabled.
The max-age attribute defines the maximum time in seconds the browsers can cache the files locally and avoid making requests for these file to the server. This setting affect how the users’ browser cache the files defined on the path attribute.

Output Cache

Another cache feature available on SharePoint 2010 is the Output Cache.
The Output Cache caches the HTML output for the pages processed by SharePoint. This cache improves the server processing time for the cache pages since IIS doesn’t need to call SharePoint and wait for the page to be processed. It just gets the cached copy and send the HTML back to the browser. The Output Cache is configured per Site Collection.
First we need to make sure the cache profile is configured in the way we need.
Go to the Site Settings page, then to Site Collection Administration and then to Site Collection Cache Profiles.
The default cache profiles are listed. I’ll check if the Public Internet one is alright for my needs.
In my case I’ll need a few tweaks on the cache profile configuration:
  • Check for changes: This setting needs to be Yes in order for the cache to items in the cache if they changed before the duration of the cache. It affects performance but it is a good option to make sure Content Managers have their content showing up on the site as soon as they approve it.
  • Vary by query string parameters: Since we have several dynamic pages which receive parameters by query string and produce different HTML in the output we need to specify the query string parameter. The value of the parameter should be * since the names of the parameters vary a lot.
My new cache profile looks like this:
After your cache profile is ready, you should go to the Site Settings page, then to Site Collection Administration and then to Site Collection Output Cache.
Make sure you enable the Output Cache and select the cache profile you just created.

Testing

Now you just need to recycle your app pools and start testing the cache. Both caches can be tested in HTTP monitoring tools such as FiddlerHTTP Watch, IE Developer Tools or Chrome Developer Tools.
Two important notes on testing:
  • If you hit F5 on a page, your browser will sent HTTP headers to the server telling it to ignore any cache. The best way to test is navigating thru the site and checking which page and assets (images, js, css files) are called or cached.
  • If you configure your browser to always request the most current version of the page, the BLOB cache will not work on the client side.

Wednesday, October 2, 2013

Creating Custom Permission Levels

Edit an existing permission level, or create a new one?

Here are several examples of situations when it might be useful to change an existing permission level:
  • A default permission level includes all permissions except one that users must have to do their jobs, and you want to add that permission.
  • A default permission level includes a permission that users do not need. For example, you might want people to be able to read and edit items in a list, but not to delete items from that list. You might start with the Contribute permission level, and then remove the “Delete List Item” permission to create a new permission level.
You might want to create new permission levels if one or more of the following situations applies:
  • You want to exclude several permissions from a particular permission level.
  • You want to define a unique set of permissions.

Open the permission levels page

To change permission levels, you first open the Permission Levels page.
  1. On the top-level Web site of the site collection, click the Site Actions menu, and then click Site Settings.
  2. On the settings page, in the Users and Permissions section, click Site Permissions.
  3. On the Edit tab, click Permission Levels.
On this page, you can add or delete permission levels, or modify existing permission levels.

Create a permission level

  1. On the Permission Levels page, click Add a Permission Level.
  2. On the Add a Permission Level page, in the Name and Description section, type a name and optionally a description.
Select the check boxes for the permissions that you want to associate with this permission level, and then clickCreate.

Copy a permission level

On the Permission Levels page, click the name of the permission level that you want to copy.
  1. Scroll to the bottom of the Edit Permission Level page, and then click Copy Permission Level.
  2. In the Permission Level Name and Description section, type the name and optionally a description for the new permission level.
  3. Click Create.
The new permission level appears on the Permission Levels page.

Edit a permission level

Use these steps to change any custom permission levels or any of the default permission levels other than Full Control or Limited Access.
  1. On the Permission Levels page, click the name of the permission level that you want to edit. The Edit Permission Level page opens, where you can make the following changes:
  2. Change the description of the permission level.
  3. Select the check boxes for the permissions that you want associated with this permission level.
  4. Clear the check boxes for the permissions that you do not want associated with this permission level.
  5. After you have made you changes, click Submit.

Delete a permission level

Use these steps to delete custom permission levels or any of the default permission levels other than Full Control or Restricted Read. Full Control and Restricted Read cannot be deleted.
  1. On the Permission Levels page, select the check boxes for the permission levels that you want to delete, and then click Delete Selected Permission Levels.
  2. Click OK.

Assign a new permission level to a group

After you create a permission level, you can assign it to groups or users.

  1. On the top-level Web site of the site collection, click the Site Actions menu, and then click Site Permissions.
  2. Select the check box next to the person or group that you want to assign the new permission level to.
  3. Click the Edit User Permissions button.
  4. In the Edit Permissions dialog box, check the name of the new permission level, and then click OK.


Creating a custom permission level

First, we will create a custom permission level. To create a custom permission level, go to Site Actions->Site Settings. Under the "Users and Permissions" category, click on "Advanced permissions". 



Now click on Settings->Permission Levels 



Click on "Add a Permission Level" 



Provide a unique name and description to the Permission Level. Permission Levels are divided into three levels 
  • List
  • Site
  • Personal
Each set contains different kind of permission selections like add, edit, delete, open, etc.... In our case we need to update List and Site permissions in order to allow users to access sites and perform operations on a list. So in the "Permissions" category, under the "List Permissions" section, select the below three permissions:
  • Add Items - Add items to lists, add documents to document libraries, and add Web discussion comments.
  • View Items - View items in lists, documents in document libraries, and view Web discussion comments.
  • View Application Pages - View forms, views, and application pages. Enumerate lists.


Under the "Site Permissions" section, select the permissions below:
  • View Pages - View pages in a Web site.
  • Open - Allows users to open a Web site, list, or folder in order to access items inside that container.


Click on "Create" and now you can see the custom permission level listed in site permission levels.