Saturday, 27 June 2015

Interview Questions Answers – Mirroring


1) What is Database Snapshot?
A database snapshot is a view of what the source database looked like at the time at which the snapshot was created. This means that all the objects will be the same as what it was when the snapshot was taken and all of the data will be exactly as it was then. To use database snapshots to recover from an unwanted DML statement, you need to have a suitable snapshot in place. Snapshots can only be created by using a T-SQL statement.
2) How to create a Database Snapshot?
CREATE DATABASE AdventureWorks2012_S1 ON (NAME = [AdventureWorks2012_Data], FILENAME = 'D:\ MSSQL\DATA\AdventureWorks2012_Data_SS_1.ss') AS SNAPSHOT OF AdventureWorks2012
3) How does a snapshot work?
High level tasks of snapshot involves
  • When you create a snapshot a sparse file is created for each data file
  • When data is modified in the source database for the first time, the old value of the modified data is copied to the sparse file
  • If the same data is the subsequently changed again, those changes will be ignored and not copied to the snapshot
  • When you query the snapshot, it first checks if the data is available in the snapshot. If it’s there it reads if from the snapshot. If it’s not there, I reads through to the source database and gets the data from there instead, because that means the data has not yet changed since the time the snapshot was taken
4)  What is SPARSE file?
When a database snapshot is created, a sparse file is added for each database file in the database of which the snapshot was taken. A sparse file is basically an empty file. It does not contain any data until a change is made to the source database
5) What are important things to remember about sparse files?
  • The maximum size a sparse file can grow to is the size of the original file at the time of the database creation
  • Sparse files are limited to 16 GB on Windows 2008 and 64 GB on Windows 2003
  • Sparse files grow in increments of 64 KB
6) How can we check the SPARSE files?
SELECT name, is_sparse FROM sys.database_files
7) Can we change the permissions in a database snapshot?
No it’s not possible.
8)Can we take a backup of a database snapshot?
No.
9) Can we detach a database snapshot?
No.
10) What are the restrictions in Database Snapshots?
  • Database snapshots depend on the source database. They can only be created on the same server as where the database resides (or the server to which the database is mirrored.)
  • While there are snapshots present, you cannot drop the database or add any new files to it
  • Once a database snapshot becomes suspect it cannot be saved. It just has to be deleted. This can happen if the snapshot runs out of space or reaches the maximum sparse file size limit
  • You cannot create indexes on snapshots, they are strictly read only
  • The user permissions are exactly the same as it was in the source database. You cannot grant a user access to a snapshot. You have to grant the access in the source database and then take another snapshot first before the user will be able to access it
11) What are the benefits of Database Snapshots?
  • Snapshots can be used for reporting purposes.
  • Using a mirror database that you are maintaining for availability purposes to offload reporting.
  • Safeguarding data against administrative and user error
12) Can we configure mirroring between Standard Edition & Enterprise Edition or Vice Versa?
No it’s not possible, both principal and mirror should have same edition
13) Is it possible to take backup of mirrored database in mirror server?
No
14) Can I create multiple endpoints for configuring different databases for mirroring and point each database to unique endpoint?
No
15) Can I configure a single database to be mirrored to more than one server. i.e) One source & many destination like logshipping?
No
16) How to know the database mirroring connection time out in Mirroring?
SELECT Mirroring_Connection_Timeout FROM sys.database_mirroring WHERE database_id = db_id('Database Names')

