Understanding and using RBS

Source: Internet
Author: User
Tags filegroup management studio sql server management studio

First of all, I would like to thank the original author. Thank you very much.

------------------------------------------------------------------------

If SharePoint 2007 is used as the document management platform, it is highly criticized that SharePoint 2007 directly stores files in the SQL Server database. Although Windows SharePoint Services 3.0 SP1 adds an external blob storage (EBS) interface, Microsoft does not provide implementation, but requires developers to implement it themselves.

SharePoint 2010 is still compatible with EBS, but EBS is not recommended. The recommended solution is to use SQL Server 2008 remote blob storage (RBS ).

SQL rbs is a group of APIs. Through RBS, an SQL Server 2008 database no longer needs to store big binary data (BLOB) inside the database, but can store it somewhere outside, only one reference to external BLOB data may be stored in the database. Both SQL Server 2008 and SQL Server 2008 R2 support RBS.

It sounds like RBS is really a good stuff. However, RBS is only a set of APIs. In other words, RBS allows developers to use this set of APIs to develop an RBS provider to truly access BLOB data. Without RBS provider, RBS itself does not automatically store blob in a specified place. Different RBS providers allow us to store blob in various places, such as file systems, disk storage devices, and file servers. If we do not store blob in the SQL Server database, we can.

After you have a preliminary understanding of RBS, we will introduce another new feature in SQL Server 2008: filestream. The following sentence is taken from SQL Server 2008 books online: "by storing varbinary (max) Binary Large Object (BLOB) data in a file system, filestream makes the SQL Server database engine and the NTFS file system a whole." Therefore, the filestream administrator can choose to store varbinary (max) BLOB data in the SQL Server database to the local NTFS file system. When using filestream to access BLOB data, you can also enjoy the advantages of database transaction processing.

It sounds like filestream and RBS are very similar, isn't it? But in fact, RBS and filestream are two different things that do not depend on each other. RBS is a set of API interfaces. Through this set of APIS, applications can store BLOB data somewhere outside the database. The specific implementation is done by the RBS provider created by developers. Filestream is a built-in feature of SQL Server 2008. It can store BLOB data originally stored in the database to the local NTFS file system on the server.

SharePoint 2010 uses the rbs api instead of the filestream feature. Therefore, without an RBS provider, we cannot immediately store the files stored in SharePoint 2010 outside the database. However, since the filestream feature already has the ability to store BLOB data in the database to the NTFS file system, why not directly use filestream as an RBS filestream provider, that is, an RBS provider implemented by using the filestream function? In this way, can I store all the files in SharePoint 2010 to the NTFS file system?

Microsoft also thought of it, So Microsoft provides an RBS filestream provider in the form of a Feature Pack. You can download RBS filestream provider for x64 from here. However, to install and use it on the SharePoint 2010 system, you also need to follow certain steps. The procedure is as follows.

1. Make sure that SQL Server 2008 has enabled filestream.

When installing SQL Server 2008, you will be prompted whether to install filestream. If you are not sure whether this feature is installed, open the SQL Server Configuration Manager on the SQL Server 2008 server and select "SQL Server Service" from the left ", right-click the running SQL server instance in the right pane and select the "properties" menu item.

In the open Properties window, select the "filestream" tab, select the option to enable filestream, and click "OK.

Open SQL Server Management studio, select the SQL server instance on the left, and click "new query" in the toolbar area to open a query interface. Then, enter the following SQL statement and execute it.

Exec sp_configure filestream_access_level, 2
Reconfigure



2. determine the content database for which the RBS filestream provider is to be applied

Because RBS is enabled Based on databases, you can choose which SharePoint content databases to enable RBS. This means that for the content databases that store a small number of files in the Sharepoint Server Farm, it may not be necessary to enable RBS for it, and for those content databases that may store a large number of files, you can enable RBS to effectively optimize them.

In the SharePoint 2010 system, the relationship between the content database and the website is:

● A web application can use one or more content databases;
● When a web application is created, a content database is automatically created for it. The administrator can create more content databases for the Web application later;
● When a website set is created in a web application, the website set is stored in a content database of the Web application;
● A website set (including its primary website and all its sub-websites) can only be stored in one content database, but cannot be split and stored in multiple Content databases.

The administrator can open the content database management interface of SharePoint 2010 management center to view the content database used by each web application, or add a new content database for a web application.

In the following example, RBS is enabled for the content database named "wss_content" as shown in.

