Microsoft Press microsoft sql server 2005 PHẦN 8 pdf

99 345 0
Microsoft Press microsoft sql server 2005 PHẦN 8 pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Lesson 1: Creating a Database Snapshot 607 Lesson Summary ■ A Database Snapshot is a point-in-time, read-only copy of a source database that exists on the same SQL Server instance as the source database. As pages are changed in the source database, the original image of the data page is written into the sparse files of the Database Snapshot to preserve the state of the data at creation time. ■ Although a Database Snapshot can be queried like any other database, you are not allowed to modify data or structural elements. A Database Snapshot also cannot be used for backup/restore operations. Even though it is required to exist on the same SQL Server instance as the source database, a Database Snapshot can be created against a mirror database within a Database Mirroring session. Lesson Review The following questions are intended to reinforce key information presented in this lesson. The questions are also available on the companion CD if you prefer to review them in electronic form. NOTE Answers Answers to these questions and explanations of why each answer choice is right or wrong are located in the “Answers” section at the end of the book. 1. Which operations can be performed against a Database Snapshot? A. BACKUP DATABASE B. ALTER DATABASE C. SELECT COLUMN1, COLUMN2 FROM TABLE D. UPDATE TABLE1 SET COLUMN1 = 4 2. You can create a Database Snapshot against which types of databases? (Choose all that apply.) A. User database B. Master database C. Another Database Snapshot D. Mirror database C1662271X.fm Page 607 Friday, April 29, 2005 8:00 PM 608 Chapter 16 Managing Database Snapshots 3. What data is contained within a Database Snapshot? (Choose all that apply.) A. All original pages of the source database B. Only the original image of pages changed since the Database Snapshot was created C. A catalog of changed pages D. Metadata about the database objects C1662271X.fm Page 608 Friday, April 29, 2005 8:00 PM Lesson 2: Reverting a Database from a Database Snapshot 609 Lesson 2: Reverting a Database from a Database Snapshot A Database Snapshot provides a point-in-time copy of a source database. Because it provides a copy of the data in the database, you can use it to recover in a variety of sit- uations. In the event of data being accidentally damaged or if an administrative pro- cess makes changes that are unwanted, you can extract the original version of the data from the Database Snapshot and move it back into the source database using either an INSERT or UPDATE statement. In an extreme case, a DBA might want to restore the state of a database back to a pre- vious point in time. This lesson will explain how to revert a source database to a pre- vious point in time by using a Database Snapshot. After this lesson, you will be able to: ■ Revert a database from a Database Snapshot. Estimated lesson time: 10 minutes Reverting a Database Reverting a database is a special subclass of restore operation that you can perform against a database. During a restore of a database, you can leave the database in a recovering state to apply subsequent transaction logs to roll a database forward to a specific point in time. Reverting a database will take a database back to a point in time; however, you cannot restore subsequent backups after reverting the database to that point in time. Using a Database Snapshot to revert a database has some restrictions: ■ Only a single Database Snapshot can exist against a source database. ■ Any full-text catalogs on the source database are dropped and must be re-cre- ated. ■ The transaction log is rebuilt, which breaks the log chain. ■ The source database and Database Snapshot are offline during the revert. The syntax to revert a database from a Database Snapshot is as follows: RESTORE DATABASE <database_name> FROM DATABASE_SNAPSHOT = <database_snapshot_name> C1662271X.fm Page 609 Friday, April 29, 2005 8:00 PM 610 Chapter 16 Managing Database Snapshots Quick Check ■ How many Database Snapshots can exist against a source database when you are restoring? Quick Check Answer ■ Reverting a database using a Database Snapshot causes all the changed pages within a Database Snapshot to overwrite the corresponding pages in the source database. Because this process changes the state of the database, it would immediately invalidate all Database Snapshots except the one used to revert from. Therefore, SQL Server enforces the restriction that only a single Database Snapshot can exist against a source database when you use the Database Snapshot to revert. In this way, it prevents the possibility of having invalid Database Snapshots. PRACTICE Reverting a Database from a Database Snapshot In this practice, you will revert the AdventureWorks database to a previous version using the Database Snapshot you created in the previous lesson in this chapter. 1. If necessary, open SSMS and connect to the SQL Server instance containing the Database Snapshot you created in the previous lesson in this chapter. 2. Click New Query. 3. Type the following code: RESTORE DATABASE AdventureWorks FROM DATABASE_SNAPSHOT = ’snapshottest’ 4. Verify that the data added to the table in the AdventureWorks database during the previous exercise no longer exists. Lesson Summary ■ The RESTORE DATABASE command contains a special clause that enables a DBA to revert a database from a Database Snapshot. This operation would inval- idate any other Database Snapshots created against the source database, so you must drop all other Database Snapshots before you can perform a revert. Addi- tionally, any operation that relies on a contiguous transaction log chain will be interrupted because the restore process will rebuild the transaction log. C1662271X.fm Page 610 Friday, April 29, 2005 8:00 PM Lesson 2: Reverting a Database from a Database Snapshot 611 Lesson Review The following question is intended to reinforce key information presented in this les- son. The question is also available on the companion CD if you prefer to review it in electronic form. NOTE Answers Answers to this question and explanations of why each answer choice is right or wrong are located in the “Answers” section at the end of the book. 1. Which of the following are required before a database can be reverted from a Database Snapshot? (Choose all that apply.) A. Full text catalogs on the source database must be dropped. B. Users cannot be accessing the source database or the Database Snapshot. C. Log shipping must be stopped. D. All Database Snapshots except the Database Snapshot used for the revert must be dropped. C1662271X.fm Page 611 Friday, April 29, 2005 8:00 PM 612 Chapter 16 Review Chapter Review To further practice and reinforce the skills you learned in this chapter, you can ■ Review the chapter summary. ■ Review the list of key terms introduced in this chapter. ■ Complete the case scenario. This scenario sets up a real-world situation involv- ing the topics of this chapter and asks you to create solutions. ■ Complete the suggested practices. ■ Take a practice test. Chapter Summary ■ A Database Snapshot is a point-in-time, read-only copy of a source database that can be used for read activities. ■ In addition to read activities, you can use a Database Snapshot to revert a data- base to a previous point in time defined by the instant in time at which you cre- ated the Database Snapshot. ■ Because Database Snapshots can be used for read operations as well as recover- ing to a previous point in time, they are ideal for use in situations in which DBAs would normally create an interim backup to eliminate a significant amount of time spent during maintenance operations. Key Terms Do you know what these key terms mean? You can check your answers by looking up the terms in the glossary at the end of the book. ■ catalog of changed pages ■ copy-on-write ■ Database Snapshot ■ reverting a database ■ source database ■ sparse file C1662271X.fm Page 612 Friday, April 29, 2005 8:00 PM Chapter 16 Review 613 Case Scenario: Implementing Database Snapshots for Administrative Actions In the following case scenario, you will apply what you’ve learned in this chapter. You can find answers to these questions in the “Answers” section at the end of this book. Contoso Limited, a health care organization located in Bothell, WA, has a very volatile database that contains patient claims data. The patient data is protected by privacy laws, and all access to this data is required to be audited. Audit data is written into a set of audit tables by the stored procedures that control all data access within the patient claims database. Auditors within the organization, along with external auditors, require access to audit data in the patient claims database at specific points in time. Each evening, Contoso receives data feeds from several external vendors who process payments to patients. Data in the feeds frequently needs to be edited and reimported based on validation scripts that reconcile the data within the patient claims database with the data feeds submitted by the external vendors. During the time when the import processes execute, no other transactions are issued against the patient claims database. The current process creates a full backup of the patient claims database before the import routines are executed. 1. How can Contoso DBAs reduce the amount of time it takes to import data feeds? 2. What mechanism can Contoso use to provide mutiple point-in-time copies of the data for auditors to query while minimizing the amount of time spent on administering this solution? Suggested Practices Database Snapshots are a very specific feature within SQL Server 2005. A Database Snapshot has exactly one way to create it, and there is exactly one way to revert a data- base using a Database Snapshot. Therefore, no additional practices exist for Database Snapshots beyond those already specified within this chapter. C1662271X.fm Page 613 Friday, April 29, 2005 8:00 PM 614 Chapter 16 Review Take a Practice Test The practice tests on this book’s companion CD offer many options. For example, you can test yourself on just the content covered in this chapter, or you can test yourself on all the 70-431 certification exam content. You can set up the test so that it closely sim- ulates the experience of taking a certification exam, or you can set it up in study mode so that you can look at the correct answers and explanations after you answer each question. MORE INFO Practice tests For details about all the practice test options available, see the section titled “How to Use the Prac- tice Tests” in this book’s Introduction. C1662271X.fm Page 614 Friday, April 29, 2005 8:00 PM 615 Chapter 17 Implementing Database Mirroring Database mirroring is a new Microsoft SQL Server 2005 availability technology that lets you maintain a hot or warm standby server with automatic failover and no data latency. Database mirroring, available currently as an evaluation feature that you enable by using a trace flag, operates at the database level to provide a duplicate copy of data on a mirror database and server. This chapter introduces you to database mir- roring, which will be included as a supported feature of SQL Server 2005 in a future service pack, and it explains each operating mode that you can configure for this long- awaited feature. MORE INFO Database mirroring This chapter covers the basic data mirroring information you need for the 70-431 exam. For full details about database mirroring, see the white paper “Database Mirroring in SQL Server 2005” by Ron Talmage at www.microsoft.com/technet/prodtechnol/sql/2005/dbmirror.mspx. Exam objectives in this chapter: ■ Implement database mirroring. ❑ Prepare databases for database mirroring. ❑ Create endpoints. ❑ Specify database partners. ❑ Specify a witness server. ❑ Configure an operating mode. Lessons in this chapter: ■ Lesson 1: Understanding Database Mirroring Roles. . . . . . . . . . . . . . . . . . . . . 618 ■ Lesson 2: Preparing Databases for Database Mirroring . . . . . . . . . . . . . . . . . . 622 ■ Lesson 3: Establishing Endpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627 ■ Lesson 4: Understanding Operating Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . 634 ■ Lesson 5: Failing Over a Database Mirror. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642 ■ Lesson 6: Removing Database Mirroring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645 C1762271X.fm Page 615 Friday, April 29, 2005 8:02 PM 616 Chapter 17 Implementing Database Mirroring Before You Begin To complete the lessons in this chapter, you must have ■ Three instances of SQL Server 2005 installed. ■ Either Standard or Enterprise Edition for all instances. ■ A copy of the AdventureWorks sample database on one of the instances. ■ Trace flag 1400 enabled on all three instances. NOTE Enabling database mirroring with trace flag 1400 In the release-to-manufacturing (RTM) version of SQL Server 2005, database mirroring is not a supported feature and can be enabled only by using trace flag 1400. In a future SQL Server 2005 service pack, database mirroring will be enabled and fully supported within the product. To set a trace flag, refer to the SQL Server 2005 Books Online article “DBCC TRACEON (Transact-SQL).” SQL Server 2005 Books Online is installed as part of SQL Server 2005. Updates for SQL Server 2005 Books Online are available for download at www.microsoft.com/technet/prodtechnol/sql/2005/ downloads/books.mspx. Real World Michael Hotek Since I formally entered the database industry more than a decade ago, my pri- mary focus has been on building systems to predictably achieve high levels of availability. In the 1980s and 1990s, this was a rather difficult task. It usually involved complex architectures, complicated components, and a large dose of custom coding. The tools and technologies were immature at best and nonexist- ent at worst. You could divide the availability systems that we designed back then into two basic categories. Client-oriented systems would receive a transaction and then write it to multiple destinations. And we generally built server-oriented systems around code to transfer backups between one or more systems. As technology matured, we gained additional tools that allowed basic data dupli- cation across multiple environments in a timely manner. However, this advance- ment also introduced latency between the primary and secondary databases, which could lead to data loss. We learned to deal with the potential problem because we simply could not eliminate it. C1762271X.fm Page 616 Friday, April 29, 2005 8:02 PM [...]... the SQL Server instance level instead of at the database level So for each SQL Server instance, you can create only one endpoint, which has a payload of DATABASE_MIRRORING MORE INFO Endpoints For more information about endpoints, see the SQL Server 2005 Books Online article “CREATE ENDPOINT (Transact -SQL) .” SQL Server 2005 Books Online is installed as part of SQL Server 2005 Updates for SQL Server 2005. .. allow applications to authenticate for database access You can also have linked servers, SQL Server C1762271X.fm Page 624 Friday, April 29, 2005 8: 02 PM 624 Chapter 17 Implementing Database Mirroring Integration Services (SSIS) packages, SQL Server Agent jobs, customer error messages, or other objects configured on the server Copying all of these objects to the instance hosting the mirror database... C1762271X.fm Page 626 Friday, April 29, 2005 8: 02 PM 626 Chapter 17 Implementing Database Mirroring 2 Which database setting is valid for database mirroring? A Full recovery model B 80 compatibility level C Read only D Bulk-Logged recovery model C1762271X.fm Page 627 Friday, April 29, 2005 8: 02 PM Lesson 3: Establishing Endpoints 627 Lesson 3: Establishing Endpoints SQL Server 2005 introduces a stronger, revamped,... either Standard or Enterprise Edition However, you define the witness role at an instance level The instance of SQL Server 2005 that you use for the witness server can be any edition, including SQL Server Express Edition, which is why we refer to a principal or mirror database but a witness server Quick Check ■ What are the three database mirroring roles and what functions do they serve? Quick Check... Server 2005 Books Online is installed as part of SQL Server 2005 Updates for SQL Server 2005 Books Online are available for download at www .microsoft. com/ technet/prodtechnol /sql/ 2005/ downloads/books.mspx C1762271X.fm Page 6 28 Friday, April 29, 2005 8: 02 PM 6 28 Chapter 17 Implementing Database Mirroring Endpoint Security Endpoints provide multiple layers of security that you can configure for your... loss in the event of a primary database failure C1762271X.fm Page 6 38 Friday, April 29, 2005 8: 02 PM 6 38 Chapter 17 Implementing Database Mirroring High Protection Operating Mode Database mirroring’s High Protection operating mode is the same as High Availability operating mode, except that you do not configure a witness server SQL Server transfers transactions synchronously between principal and mirror,... from the primary to the mirror database Figure 17-1 shows a reference diagram for a database mirroring configuration Witness Application SQL Server SQL Server Principal Mirror Figure 17-1 Database mirroring components C1762271X.fm Page 619 Friday, April 29, 2005 8: 02 PM Lesson 1: Understanding Database Mirroring Roles 619 Principal Role The database you configure in the principal role becomes the source... as WITNESS can participate only as a witness An endpoint specified as ALL can function in any role NOTE Endpoints on Express Edition If you are creating a database mirroring endpoint on SQL Server 2005 Express Edition, it will support only a role of WITNESS The following Transact -SQL example shows how to create a database mirroring endpoint: CREATE ENDPOINT [Mirroring] AS TCP (LISTENER_PORT = 5022)... Include Witness Server page, verify that Yes is selected This option enables you to configure an endpoint’s security for the witness server instance Click Next 7 On the Choose Servers To Configure page, you see that the Principal Server check box is selected and unavailable because it is assumed that you are running the wizard from that instance Verify that the Mirror Server Instance and Witness Server Instance... mirror, and witness endpoints on different SQL Server instances 11 On the Service Accounts page, you specify service accounts This step is optional If all the instances that you are configuring endpoints for have the SQL Server service running under the same service account, you do not have to specify anything here Otherwise, specify the service account for the SQL Server service on all three instances . flag, refer to the SQL Server 2005 Books Online article “DBCC TRACEON (Transact -SQL) .” SQL Server 2005 Books Online is installed as part of SQL Server 2005. Updates for SQL Server 2005 Books Online. instance of SQL Server 2005 that you use for the witness server can be any edition, including SQL Server Express Edition, which is why we refer to a principal or mirror database but a witness server. Quick. configuration. Figure 17-1 Database mirroring components Application SQL Server Principal SQL Server Mirror Witness C1762271X.fm Page 6 18 Friday, April 29, 2005 8: 02 PM Lesson 1: Understanding Database Mirroring

Ngày đăng: 07/08/2014, 02:22

Tài liệu cùng người dùng

Tài liệu liên quan