17) How can I increase Heartbeat time between principal and mirror server? By default its 10 sec.
ALTER DATABASE AdventureWorks SET PARTNER TIMEOUT 30
18) What status of mirroring has if secondary is down?
If secondary is down principle or Mirror show status disconnected
19) What status of mirroring has if principle is down?
If principle is down mirror will be disconnected with in recovery instead of synchronized with restoring
20) What status of mirroring has if mirroring is paused?
If mirroring is set to paused from principle then both principle & mirror in suspending
21) How to monitoring Mirroring?
There are six methods are available for monitoring the Database Mirroring
a) Database Mirroring Monitor:- Database Mirroring Monitor is a GUI tool that shows update status and to configure warning thresholds.
To open DM Monitor:- Right click on Principal Database > Tasks > Select Launch Database Mirroring Monitor.
b) SQL Server Management Studio:- A green arrow on the mirror server is indicates running well. A red arrow indicates problems that need to investigate.
c) SQL Server Log:- It provides information of Mirroring establishment and status. If any errors occur it will be logged to SQL Server log and Windows event log.
d) Performance Monitor:- It can provides real-time information about Database mirroring. We can use performance counters to get status of the database mirroring such as Bytes received/sec, Bytes sent/sec, Transaction delay etc.
e) Profiler:- Profiler many events are providing the status of the Database mirroring
f) System Stored Procedures:-
sp_dbmmonitoraddmonitoring
sp_dbmmonitorchangemonitoring
sp_dbmmonitorhelpmonitoring
sp_dbmmonitordropmonitoring
22) What will be the impact if we add data files to the Primary database in Database Mirroring?
Data files will be added to the Mirror database if the identical location is present at the mirrored server without any issues.
23) What will be the impact if we add data files to the Primary database with a location which is not present on the Mirrored server in Database Mirroring?
Database mirroring will not work in this case. We have to break the Mirroring and take a Log backup of the Primary database and restore it on the Mirror database using “WITH MOVE” and “NORECOVERY” option. Once it’s done then Reestablish the mirroring.
24) If we add any users to the Primary database, will it be copied to the Mirror databases or not?
Yes, It will be copied to the Mirror database with the permissions. However you have to create the login manually with the same SID.s
25) How to disable mirroring by scripts?
ALTER DATABASE <sdatabase_name> SET PARTNER OFF
26) How to do manual failover to Mirror when principle is working fine?
ALTER DATABASE <DB Name> SET PARTNER FAILOVER
27) What is Transparent Client Redirection?
Database mirroring provides a feature of automatically redirection of the Application connection to Mirror database in case of Primary database failures. Database connections configured as below to enable this functionality.
Data Source=SQLA;Failover Partner=SQLB;Initial Catalog = AdventureWorks2008R2 ; Integrated Security=True
28) What is Log buffer?
Log buffer is a small contiguous memory structure, only 60k maximum, to host in memory transaction logs per database. When the transaction is committed, entire buffer will be written to transaction log file before commit finishes.
29) What is Automatic Page Repairing?
Automatic page repair is supported by database mirroring. After certain types of errors corrupt a page, making it unreadable, a database mirroring partner (principal or mirror) attempts to automatically recover the page. The partner/replica that cannot read the page requests a fresh copy of the page from its partner. If this request succeeds, the unreadable page is replaced by the readable copy, and this usually resolves the error, this whole process is called Automatic Page Repair.
30) What are the error types which cause and Automatic Page Repair attempt?
Error number
Description
Instances that cause automatic page-repair attempt
Action is taken only if the operating system performed a cyclic redundancy check (CRC) that failed on the data.
ERROR_CRC. The operating-system value for this error is 23.
Logical errors.
Logical data errors, such as torn write or bad page checksum.
829
A page has been marked as restore pending.
All.
31) What are the page types which are not repairable using Automatic Page repair option?
Automatic page repair cannot repair the following control page types:

  • File header page (page ID 0).
  • Page 9 (the database boot page).
  • Allocation pages: Global Allocation Map (GAM) pages, Shared Global Allocation Map (SGAM) pages, and Page Free Space (PFS) pages.

Interview Questions Answers –Logshipping

  1. What is High Availability in SQL Server?
A high availability solution masks the effects of a hardware or software failure and maintains the availability of applications so that the perceived downtime for users is minimized.SQL Server high-availability solutions improve the availability of servers or databases.
  1. What all High Availability options are available in SQL Server?
At a high level, there are five main high availability options including a new feature set to be release with SQL Server 2012:
  • Log Shipping
  • Mirroring
  • Replication
  • Clustering
  • AlwaysON
3.    What is Log Shipping?
Log shipping is the process of automating the backup of database and transaction log files on a production SQL server, and then restoring them onto a standby server. But this is not all. The key feature of log shipping is that it will automatically backup transaction logs throughout the day (for whatever interval you specify) and automatically restore them on the standby server. This in effect keeps the two SQL Servers Databases in “synch”.
  1. What are the Benefits of Log Shipping?
Benefits of log shipping, let’s take a more comprehensive look:
  • Log shipping doesn’t require expensive hardware or software. While it is great if your standby server is similar in capacity to your production server, it is not a requirement.
  • Once log shipping has been implemented, it is relatively easy to maintain.
  • Assuming you have implemented log shipping correctly, it is very reliable.
  • The manual failover process is generally very short, typically 15 minutes or less.
  • Implementing log shipping is not technically difficult.
  1. What the drawbacks of Log Shipping?
  • Log shipping failover is not automatic. The DBA must still manually failover the server, which means the DBA must be present when the failover occurs.
  • The users will experience some downtime. How long depends on how well you implemented log shipping, the nature of the production server failure, your network, the standby server, and the application or applications to be failed over.
  • Some data can be lost, although not always. How much data is lost depends on how often you schedule log shipping and whether or not the transaction log on the failed production server is recoverable.
  • The database or databases that are being failed over to the standby server cannot be used for anything else. But databases on the standby server not being used for failover can still be used normally.
  • When it comes time for the actual failover, you must do one of two things to make your applications work: either rename the standby server the same name as the failed production server (and the IP address), or re-point your user’s applications to the new standby server. In some cases, neither of these options is practical.
  1. In which recovery model Log Shipping can be configured?
Log Shipping works with Full and Bulk Logged recovery model.
  1. Is it possible to configure Log Shipping from lower version to upper version and Vice versa?