3. Configure the content database

After you confirm the content database for which you want to enable RBS, open SQL Server 2008 Management studio, find the content database, right-click it, and select the "new query" menu item.

In the open query window, enter the following SQL statements and execute them.

Use [wss_content]
If not exists (select * From SYS. tricric_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

In the preceding SQL commands, the green ones are the ones you need to modify after copying these commands according to the actual situation in your environment. "Wss_content" needs to change the actual name of the content database for which you want to enable RBS. "C: \ blobstore" must be changed to the directory where you want to store blob files. From a practical perspective, you need to select a folder that is located in a non-system partition, with a large available space, fast, stable, and reliable. Note: This folder can only be a local path, not a network path, because filestream does not support remote NTFS folders. In addition, do not create this folder beforehand. The preceding SQL command will automatically help you create this folder.

After the preceding SQL statement is executed, open the resource manager and check that the corresponding folder has been created on the SQL Server server.

4. Install RBS filestream provider

Copy the downloaded rbs_x64.msi file to each server in the Sharepoint Server Farm. This RBS provider must be installed on all SQL Server database servers and SharePoint servers.

First, install RBS filestream provider on the SQL Server database and Sharepoint Server (if there are multiple SharePoint servers in the server farm, then on a Web Front-End Server). The installation steps are as follows.

Run the command prompt as an administrator.

In the Command Prompt window, use the "cd" command to set the current path to the folder where "rbs_x64.msi" is located, then enter the following command and execute:

Msiexec/Qn/lvx * rbs_install_log.txt/I rbs_x64.msi placement = true filegroup = primary dbname = "wss_content" dbinstance = "sp2010" filestreamfilegroup = rbsfilestreamprovider filestreamstorename = filestreamprovider_1

The section marked with green in the preceding Command needs to be modified according to the actual situation in your environment. "Wss_content" needs to be changed to the content database that needs to enable RBS, and "sp2010" needs to be changed to the actual name of the SQL Server 2008 instance (if you install SQL Server 2008, if you do not use the default Instance name, its value may be in a format similar to "sp2010 \ Express ). For each internal data warehouse, this command should be executed only once using msiexec.exe.

After you press the long command line above and press enter, the Command Prompt window appears to be executed immediately, but in fact, the background will continue to execute the RBS provider installation program. You can open the Windows Task Manager. Several msiexec.exe processes are running. The RBS provider installation process is complete.

During RBS provider installation, it writes log information to the "rbs_install_log.exe" file in the same directory as the "rbs_x64.msi" Installation File. Open the log file from the resource manager and search for information such as "installation completed successfully". The information indicates that "rbs_x64.msi" is successfully installed.

If there is only one Sharepoint Server in your Sharepoint Server Farm, you can install RBS filestrream provider on it as described above. However, if there are multiple SharePoint servers in the server farm, you need to install RBS filestream provider on other Web Front-end servers and application servers. However, replace the commands in the command prompt:

Msiexec/Qn/lvx * rbs_install_log.txt/I rbs_x64.msi dbname = "wss_content" dbinstance = "sp2010" addlocal = "client, Docs, maintainer, serverscript, filestreamclient, filestreamserver"

After RBS filestream provider is installed on all servers, open SQL Server 2008 Management studio and refresh the table list of the content database. Many names starting with "mssqlrbs" should be displayed, table related to RBS. If you execute the following SQL statement in the query window, you should be able to query some results.

Select * From DBO. sysobjects where name like 'rbs %'

If there is no such table in the content database and no results can be found by running the preceding SQL statement, it indicates that the RBS provider is not correctly installed on the content database. In this case, open the resource manager on each server and double-click "rbs_x64.msi". Then, on the installation interface that appears, use the "Uninstall" option to uninstall the RBS provider, then, follow the steps above and try to install it again in the Command Prompt window.

5. Enable RBS filestream provider for the content database

The last step is finally reached. On the Sharepoint Server, open SharePoint 2010 management shell, a command line management tool based on Windows powershell.

In SharePoint 2010 management shell, execute the following commands in sequence:

(1) $ CDB = Get-spcontentdatabase "wss_content"
Obtain the instance of the specified content database (spcontentdatabase) object. The "wss_content" marked in green must be replaced with the actual name of the content database in your environment.

(2) $ RBSs = $ CDB. remoteblobstoragesettings
Get the RBS setting (spremoteblobstoragesettings) object instance of the content database.

(3) $ RBSs. installed ()
Check whether RBS is installed on the content database. If necessary, update the attribute values.

(4) $ RBSs. Enable ()
Enable RBs on the content database.

(5) $ pvdname = $ RBSs. getprovidernames () [0]
Obtain the name of the first RBS provider registered to the content database.

(6) $ RBSs. setactiveprovidername ($ pvdname)
Set the RBS provider to be activated for the content database.

Then, you can run "$ RBSs" to view some of its property values. If it is set correctly, the output content should be shown in.

If you have already stored a website set in the RBS filestream provider's content database, the documents in the website set will not automatically pass filestream immediately after you have enabled RBS provider, to the NTFS file system. Only new documents are stored in the NTFS file system. The files uploaded in the website set are still stored in the content database. If you want to transfer all the old documents to the NTFS file system we specified, you can continue to execute the following command in SharePoint 2010 management shell:

(7) $ RBSs. migrate ()

If you want to set a document size threshold, only documents whose size exceeds this threshold can be stored on the NTFS file system through RBS filestream provider, and documents whose size is less than this threshold value, if it is still stored in the content database, you can continue executing the following command in the SharePoint 2010 management shell (assuming the threshold is 1048000 bytes, that is, 1 m ):

(8) $ RBSs. minimumblobstoragesize = 1048000
(9) $ RBSs. Update ()

The preceding commands are for a content database. If you have multiple Content databases to enable RBS, execute the preceding command for each content database.

6. Check the final result

After completing all the above steps, upload some documents on the SharePoint website and check the NTFS folder you have set. There should be some subfolders that store these documents.

 

Source Address:

If SharePoint 2007 is used as the document management platform, it is highly criticized that SharePoint 2007 directly stores files in the SQL Server database. Although Windows SharePoint Services 3.0 SP1 adds an external blob storage (EBS) interface, Microsoft does not provide implementation, but requires developers to implement it themselves.

SharePoint 2010 is still compatible with EBS, but EBS is not recommended. The recommended solution is to use SQL Server 2008 remote blob storage (RBS ).

SQL rbs is a group of APIs. Through RBS, an SQL Server 2008 database no longer needs to store big binary data (BLOB) inside the database, but can store it somewhere outside, only one reference to external BLOB data may be stored in the database. Both SQL Server 2008 and SQL Server 2008 R2 support RBS.

It sounds like RBS is really a good stuff. However, RBS is only a set of APIs. In other words, RBS allows developers to use this set of APIs to develop an RBS provider to truly access BLOB data. Without RBS provider, RBS itself does not automatically store blob in a specified place. Different RBS providers allow us to store blob in various places, such as file systems, disk storage devices, and file servers. If we do not store blob in the SQL Server database, we can.

After you have a preliminary understanding of RBS, we will introduce another new feature in SQL Server 2008: filestream. The following sentence is taken from SQL Server 2008 books online: "by storing varbinary (max) Binary Large Object (BLOB) data in a file system, filestream makes the SQL Server database engine and the NTFS file system a whole." Therefore, the filestream administrator can choose to store varbinary (max) BLOB data in the SQL Server database to the local NTFS file system. When using filestream to access BLOB data, you can also enjoy the advantages of database transaction processing.

It sounds like filestream and RBS are very similar, isn't it? But in fact, RBS and filestream are two different things that do not depend on each other. RBS is a set of API interfaces. Through this set of APIS, applications can store BLOB data somewhere outside the database. The specific implementation is done by the RBS provider created by developers. Filestream is a built-in feature of SQL Server 2008. It can store BLOB data originally stored in the database to the local NTFS file system on the server.

SharePoint 2010 uses the rbs api instead of the filestream feature. Therefore, without an RBS provider, we cannot immediately store the files stored in SharePoint 2010 outside the database. However, since the filestream feature already has the ability to store BLOB data in the database to the NTFS file system, why not directly use filestream as an RBS filestream provider, that is, an RBS provider implemented by using the filestream function? In this way, can I store all the files in SharePoint 2010 to the NTFS file system?

Microsoft also thought of it, So Microsoft provides an RBS filestream provider in the form of a Feature Pack. You can download RBS filestream provider for x64 from here. However, to install and use it on the SharePoint 2010 system, you also need to follow certain steps. The procedure is as follows.

Source Address: http://kaneboy.blog.51cto.com/1308893/288697

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.