Documentos de Académico
Documentos de Profesional
Documentos de Cultura
on replicated database
High Availability - LOG SHIPPING
Points to Remember:
----------------------------We can ship all databases except master, model, read-only and the databases whose
recovery model is SIMPLE.
We should have sysadmin privileges on both servers.
Changing recovery model from FULL or BULK LOGGED to SIMPLE will break log shipping
process.
We cannot take ad-hoc Transaction Log backups from primary server as it breaks log shipping
log
backup chain.
Architecture
-----------------Log Shipping Jobs
-----------------------* Log shipping supports 4 jobs
* Backup Job
* Copy Job
* Restore Job
* Alert Job
a. 1. Backup Job
------------------* It is created in primary server for every log shipping configuration.
* It takes backups of T-Log file periodically and deletes old backups and old history
information.
* We have to grant read write permissions on Backup folder to primary server service account
and read permissions to secondary server account.
2. Copy Job
---------------* 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.
3. Restore Job
-------------------* It is created in secondary server for every log shipping configuration.
* It restores the files from Copy folder into secondary server in standby mode.
4. Alert Job
---------------* It is created in Monitor server.
* If monitor server is not used it is created in primary and secondary servers.
* Only one instance of Alert Job is created.
Requirements
------------------* Minimum 2 servers are required.
* Database must be in FULL or BULK LOGGED recovery model.
* Any of the editions
* Enterprise Edition
* Standard Edition
* Workgroup Edition
* Both the servers should have same collation settings.
Steps
-------1.
2.
1.
1.
1.
Note:
We have to configure on existing database.
6. Go to Secondary Server
* Create folder with the name d:\SureshFiles and grant read write permissions to service
account.
(Not required to perform manually)
1.
To Database: suresh
Select From Device:
1.
* Select the option "No, the secondary database is initialized (Yes, generate full
backup)
* Select "Standby Mode" option and checkbox "Disconnect users in the database
when..."
* Click on schedule Change the time to 5minutes
Occurs Every: 5 minutes
* OK
* OK
* OK
Observations
-----------------1.
Go to primary server --> SQL Server agent --> Jobs --> View the backup job with the
name
LSBackup_Sales
1.
If no monitor server is used, check 2 alerts are created in Alerts folder.
Log shipping Primary Server Alert
Log shipping Secondary Server Alert
1.
In Secondary server verify that 2 jobs are created
* Copy
(LSCopy_Sales)
* Restore
(LSRestore_Sales)
1.
All the above (Backup, Copy, Restore) jobs uses "sqllogship.exe" file.
2.
Alert job calls the following SP
sys.sp_check_log_shipping_monitor_alert
1.
sqlmaint.exe is responsible for updating backup, copy and restore information in the
monitor
server/p/s servers.
1.
Linked Servers are created in primary and secondary server related to monitor as
LOGSHIPLINK_<MonitorServerName>
1.
The following SPs are used to configure Log Shipping
1. master.dbo.sp_add_log_shipping_secondary_primary
2. master.dbo.sp_add_log_shipping_secondary_database
Configuring Alerts
------------------------* Once we configure Log shipping 2 alerts are created automatically.
* We have to configure response for the alerts.
Steps
-------* Go to Primary server --> SQL Server Agent --> Alerts --> Right Click on Log shipping
Primary server alert --> Properties --> Response -->Notify Operators --> Select existing
operator and select Email
* Go to secondary server configure "Log shipping secondary alert"
Monitoring Log Shipping
---------------------------------1.
Using MSDB tables and Views
* Go to primary server --> MSDB
1. Log_shipping_primary_databases
* Consists of information related to
* Log Backup folder path
* Last Log backup file name
2. Log_shipping_primary_secondaries
* Consists of details of secondary server name and database name
* Go to Secondary Server --> MSDB
1. log_shipping_secondary
* Details of copy folder and last copied file
2. log_shipping_secondary_databases
* Details of last restore file
Creating Linked Server in Server1 (primary) for Monitoring
-------------------------------------------------------------------------------1.
Go to secondary server Server2 and create a login which can access msdb tables.
use master
go
create login link_login with password='hyd'
go
use msdb
go
create user link_login for login link_login
go
grant select to link_login
Out of sync
------------------* It is raised when the T-Log backups are not applied at secondary server with the error
number 14421
* If there is no disk space in the secondary server for restoring backups.
* If there is no respective path to create the files in secondary server.
* If there is ad-hoc T-Log backup was taken in the primary server.
9:00
T-Log 1000
9:10
T-Log 1050 (Ad-hoc)
9:15
T-Log 1100
Solution
-----------* Restore first ad-hoc log backup which was taken at 9:10 manually in secondary server
with no-recovery.
* Restore next log backup which was generated by Log shipping process i.e. at 9:15
* If the Agent service or MSDB is not working in secondary server.
* If any T-Log backups are missing/corrupted before restoring.
* Disable Log shipping jobs.
* Take differential/Full backup and apply in secondary server.
* Enable jobs
2. Copy and Restore jobs are not running
-------------------------------------------------------* Check secondary server date and time. i.e secondary server date and time is less than
primary server.
* Change the date of start for the above jobs equal to secondary server date.
FAQ: - If the secondary server is down or Agent service in secondary server is not running or
msdb is not online copy and restore jobs fail. Once the Agent service is started how the
backup files are copied.
Ans:
* All the backup files are copied from last copied file at once by the copy job.
FAQ: - In secondary server restore job was failing and there is error message
"it is too early to apply the logs". What may be the possible reasons?
Ans:
* Try to restore if there is any previous backup file.
Performing fail over
----------------------------* Process of making secondary database available to the appls or users is called fail over when
primary server/db failed.
* Log Shipping Fail over process is not automatic.
Steps
-------1.
2.
3.
4.
5.
6.
7.
PRINT @tmpstr
PRINT ''
PRINT 'DECLARE @pwd sysname'
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
PRINT ''
SET @tmpstr = '-- Login: ' + @name
PRINT @tmpstr
IF (@xstatus & 4) = 4
BEGIN -- NT authenticated account/group
IF (@xstatus & 1) = 1
BEGIN -- NT login is denied access
SET @tmpstr = 'EXEC master..sp_denylogin ''' + @name + ''''
PRINT @tmpstr
END
ELSE
BEGIN -- NT login has access
SET @tmpstr = 'EXEC master..sp_grantlogin ''' + @name + ''''
PRINT @tmpstr
END
END
ELSE
BEGIN -- SQL Server authentication
IF (@binpwd IS NOT NULL)
BEGIN -- Non-null password
EXEC sp_hexadecimal @binpwd, @txtpwd OUT
IF (@xstatus & 2048) = 2048
SET @tmpstr = 'SET @pwd = CONVERT (varchar(256), ' + @txtpwd + ')'
ELSE
SET @tmpstr = 'SET @pwd = CONVERT (varbinary(256), ' + @txtpwd + ')'
PRINT @tmpstr
EXEC sp_hexadecimal @SID_varbinary,@SID_string OUT
SET @tmpstr = 'EXEC master..sp_addlogin ''' + @name
+ ''', @pwd, @sid = ' + @SID_string + ', @encryptopt = '
END
ELSE
BEGIN
-- Null password
EXEC sp_hexadecimal @SID_varbinary,@SID_string OUT
SET @tmpstr = 'EXEC master..sp_addlogin ''' + @name
+ ''', NULL, @sid = ' + @SID_string + ', @encryptopt = '
END
/* sp_help_revlogin script
** Generated May 25 2009 9:11PM on ONLINE */
-- Login: BUILTIN\Administrators
CREATE LOGIN [BUILTIN\Administrators] FROM WINDOWS WITH DEFAULT_DATABASE =
[master]
-- Login: NT AUTHORITY\SYSTEM
CREATE LOGIN [NT AUTHORITY\SYSTEM] FROM WINDOWS WITH DEFAULT_DATABASE =
[master]
Run the above output (for required logins) in Stand by server instance.
--You can download from
--http://support.microsoft.com/kb/918992/
......................................................
=======================================
Log shipping is one of four SQL Server 2005 high-availability solutions.
Other SQL Server 2005 high-availability alternatives include
* Database Mirroring
* Failover Clustering
* Peer-to-Peer Replication.
Note: - Database mirroring and Peer-to-Peer Replication are new technologies introduced with
SQL Server 2005
Log shipping offers increased database availability and database protection by maintaining a
warm standby database on another instance of SQL Server 2005.
Unlike database mirroring, a Log Shipping failover is not done automatically but its manual
failover.
Factors affecting Log Shipping
=================================
The size of the transaction log backups, speed of the network, and length of time the
restoration takes all play a significant role in planning and scheduling the log shipping solution.
Log Shipping Design Considerations
===================================
*
SQL Server Version: SQL Server 2005 Standard, Workgroup and Enterprise Editions can
be used for log shipping. All servers must be configured with the same case-sensitivity
settings.
Recovery Mode: The recovery mode of the source database on the primary server
must be
configured as full or bulk-logged. Because the transaction log is a key part of
log shipping, the simple recovery model cannot be used.
Monitor Server: The monitor server is optional. This server is important because it
provides a central location for the log shipping status and alert messages.
Security: Sysadmin role is required on each SQL Server that will take part in the Log
Shipping. The agent account used to run the backup job on the primary server must be
able to read and write to the backup location.
Backup & Restore T Log Location: The backup storage location is used to store the
transaction log backups created by the backup job. It is highly recommended to host the
transaction log backups on a fault-tolerant server independent of the log shipping
primary or secondary servers having enough disk space. Similarly on backup server,
enough drives should be available.
Description
--------------Stores alert job ID.
log_shipping_monitor_error_detail
log_shipping_monitor_history_detail
log_shipping_monitor_primary
primary
Log shipping
configuration,
information about the last backup
file
that is useful for monitoring.
log_shipping_monitor_secondary
database,
last backup file and last
file that is useful for monitoring.
Reasons of Log shipping Failure
==============================
* Network Failure
* No Disk space on Secondary Server
* Read/Write permission removed from Log folder
* Password Expired of SS Agent Service
* Copy / Restore job is not running
Prerequisite to configure LS
------------------------------------* 2 Servers ( Primary & Secondary)
* Recovery model should be FULL
* SQL 2005 Enterprise/Standard edition
* Same collation on both Servers
* Agent should be in Automatic Mode
* One shared folder on primary server to keep log backups
-------------------------------------------------------------------
A transaction undo(.TUF) file is required if a database is loaded in read-only state. In this state,
further transaction log backups may be applied.
or the old directory is itself lost then there is no other way than reconfiguring your LS setup
from scratch.
172014
more secondary databases on separate secondary server instances. The transaction log backups
are applied to each of the secondary databases individually.
Prerequisite
The primary database must use the full or bulk-logged recovery model.
Restriction:
Here we will give you demo How to Setup the Log Shipping
Very Step is to make sure your database is in full or bulk-logged recovery model.
Login to primary server then navigate to database Properties. Then select the Transaction Log
Shipping Page. Check the Enable this as primary database in a log shipping configuration check
box as shown in given snapshot :
In the next step, we will configure the Backup Setting as shown in given snapshot. Here will
mention network path. Also we can mention local folder path if backup folder path is located on
the primary server. Once we are completed with this step, backup jobs will be created on primary
server.
Now in the next step we will add the secondary server instance\databases, we can add more
than one if we want to log ship to multiple servers
When we click on the Add Button, new screen will open and here we will configure the
secondary server details. In the Initialize secondary database tab, there are three options. We
have selected the first option as shown in the snapshot, which take the fresh backup of database
from primary database and restore it on the secondary database.
In the Copy File Tab, We will mention Destination Shared Folder where the Log Shipping Copy
job will copy the Transactional-Log backup files. Once we are completed with this step, copy jobs
will be created on Secondary server.
In the Restore Transaction Log tab, we will mention database restore state and restore
schedule. Once we are completed with this step, restore jobs will be created on secondary
server.
No Recovery Mode: Database will be in restore state and cannot read until its online.
Standby Mode: Database will be in read-only mode.
In the next step, we will configure the log shipping monitoring; Monitoring can be done from the
primary server or secondary server or any other SQL Server instance. We can configure alerts
on primary / secondary server if respective jobs fail.
When we click on the Setting button, new screen will open. Here we will mention the
monitoring server details as shown in given snapshot. Once we are completed with this step,
alert jobs will be created on primary server.
Now click OK button to finish the Log Shipping configuration and it will show the following
screen :
Click Close
Now you check on your secondary server, database will look as shown below :