Yes it is possible to configure Log Shipping from lower to upper version. But it is not possible vice versa.
  1. What is Log Shipping Monitor Settings?
This setting enables us to setup a monitor on the Log shipping through which we can monitor the log shipping process.
  1. What all jobs are created after configuring the Log Shipping?
Internally when Log Shipping is configured, there are 4 jobs created between Primary Server and Secondary Server, they are Backup Job, Copy Job, Restore Job and Alert Job
  • Backup job: This job is created on Primary Server; this job takes the transaction log backup of the Database on a scheduled time
  • Copy Job: This job is created on Secondary Server, this job Copies the transaction log Backup from Primary Server to the Standby/Secondary Server.
  • Restore Job: This job is created on Secondary Server; this job restored the copied transaction log backup on the Secondary Server.
  1. What permissions are required for shared folders on Primary and secondary for the service accounts?
  • For the backup job, read/write permissions to the backup directory are required to the following:
SQL Server service account on the primary server instance.
Proxy account of the backup job. By default, this is the SQL Server Agent account on the primary server instance.
  • For the copy job, read permissions to the backup directory and write permissions to the copy directory are required by the proxy account of the copy job. By default, this is the SQL Server Agent account on the secondary server instance.
  • For the restore job, read/write permission to the copy directory are required by the following: The SQL Server service account on the secondary server instance. The proxy account of the restore job. By default, this is the SQL Server Agent account on the secondary server instance.
  1. What is the copy Job in Log shipping and on which instance it’s created?
  • Created in secondary server for every log shipping configuration.
  • Copy the backup files from backup folder into copy folder.
  • It deletes old files and old history from copy folder.
  • On backup folder we have to grant read permission to secondary server account and read-write permissions on copy folder.
  1. What is Monitor server?
An optional instance of SQL Server that tracks all of the details of log shipping, including:
  • When the transaction log on the primary database was last backed up.
  • When the secondary servers last copied and restored the backup files.
  • Information about any backup failure alerts.
  1. What are Log Shipping System Tables and in which database these are stored?
SQL Server Log Shipping System Tables
  • log_shipping_monitor_primary – Stores one monitor record per primary database in each log shipping configuration.
  • log_shipping_monitor_secondary – Stores one monitor record per secondary database in a log shipping configuration.
  • log_shipping_primary_databases – Stores one record for the primary database in a log shipping configuration.
  • log_shipping_secondary – Stores one record per secondary ID
  1. What are Log Shipping System Store Procedures?
SQL Server will issue a series of steps to synchronize the information between primary/secondary server and the monitor server. This can be implemented by running the below undocumented log shipping stored procedures:
  • sp_processlogshippingmonitorprimary
  • sp_processlogshippingmonitorsecondary
  1. Is it possible load balance in Log Shipping?
Yes, it’s possible in log shipping, while configuring log shipping we have the option to choose standby or no recovery mode, there we select STANDBY option to make the secondary database readonly.
  1. What is STANDBY Mode on the secondary database?
We can reduce the load on our primary database by using a secondary server for read-only query processing. To do this, the secondary database must be in STANDBY mode.
  1. What’s the difference between the secondary being in “Restoring” vs. “Standby”?
There are two options for configuration when we place the secondary database in standby mode:
  • We can choose to have database users disconnected when transaction log backups are being restored. If we choose this option, users will be disconnected from the database each time the log shipping restore job attempts to restore a transaction log to the secondary database. Disconnection will happen on the schedule you set for the restore job.
  • We can choose not to disconnect users. In this case, the restore job cannot restore transaction log backups to the secondary database if there are users connected to that database. Transaction log backups will accumulate until there are no user connections to the database.
  1. What is TUF file?
TUF stands for Transaction Undo file.
  1. What will happen to Log Shipping if TUF file is corrupted or lost?
The log shipping will not work. We have to setup the Log Shipping again.
  1. If you create a Job on the Primary database server, will it automatically be created on the secondary server or not?
No, it will not be created on the secondary server.
  1. If you create a user on the Primary database, will it automatically be created on the secondary or not?
Yes, it will be created automatically on the secondary database.
  1. If you add a file on the Primary database in the same location which exists on the target, will it automatically be created on the secondary or not?
Yes, it will be created automatically on the Secondary database if the file is added to the Primary database.
  1. If you add a file on the Primary database in a location which does not exist on the target, will it automatically be created on the secondary or not?
No, Log Shipping will hang. We have to manually restore the Log backup with MOVE option on the secondary database to rectify the issue.
  1. Is it possible to configure Log shipping on the database server with different collation?
No.
  1. Can we configure Log Shipping between the different domains?
Yes, we can configure Log Shipping on the server residing in different domains.
  1. What are the store procedures to monitor Log Shipping?
We can execute the below Log Shipping System Stored Procedure to monitor log shipping and get detailed information about log shipping.
  • sp_help_log_shipping_monitor – This is the how SQL Server generates the Log Shipping Status report by executing
  • sys.sp_help_log_shipping_monitor – This procedure returns the log shipping status (whether it is healthy or not) as well as metadata such as primary and secondary database names, time since last backup, last backup file, last restore file, etc…
  • sp_help_log_shipping_monitor_primary – returns all columns from the log_shipping_monitor_primary table for the specified primary log shipping database. It returns server name, database name, time of last backup, backup threshold, threshold alert and history retention period.
  • sp_help_log_shipping_monitor_secondary – returns all columns from log_shipping_monitor_secondary table for the specified secondary log shipping database. It will return database name, server name, restore threshold, last copied file, time of last copy / restore and history retention period.
  1. Can we setup multiple secondary databases in Log Shipping?
Yes, we can setup multiple secondary databases in Log Shipping.
  1. Can we shrink log shipped database log file?
Yes, we can shrink the log file, but we shouldn’t use WITH TRUNCATE option. If we use this option obviously log shipping will be disturbed.
  1. Can we take full backup of the log shipped database in primary server?
Yes it’s possible. We can take full backup of log shipped database and this won’t affect the log shipping.
  1. What editions of SQL Server is log shipping available in?
  • 2012 – Enterprise, Business Intelligence, Standard, and Web
  • 2008R2 – Datacenter, Enterprise, Standard, Web, and Workgroup
  • 2008 – Enterprise, Standard, Web, and Workgroup
  • 2005 – Enterprise, Standard, and Workgroup
  1. Can we take full backup of the log shipped database in secondary server?
No, we won’t be able to execute BACKUP command against a log shipped database in secondary server.




SQL SERVER DBA HIGH AVAILABILTY(Interview Questions)

SQL SERVER DBA – HIGH AVAILABILTY

Logshipping

1.What is Log shipping and purpose of Log shipping?
To achieve high availability and high protection, Log shipping copies transactions from a ‘primary server’ to one or more ‘secondary servers’. In Log shipping, T.Log backups are sent to one or more secondary servers and then restored to the destination servers individually. If the Primary database becomes unavailable, any of the secondary database can brought into online manually. The Secondary server acts as a Backup server and provides read-only query processing to reduce the load on the Primary server. (For query processing, secondary servers should be configure in stand-by mode).

2.What is Primary Server, Secondary Server & Monitor Server?

Primary Server: - Primary Server is a Production server which holds the original copy of the database. Log shipping configuration and administrating will be done from Primary Server.
Secondary Server: - Secondary servers hold the standby copy of the database. We must initialize the DB on a secondary server by restoring a backup from the Primary server using either NORECOVERY option or the STANDBY option. By using STANDBY option Users can have read-only access to it.
Monitor Server: - An optional Server is called as Monitor Server that records history and status of backup, copy and restore operations and raises alerts if any operations fail. The Monitor Sever should be on separate server to avoid losing critical information. Single Monitor Server monitors multiple Log shipping configurations.

3.What are the Jobs running for Log shipping and explain them?

Log shipping having four operations which are handled by SQL Server Agent Job.

i.Backup Job: - Backup job is created on Primary Server instance and it performs backup operation. It logs history on the local server and monitor severs and deletes old backup files and history information.
ii.Copy Job: - Copy Job is created on Secondary server instance and it performs copies the backup files from primary sever to secondary server. It logs history on the secondary server and monitor server.
iii.Restore Job: - Restore Job is created on the Secondary server instance and it performs restore operation. It logs history on the local server and monitor server and deletes old files and history information.
iv.Alert Job: - If a Monitor Server is used, the Alert Jobs is created on the Monitor server instance and it raises Alerts if any operations have not completed successfully.

4.Requirements for Log shipping?
i.SQL Server 2005 Standard Edition, Workgroup Edition, or Enterprise Edition must be installed on all server instances involved in log shipping.
ii.All servers should have the same case sensitivity settings.
iii.The databases must use the full recovery model or bulk-logged recovery model.

5.How to configure Log shipping?
i.Choose Primary Server, Secondary Servers, and optional Monitor server.
ii.Create a File share to keep Transaction log backups (Best to place on a separate computer)
iii.Create a folder for each Secondary server into which transaction log backup copies.
iv.Choose Backup Schedule for Primary Database
v.Choose Copy and Restore Schedules for Secondary Database
vi.Choose Alert Job schedule for Monitor Server if configured

6.What are permissions required for Log shipping?
We must have sysadmin on each server instance to configure Log shipping.

7.In Logshipping which Recovery Models can we used?
We can use either full or bulk logged recovery model for log shipping.


8.Where you monitoring Log shipping and how?
We can monitoring the Log shipping in the following ways.
i.)Monitor server (History Tables):- Monitor Server tracks all statistics, status and errors that could be happen during Log shipping.
Log_shipping_monitor_primary:- Stores primary server status
Log_shipping_monitor_secondary:- Stores secondary servers status
     Log_shipping_monitor_history_detail:- Contains history details for logshipping agents.
     Log_shipping_monitor_error_detail:- Stores error details for log shipping jobs.
     Log_shipping_monitor_alert:- Stores Alert Job ID
ii.)System Stored Procedures (MSDB):- System Stored procedures gives the history information about the specified server that are configured in Log shipping.
    sp_help_log_shipping_monitor (Run at Monitor Server)
    sp_help_log_shipping_monitor_primary @Primary_Database = ‘DBName’ (Run at MS)
    sp_help_log_shipping_monitor_secondary @ Secondary_Database = ‘DBName’ (Run at MS)
   sp_help_log_shipping_alert_job (Run at Mon Server)
   sp_help_log_shipping_primary_database @ Database = ‘DBName’ (Run at Primary Server)
   sp_help_log_shipping_secondary_database @ Database = ‘DBName’ (Run at Sec Server)
iii.)Transaction Log shipping Status report (Summary Reports):-  This report shows the status of log shipping configurations for which this server instance is a primary, secondary or monitor.
 iv.)SQL Server Agent Job History
 v.)Checking the SQL Server Log

9.How Secondary Server will brought into Online, if the Primary Server becomes Unavailable?
If the Primary Server will become un-available, do the following steps.
a)            Take the Tail of Log from Primary server
b)            Restore Tail of log into all Secondary Database
c)            Remove Log-shipping configuration from Primary Server
d)            Select any one of Secondary server and bring into online with
           Alter Database  DBName set Online
e)            Right click on Primary Database and Generate script for Users and Logins.
f)            Then move the script to Secondary server to create Users and Logins
g)            Re-configure log shipping from New Server (Secondary server)

10.What are errors occurred in Log shipping?
There are two errors are occurred during Log shipping
1)            14420:- This error occurs when the Backup job fails
2)            14421:- This error occurs when the Restoring job fails

11.What is the use of .wrk and .TUF file in LOGSHIPPING?

TUF File: Its Transaction Undo File. It Generated only when you Have Configured Log Shipping With Stand By Option. Since In Stand by Log Shipping Secondary Database is Available to User. So TUF Keep Pending Transaction like uncommitted which are in Log File Came From Primary So That when Next Log Backup Will Come From Primary They Can Be Synchronized At Secondary.

 .WRK File:  This Extension Is Given To A File Which is  Being Copied From Primary
  Backup location to Secondary and once Copy Process has been completed these
 file are renamed with .trn file.

12) How to find out the trasactions latency primary to secondary in logshipping?
Tracio Tokency property in distributer.
13) How to find out the trasactions not coming from primary to secondary in logshipping?
If ms_repl commands are not executed then we are facing, so we can execute the ms_repl commands.


Mirroring

1)   What is Database Mirroring? What are the benefits of that?
Database mirroring is a method of increasing database availability”, which supports automatic failover with no loss of data.
Benefits:-
h)  Increases data protection.
i)   Increases availability of a database.
j)   Improves the availability of the production database during upgrades.

2)   What are the prerequisites for Database Mirroring?
a)            Both Servers are requires same edition either Standard Edition or Enterprise Edition.
b)            If Witness server configured, the server should be installed Standard Edition, Enterprise Edition, Workgroup Edition, or Express Edition.
c)            All Servers should use the same master code page and collation.
d)            Mirror Server has same database name and use only With NoRecovery option.
e)            Mirroring uses the full recovery model. (Simple and bulk-logged not supported)
f)            All logins for connecting Principal Database should be reside on Mirror database

3)   What are the Restrictions for Database Mirroring?
a)  Maximum 10 databases per instance can support on a 32-bit system.
b)  Database mirroring is not supported with either cross-database transactions or distributed transactions.

4)   Explain about Principal, Mirror and Witness Servers?
1)            Principal Server:-  One Server serves the database to client is called Principal server and it having original data. Can have only one Principal Server and it has to be on a separate server.
2)            Mirror Server:- Other server instance acts as a hot or warm standby server is called Mirror server and it having copy of database.
3)            Witness Server:- The witness server is an optional server and it controls automatic failover to the mirror if the principal becomes unavailable. To support automatic failover, a database mirroring session must be configured in high-availability.

5)   In which Operations are running the Operating Modes?
Asynchronous:- Under asynchronous operation, the Principal server does not wait for a response from the mirror server after sending the log buffer.
Synchronous:- Under synchronous operation, the Principal server sends the log buffer to the mirror server, and then waits for a response from the mirror server.

6)   What are the Operating Modes and explain them?
a.            High Availability:- High-availability mode, runs synchronously. Requires a Witness Server instance. The Principal server sends the log buffer to the mirror server, and then waits for a response from the mirror server.
b.            High Protection:- High-protection mode, runs synchronously. Always commit changes at both the Principal and Mirror.
c.            High Performance:- High-performance mode, runs asynchronously and the transaction safety set to off. The Principal server does not wait for a response from the mirror server after sending the log buffer. The principal server running nice and fast, but could lose data on the mirror server.

7)   What is the default of Port numbers of Principal and Mirror servers? How to find the Port numbers?
The default port numbers of principal and mirror servers are 5022 and 5023.
To Find Port Number:- SELECT name, port FROM sys.tcp_endpoints



8)   What is End Point? How u create end point?
An endpoint is a network protocol which is used to communicate over the network.
Creation of an end point:
Create endpoint <endpoint name> State=started/stopped/disabled
          as tcp (listener port=5022/5023) for database_mirroring (role=partner/witness)

9)   Which Trace flag is used in Mirroring?
Trace flags are used to temporarily set specific server characteristics or to switch off/on a particular behavior. 1400 Trace flag is used in mirroring.
To set trace flag for Database mirroring:- Configuration Manager > Right click on server instance > Properties > Advanced tab > Startup parameters > -t1400 (add)

10)                In which Recovery model we can use in Mirroring?
In mirroring the principal and mirror databases are used only full recovery model

11)                What is Role-switching?
Inter changing of roles like principal and mirror are called role switching.

12)                What is the Syntax to stop the Database Mirroring?
Alter database <database name> set partner off

Failover: Alter database <database name> set failover

alter database database_name set partner force_service_allow_data_loss

13)                How to configure Mirroring?
a)  Choose Principal Server, Mirror Server, and optional Witness server.
b)  The principal and mirror server instances must be running the same edition either Standard Edition or Enterprise Edition
c)  The Witness server instance can run on SQL Server Standard Edition, Enterprise Edition, Workgroup Edition, or Express Edition
d)  Mirror database requires restoring a recent backup and one or more T.log backups of the principal database (with Norecovery)

14)                How to monitoring Mirroring?
There are six methods are available for monitoring the Database Mirroring
a)  SQL Server Management Studio:- A green arrow on the mirror server is indicates running well. A red arrow indicates problems that need to investigate.
b)  SQL Server Log:- It provides information of Mirroring establishment and status. If any errors occurs it will be logged to SQL Server log and Windows event log.
c)  Performance Monitor:- It can provides real-time information about Database mirroring. We can use performance counters to get status of the database mirroring such as Bytes received/sec, Bytes sent/sec, Transaction delay etc.
d)  Profiler:- Profiler many events are providing the status of the Database mirroring
e)  Database Mirroring Monitor:- Database Mirroring Monitor is a GUI tool that shows update status and to configure warning thresholds.
To open DM Monitor:- Right click on Principal Database > Tasks > Select Launch Database Mirroring Monitor.
f)  System Stored Procedures:-
1.  sp_dbmmonitoraddmonitoring
2.  sp_dbmmonitorchangemonitoring
3.  sp_dbmmonitorhelpmonitoring
4.  sp_dbmmonitordropmonitoring

15)                What is Hardening?
As quickly as possible, the log buffer is written to the transaction log on disk, a process called hardening.

16)                What is Log buffer?
A log buffer is a special location in memory (RAM). SQL Server stores the changes in the database’s log buffer.
17)                How to Set a Witness Server to Database Mirroring?
SSMS:- Right Click on Principal Database > Tasks > Mirror > Click on Configure Security > Provide the End point for Witness server > Click oK
T-SQL:- ALTER DATABASE AdventureWorks SET WITNESS = 'TCP://prasad.local:5024' (Do this from the Principal Server)

18)                How to Remove a Witness Server from Database Mirroring?
SSMS:- Right Click on Principal Database > Tasks > Mirror > Remove TCP address from the Witness > Click oK
T-SQL:- ALTER DATABASE AdventureWorks SET WITNESS OFF

19)                How to Setup Fully Qualified Names for Database Mirroring?
I. FQDN Error
One or more of the server network addresses lacks a fully qualified domain name (FQDN).  Specify the FQDN for each server, and click Start Mirroring again.

The syntax for a fully-qualified TCP address is:
TCP://<computer_name>.<domain_segment>[.<domain_segment>]:<port>

 

II. RECTIFYING FULLY QUALIFYED NAMES

1)                            To View Endpoints:-SELECT * FROM sys.database_mirroring_endpoints;
2)                            Remove existing all Endpoints from Principal, Mirror and Witness servers :- DROP ENDPOINT [ENDPOINT_NAME]
3)                           Adding "local" as the primary DNS suffix as follows:-
a)  Right-click My Computer, and then click Properties. The System Properties dialog box will appear.
b)  Click the Computer Name tab.
c)  Click Change. The Computer Name Changes dialog box will appear.
d)  Click More. The DNS Suffix and NetBIOS Computer Name dialog box will appear.
e)  Enter the appropriate DNS suffix for the domain.
f)  Select the Change primary DNS suffix when domain membership changes check box.
g)  Click OK to save the changes, and then click OK to exit the Computer Name Changes dialog box.
h)  Click OK to close the System Properties dialog box, and then restart the computer for the change to take effect.
4)                            Reconfigure the Database mirroring either GUI or T-SQL



20)                What are the Database Mirroring states?

1) SYNCHRONIZING:-
The contents of the mirror database are lagging behind the contents of the principal database. The principal server is sending log records to the mirror server, which is applying the changes to the mirror database to roll it forward.
At the start of a database mirroring session, the database is in the SYNCHRONIZING state. The principal server is serving the database, and the mirror is trying to catch up.

2)  SYNCHRONIZED:-
When the mirror server becomes sufficiently caught up to the principal server, the mirroring state changes to SYNCHRONIZED. The database remains in this state as long as the principal server continues to send changes to the mirror server and the mirror server continues to apply changes to the mirror database.
If transaction safety is set to FULL, automatic failover and manual failover are both supported in the SYNCHRONIZED state, there is no data loss after a failover.
If transaction safety is off, some data loss is always possible, even in the SYNCHRONIZED state.


3) SUSPENDED:-
The mirror copy of the database is not available. The principal database is running without sending any logs to the mirror server, a condition known as running exposed. This is the state after a failover.
          A session can also become SUSPENDED as a result of redo errors or if the administrator pauses the session
          SUSPENDED is a persistent state that survives partner shutdowns and startups.
4) PENDING_FAILOVER:-
          This state is found only on the principal server after a failover has begun, but the server has not transitioned into the mirror role.
          When the failover is initiated, the principal database goes into the PENDING_FAILOVER state, quickly terminates any user connections, and takes over the mirror role soon thereafter.
5) DISCONNECTED:-
          The partner has lost communication with the other partner











Replication

1) What is Replication?
“Replication is the process of copying and distributing data between databases to different servers throughout the enterprise”.
Replication is a set of technologies for copying and distributing data and database objects from one database to another and then synchronizing between databases to maintain consistency.

2) What are the uses of Replication?
a)  Server to Server Replication:-
1.  Improving scalability and availability
2.  Data warehousing and reporting
3.  Integrating data from multiple sites
4.  Integrating heterogeneous data
5.  Offloading batch processing
b)  Server to Client Replication:-
1.  Exchanging data with mobile users
2.  Retail point of sale (POS) applications
3.  Integrating data from multiple sites

3) Types of Replication and explain each?
a)  Snapshot replication:- Snapshot replication takes a picture or a snapshot of the database and propagated to the subscribers. It reduces the overhead on the Publishers and Subscribers because it does not monitor data updates. Snapshot replication is very useful, when the source data is changes occasionally (Reporting).
b)  Transactional replication:- Transactional Replication starts with a snapshot of the publisher database. With Transactional Replication, any changes made to the articles are captured from the transactional log and propagated to the distributors continuously and automatically. Using Transactional Replication we can keep the publisher and subscriber in almost exactly the same state.
c)  Merge replication:- Merge Replication starts with a snapshot of the publisher database. Subsequent data changes and schema modifications made at the Publisher and Subscribers are tracked with triggers. The Subscriber synchronizes with the Publisher when connected to the network and exchanges all rows that have changed between the Publisher and Subscriber since the last time synchronization occurred.

4) Explain about Publisher, Subscriber and Distributer?
a)  Publisher:- The Publisher is a database that makes data available for replication. The Publisher can have one or more publications.
b)  Distributor:- The distributor is the intermediary between the publisher and subscriber. It receives published transactions or snapshots and then stores and forwards these publications to the subscribers.
c)  Subscribers:-  Subscribers are database servers that store the replicated data and receive updates. A subscriber can receive data from multiple publishers. Based on the replication type, the Subscriber can also pass data changes back to the Publisher or republish the data to other Subscribers.

5) Explain about Article, Publication, Subscription?
a)  Article:- An Article is the data, transactions, or stored procedures that are stored within a publication. This is the actual information that is going to be replicated.
b)  Publication:- The publication is the storage container for different articles. A subscriber can subscribe to an individual article or an entire publication.
c)  Subscription:-Subscription is a request by the subscriber to receive the publication.

6) Which recovery models are used for Replication?
Full and Bulk-logged Recovery models


7) How to monitor the Replication?
a)  Replication Monitor:- Replication Monitor is a GUI tool provides detailed information on the status and performance of publications and subscriptions.

By using replication monitor we can find out
(1) which subscriptions are slow
         (2) Why is an agent not running
         (3) Time taken to transaction commit
         (4) Why merge replication is slow
         (5) How far behind subscription etc.

To launch Replication Monitor :- Connect Instance > Right Click on Replication folder >
 Select launch Replication monitor
b)  Management Studio:- By using management Studio we can see View Snapshot Agent Status, View Log Reader Agent Status, View Synchronization Status etc.
Through SSMS:- Connect Instance > Right Click on Publication > Select the option

c)  System Monitor:- Provides information on the performance of various processes of Replication.

8)           What are the Agents available for Replication and explain each?

SQL Server Agent hosts and schedules the agents used in replication and also controls and monitors operations outside of replication.
b)  Snapshot Agent:-The Snapshot Agent is typically used for all types of replication.

It is responsible for copying the schema and data from the publisher to the subscribers, stores the snapshot files, and records information about synchronization in the distribution database. The Snapshot Agent runs at the Distributor.

c)  Log Reader Agent:- The Log Reader Agent is used for transactional replication. It moves information from the transaction log on the publisher to the distribution database.
d)  Distribution Agent:- The Distribution Agent is used for snapshot replication and transactional replication. It is responsible for moving the stored transactions from the distributor to the subscribers.
e)  Merge Agent:- The Merge Agent is used for merge replication. It is responsible for converging records from multiple sites and then redistributing the converged records back to the subscribers.
f)  Queue Reader Agent:- The Queue Reader Agent is used for transactional replication with the queued updating option. It runs on the Distributor and is responsible for reading messages from the queue on the subscribers and applying them to the appropriate publication.

9)           What are the Agents used for Transactional Replication?
a)            Snapshot Agent
b)            Log Reader Agent
c)            Distribution Agent

10)        What are the Agents used for Merge Replication?
a)    Snapshot Agent
b)    Merge Agent

11)        What is the Process of Transactional Replication?
Three Agents are doing the Process for Transactional Replication


CLUSTERING

1) What is Windows Cluster?
Clustering can be best described as a technology that automatically allows one physical server to take over the tasks and responsibilities of another physical server that has failed. The obvious goal behind this, given that all computer hardware and software will eventually fail, is to ensure that users running mission-critical applications will have very less downtime when such a failure occurs.

2) What is a Cluster Node?
A cluster node is a server within the cluster, and it has Windows Server and the Cluster service installed.
3) What is called a Resource in Windows cluster?
A resource is a physical or logical entity, which has below properties:
  • Can be brought online and taken offline
  • Can be managed in the failover cluster
  • Can be owned by only one node at a time
To manage resources, Cluster service communicates with a resource DLL through Resource Monitor.
4) What are the different states of a Resource in Windows cluster?
All resources can have following states
  • Offline
  • Offline_Pending
  • Online
  • Online_Pending
  • Failed
5) What is the difference between Active\Passive and Active\Active cluster?
·         Active\Passive :  An Active – Passive cluster is a failover cluster configured in a way that only one cluster node is active at any given time. The other node, called as Passive node is always online but in an idle condition, waiting for a failure of the Active Node, upon which the Passive Node takes over the SQL Server Services and this becomes the Active Node, the previous Active Node now being a Passive Node.
·         Active\Active : An Active – Active cluster is a failover cluster configured in a way that both the cluster nodes are active at any given point of time. That is, one Instance of SQL Server is running on each of the nodes always; when one of the nodes has a failure, both the Instances run on the only one node until the failed node is brought up (after fixing the issue that caused the node failure). The instance is then failed over back to its designated node.

ACTIVE_PASSIVE: When two nodes cluster without msdtc
        We have 6 IPs which
  • 2 Windows nodes – Public
  • 2 Private IP Addresses – Private
  • 1 Windows Virtual Cluster Name
  • 1 MSDTC
  • 1 SQL Server Virtual Network Name
ACTIVE_ACTIVE: When two nodes cluster without msdtc

We have 7 IPs which is
  • 2 Windows nodes – Public
  • 2 Private IP Addresses – Private
  • 1 Windows Virtual Cluster Name
  • 1 MSDTC
  • 1 SQL Server Virtual Network Name
If Analysis services:
  • 1 SQL Server Analysis Services
Quorum has participate nodes information.


1)   Difference between SQLSERVER 2005 and SQLSERVER 2008 Cluster Installation?

In SQL2005 we have the option of installing SQL in remaining nodes from the primary node,
But in SQL2008 we need to go separately (Login to the both nodes) for installing sql cluster.

2)   What is MSDTC in SQL Server clustering?

MSDTC stands for Microsoft Distributed Transaction Coordinator.

The Microsoft Distributed Transaction Coordinator service (MSDTC) tracks all parts of the transactions process, even over multiple resource managers on multiple computers. This helps ensure that the transaction is committed, if every part of the transaction succeeds, or is rolled back, if any part of the transaction process fails.

3)   What is Quorum in SQL Server clustering?
This is a logical drive assigned on the shared disk array specifically for Windows Clustering. Clustering services write constantly on this drive about the state of the cluster. Corruption or failure of this drive can fail the entire cluster setup. It also acts as a voter in the fail over process in case of odd number of nodes.

Different types of Quorum Models supported in windows Server 2008?
  • Node Majority – Used when Odd number of nodes are in cluster.
  • Node and Disk Majority – Even number of nodes (but not a multi-site cluster)
  • Node and File Share Majority – Even number of nodes, multi-site cluster
  • No Majority: Disk Only – This is the traditional MSCS quorum model, where a shared quorum disk must be online and nodes must be able to communicate with that disk.

  http://dbanaga.blogspot.in