Roles&Responsibilities for SQL DBA
Hai iam satish , i have total 3 years of experiance in sql dba and
currently working with infosys and we have different servers which
were deployed into staging,testing,developement,DR,pre production.
As a daily bases,i have logon to the system and i will check mails,and
tickets assign for my team we will work on those tickets.
we used to get alerts like
Backup job failurs
Disk space issues
Tempdb full issues
Logfile full alerts
Data file full alerts
As a DBA iam installing,monitoring,managing and trouble shooting sql
server related issues.
Iam installing sql server,and cluster installation and i have a good
experiance on highavailability concepts like
Logshipping
Mirroring and clustering
whenever someone comes to me regording performance
i will check blocks
i will check deadlocks
i will check fragmentation
i will check unused index
i will check missing index
i will check update statistics
i will check wait types
Some times high cpu and high memory causes low perfomance.
so
i will check High CPU
High memory
Long running queries
Even though performance is slow i will run DTA and profiler performer
and i have basic idea on execution plan.
i have good experiance on migration and upgradation and database
refresh and security and backups.
These are my roles and responsibilities till now i have handled.
SQL SERVER INSTALLATION:
Hardware And Software Requirements
Software requirements
.netframe work
windows insatller 4.0
powershell 2.0
Hardawrae requirements:
RAM 2gb recommeed 4gb
processor speed must be 2 Giga hz
preinsatllation steps:
we need to ask about componets what kind of componets they need we will install those
components
1) database engine componets
2)reporting service
3)anlysis service
4)integration service
we need to ask about authentication whether they need windows or mixed mode(sql+windows)
we will ask about collation setting we will install required one
we need to ask about insatnce(sql server ) name
we will provide strong SA(system admin access) password
we are using domain level service accouts
we can keep files in seperate drives
data file in one drive
logfiles one drive
backup file in one drive
tempdb files in one drive
By doing this we will achive the performace.
post insatllation steps:
we need to enable dead lock trace flag
we need to make hide insatnce as yes
we need to disable the browser service
we need to change port number other than 1433
we need to enable backupcompression
we need to enable remote admin connection
we need to maintain 20 error logs
========================================================================
Interview questions:
what is colletion setting?
it is the language preference.
what is default collation setting?
sql_latin1_general_cp1_CI_AS
why we need to do keep files in differnrt drives?
it will improve the performace
what is browser service?
it is used to connect the the nameinsatnce(sql server name) in the sql serverlevel.
how do you enable port number?
we can enable at network configation at TCP/Ip we can enable
where do you enable deadlock trace flag?
configartion manger we can enable at 'sql services' right click and 'startup parameters' .we can add
'-t1222' in 'specify a startup parameters'.
and after addded we need to restart the services.
why we need to chage port number ?
security context we are changing port number
where do you get setup files or insatalltion files?
we will get setup files in one test server we have access to the test server(repository)
what are the issue do you faced while insatllation?
1.permission issue:
i do not have proper accessing permistion on drive so we need to inform to windows team they will
provide the access on that drive.
2.Restart error:
we need resart the server
3.if we are not uninstallation properly we will get new installtion issue so we need to unistall properly
any sql unisatlltions request came
4. .net framework issue:
we need need to inform to windows team they can re-configure the .netframe work
Service packs
--->> what is the importance of service pack OR what is the use of sp(service
pack)???
Ans::The use of service pack is it can improve the
1.performance
2.security
3.it can rectify the bugs(errors)
---->> what is the latest sp's from 2005 to 2017???
Ans: 2017 -----> R.T.M(Release to manufacturing)
2016 -----> sp1------latest(sp1)
2014 ------> sp1,sp2--- latest(sp2)
2012------->sp1,sp2,sp3------ latest(sp3)
2008R2----->sp1,sp2,sp3----- latest(sp3)
2008 ----------> sp1,sp2,sp3,sp4------latest(sp4)
2005----------> sp1,sp2,sp3,sp4 ----- latest(sp4)
change order :
if we change anything in the production server(online bussiness servers) that is
called change order.
it is one type of the request in ticketing tool.
Every change order consists of the following steps.
1.implementation plan
2.verification plan
3.backout plan
---->Every change order has perticular starting time and ending time(windows
time).
The time based upon the windows time.
--->>what are the installation steps for service packs ??
(or)
what are the pre & post installation steps for sp??
Ans: pre-installation:-
1.we need to verify whether the system and user database
backups are happend or not.
2.we need to take build number by using
select @@vertion
3.we need to take file level information by using
select *from sys.sysaltfiles
4.we need to take system level configuration by using
sp_configure
5.we need the reboot or restart the server.
post installation steps:
1.we need to perform database health check (whether it is in online or
not) by using
select *from sys.databases
2.we need to perform sql server health check by using
select *from sys.dm_server_services
3.we need to check with application team about their application
connectivity.
4.we need to check build number by using
select @@vertion
issues for service packs:
Q)what are the challenges do you face while apply the service pack?
(or)
what are the issues do you have installation of service pack?
1.i have .msi and .msp files missing:
sol: we need to run VEBSCRIPT in the command prompt it will missing
files and their path we need copy those files and we need to
rename the files.
2.permissin issue:
Ans: we need to inform to windows team they can provide access.
3.space issue:
Ans:we need to inform to windows team they can provide space.
SYSTERM DATABASES
what are the system databases available in the sql server??
1.Master
2.Model
3.Msdb
4.Tempdb
5.Resouce Database
6.Report Server Databases
7.Distributor Database
MASTER:
Master database is a critical database it contains all logins
information,linked server information,end point information and
other system database,user files information.
MODEL:
Model database is Template for all user databases.
And all user databases inherit all the properties from model database.
The properties like
recovery model,autogrowth settings.
MSDB:
It can stores are backup information and restoration information and
logshipping related jobs information.
TEMPDB:
Tempdb is used for temporary operations.All index related operations
can be happening on tempdb.
Rebuild and Reorganize indexes are happening on tempdb.
For every restart the services newly recreates the Tempdb.
RESOURCE:
Resource is a hidden database whenever any service packs
upgradations are happening that can be updated in resource
database.
Note:
In 2005,Resource database can in 'Bin' folder and master database file
exist in 'data folder'
SYSTERM DATABASES CORRUPTIONS
what will you do if master databases are corrupted??
If master database is corrupted,we will not able to connect sql server.
First we can identify whether master database is really corrupted or
not.
In the 'Event viewer' application logs If master database corrupted.we
can restore with the available backup.
we need to enable '-m -t3608' trace flg.
it can allow into the sql server so we can restore with available
backup.
'-m' means used for single user mode.
'-t3608' ,only master database can access.
If you dont have a backup for master what will you do??
we need to rebuild the master database.
In command prompt ---->sql cmd---->setup.exe stat\wait
rebuilddb=master, SA='password',sql collation setting,sql server
service Account name.
suppose 'model' db corrupted we can restart the model database
same as master.
msdb also same as master database.
In no backups are available
we need to run initial script in the SQL CMD
sp_configure, 'Agentxp','0'
reconfigure
sp_configure,'Agentxp','1'
-->If tempdb corrupted we need to restart the sql server services.
--->If resourcedb is corrupted,we need to repaire the sql instance.
--->In the 'installation panel' we will find 'maintanance' tab,we can
see 'repair' option.
FILE MOVEMENTS
How can you do file movement in sql server??
alter database databasename modify file(name='logical
filname',filename='path');
In another way we can do by
'atach-deatach'.
RECOVERY MODEL
Recovery model can specify how much data we can recover whenever something
happens to the database.
How many types of recovery models in sql server?
(OR)
what are the recovery models in sql server?
There are 3 types of recovery models in sql server.they are
1.Full recovery model
2.bulk-logged recovery model
3.simple recovery model
Full Recovery Model:-
As per WAL(write ahead logging) concept every transaction can logged into the
logfile and bufferpool.
one logfile may resides in multiple VLF(virtual log file).
Log File Buffer Pool
Data File
---->>At regular intervals of time check point will raise and data flush from
bufferpool to datafile.
---->>Full recovery model is fully logged(committed data).
----->>point in time recovery (Full data) is possible .
----->>There is no data loss in Full recovery model.
Bulk-logged Recovery Model:
whenever any bulk operations are happening they can keep bulk recovery model.
---->>Bulk logged recovery model is minimally-logged.
----->>Except the bulk operations bulk logged recovery model behaves like fully
recovery model.
point intime recovery means FULL DATA
---->>Here point in time recovery is may or may not be possible.
Bulk operations:-Rebuild,Reorganization,BCP(bulk copy program)
Minimally logged: when compared to full recovery model bulk logged recovery
model cant generate more log records.
generate the less log records is called minimally logged.
All the log records resides in log files.
Simple Recovery Model:
---->>Every transaction logged into the logfile and at the same time buffer pool
at regular intervals of time check point will be raise it will be
truncate(delete) the data(recors).
Truncate---->>delete the records in the table at the same time table
structure no change.
----->>There is a data loss chances are in simple recovery model.
----->>By using simple recovery model we can saves the space in disk.
Backups
Backups can maintain the same copy of the database.
what are the backups in sql server??
1.full backup
2.differential backup
3.T-log backup or Transaction log backup
4.copy only backup
5.Tail log backup
6.split or stripp backup
7.mirror backup
8.partial backup
9.partial differential backup
10.file and file group backup
Full backup:
it can take the entire database backup.
i.e,tables,views,stored procedures and users.
command for full backup is
backup database database name to disk='path/.bak'
extension for full backup is .bak
Full backup is base for differential and transational backup.
Differential backup:
whatever the modifications after the full backup those all transactions come
under differential backup.
The command for differential backup is
backup database databasename to disk='path/.bak' with differential
Transactional or T-Log backup :
it will trigger the log file backup and it can gernerate the LSN(log sequence
number) .if miss the LSN ,point intime is missed.
The command for the T-Log backup is
backup log dbname to disk='path\.trn'
The extension for the T-log backup is .trn
Copy only backup:(copy full,copy T-log):
without effection the LSN ,we can take copy only full backup
The command for the copy only full backup is
backup database database name to disk='path\.bak' with copy_only
The command for the copy only T-Log backup is
backup database databasename to disk='path\.trn' with copy_only
Tail Log Backup:
if database corrupted we can apply the tail log backup to get the active
transactions in the logfile.
Tail log backup can fail if logfile gets corrupted
The command for the Tail log backup is
backup log dbname to disk='path.trn' with no_truncate
Split backup or stripp backup:
we can use split backup whenever any space constaints and using split backup we
can make backup is much as fast.
The command for the split backup is
backup database dbname to disk='path\.bak',disk='path\.bak'.
Mirror backup:
mirror backup means it can maintain the same copy of the database
For additional safety to backup files it is possible to create mirrored copies of
database backups. If one file gets corrupted we have another as safety measure.
backup database DBname TO DISK=N'F:\DBName_Mirr1.bak'
MIRROR TO disk=N'E:\DBName_Mirr2.bak' WITH FORMAT
Mirrored backupsets cannot reside with other NonMirroredbackupsets, hence
WITH FORMAT option is mandatory to mention.
Maximum 4 mirrored sets are possible.
File and File group backups:
By using file and file group backup we can take file level or file group bakups.
File and Filegroup backups are individual backups of Files/Filegroups in a
database.
F&FG backups are helpful to devise backup strategies for Very Large DBs.
Individual Files and Filegroups are backed up using this method, also tables can be
placed in FG and can be backed up individually.
Command:
backup database FGTest FILEGROUP='Primary' to disk=N'F:\FGTest.bak'
backup database FGTest FILE='FGTest' to disk=N'F:\FGTest1.bak'
Partial Backup:
Partial backups are useful whenever we want to exclude read-only filegroups. A
partial does not contain all the filegroups.
Command:
backup database DBName READ_WRITE_FILEGROUPS,TERITIARY,QUATERNARY
to disk=N'F:\DBName_PBKP.bak'
Partial Differential Backup:
Is a differential backup for Partial backup.
backup database DBName READ_WRITE_FILEGROUPS,READONLY1,READONLY2
to disk=N'F:\DBName_PBKP.bak' WITH DIFFERENTIAL
1) NOINIT/INIT:
NOINIT appends backupsets into the media set.
INIT overwrites existing backupsets into the media set.
2) NOFORMAT/FORMAT:
NOFORMAT will keep the existing media set.
FORMAT will create a new media set and overwrites all the contents in the file.
3) NOSKIP/SKIP:
NOSKIP instructs the BACKUP statement to check the expiration date of all backup
sets on the media before allowing them to be overwritten. This is the default
behavior.
SKIP ignores the backup set expiration.
4) BLOCKSIZE
Specifies the physical block size, in bytes. The supported sizes are 512, 1024,
2048, 4096, 8192, 16384, 32768, and 65536 (64 KB) bytes. The default is 65536
for tape devices and 512 otherwise.
BLOCKSIZE is selected automatically based on the device chosen.
STATS [ =percentage ]
Displays a message each time another percentage completes, and is used to
gauge progress. If percentage is omitted, SQL
Server displays a message after each 10 percent is completed.
Restoration
If something happens to the database users are not able to access the database
so we can restore the backup file and to access the database.this process is
called restoration.
what are the states (or) modes of the restoration???
The modes or states of the restoration are as followes
1.with_recovery mode
2.with no_recovery mode
3.standby mode
With_recovery mode:
In this mode databases are in online state and users can able to connect the
database.
With no_recovery mode:
In this mode databases are in restoring state and users cant able to connect the
database and we need to take further backups.
Standby mode:
It is read-only mode and we can just report the database.
we can fire(use) 'select' commands only.
ex:select *from tablename
what is the background process of backups???
The background process of backup is copying the data files into the backup file
by using check point operation and there are 2 phases
1.roll forward or redo
2.roll backward or undo
Roll forward: All the committed transactions comes under the roll forward or
redo.
Roll backward: All the uncommitted transactions comes under the roll backward
or undo.
How can we see the how much percentage of process completed and estimated
time for the backups&restorations??
By using the DMV(dynamic management view) we can able to see that.and
following command we can able to see the following to columns.
1.percent_time:
in this column we can see the how much
process completed in the form of percentage.
2.estimated_completion_time:
in this column we can see the how time left
for completion of process.
What is the Background process of restoration??
The background process of restoration is first files will be creating into drives
and after data will be copy and finally there will be 2 other phases also.
1.roll forward :all the commited transactions
2.roll backward:all the uncommitted transactions.
Restoring the full backup by using the following command
restore database databasename from disk='path'
How to convert the database from restoring mode to online mode??
restore database databasename with recovery
How to check the database size,logical name and physical path???
sp_helpdb databasename
How can u check where backupfiles are taking in system(default path)??
by using "backup media family" table we can able to see the backupfiles path in
our system.
select *from [dbo].[backup media family]
NOTE:sql server instance---->database---->msdb---->system table----
>dbo.backup media file
How can we check when was the last backup happend for the databases???
By using the following command
select *from 'dbo.backupset'
NOTE:sql server instance---->database---->msdb---->system table----
>dbo.backupset
With move:
I frequently restore production databases to various development servers. The
drive layouts between the servers are almost never the same. at that time by
using the "with move" clause only we can able to restore the databases properly
from one server to another servers.
restore database databasename from disk='path'
WITH MOVE 'logical name ' TO 'physical path'
MOVE 'logical name' TO 'physical path'
by using gui also we can perform withmove clause
copy the backup file from server1 to server2 and restoring that file into server2 at
that time we can modify the .mdf and .ldf files
How can we verify backup file is valid or not???
restore verifyonly from disk='path'
How can we findout how many files in the backupfiles??
restore filelistonly from disk='path'
How to findout LSN number by using restore command??
restore headeronly from disk='path'
Tell me have you faced any issues while performing backups and restores??
Backups issues:
1.whenever any space issue, backup got fail so we need to remove old backup
files or we will raise INCIDENT to windows team and they will provide the space.
2.permission issue:i need to permission so i can inform to windows team and
they willprovide to me accessing permission.
Restoration issues:
1.user is inuse:
we need to inform the application team about the using current session
according to their approvers we can kill the session or user and they can restore
2.space issue:
There is no sufficient space in the drive ,restoration got fail and they can inform
to the windows team.
3.permission issue:
we can inform to the windows team and they can provide the accessing
permission to us.
some times while performing the restore operations often raise one error like
"restore database terminated abonarmally".at that time we can performing the
following commands.
alter database databasename set single_user
go
restoring commands______________
go
alter database databasename set multi_user
what is LSN???
LSN stands for 'Log sequence number' and it is a incremental,unique value. By
using the LSN we can maintain the sequence of the transaction log records in the
sql server.
security
By using the security we can authenticate the LOGINS into the sql server.
what are the authentications in sql server??
There are 2 types of authentications are available in sql server.Those are
1.windows authentication
2.sql server authentication
windows authentication:
It can be created at windows level and it can be provide more security when
compared to sql server authentication.In windows authentication we wont
provide the user name and password.
sql server authentication:
It is less secure when compared to windows authentication because every time
we need to provide username and password.
When will you provide sql&windows authentication??
For regular users we can provide windows authentication.
For third party vendors(DB2 tool,oracle,my sql) we can provide sql authentication.
In sql server there are 3 types of security levels.Those are in the following way.
1.Server-level security
2.Database-level security
3.Table or schema or object level serity
what are the server-level security roles in sql server??
1.DB creator
2.Bulk admin
3.Disk admin
4.process admin
5.Security admin
6.Server admin
7.Setup admin
8.Public
9.Sys admin
DB creator:
Login whoever having the DB creator role,he can able to do create the database.
alter the database
drop the database
restore the database
Bulk admin:
Login whoever having the bulk admin login ,he can able to do bulk
operations.those are
insert into
select *from into BCP
Disk admin:
Login whoever having the Disk admin role,he can able to manage the disk level
files.
i.e,copying files from one drive to another.
Process admin:
Login whoever having the process admin role,he can able to see the process
information and kill the session.
Security admin:
Login whoever having the security admin role,he can able create the new
logins,and at the same time he can able to do reset or change the passwords.
Server admin:
Login whoever having the server admin role,he can able to change the server level
settings and he can able to restart or shutdown the sql server.
i.e,memory settings.
Setup admin:
Login whoever having the setup admin role,he can able to configure the linked
server and he can remove the linked server.
Public:
Login whoever having the public role,he can able to see the sql server.
Sys admin:
Login whoever having the Sys admin role,he can able to do anything in the sql
server.
Note:we can provide temporary sys admin access also if anybody wants and we
can revoke it after 15 days.
what are the DB level roles in sql server???
1.DB_reader
2.DB_writer
3.DB_Denyreader
4.DB_Denywriter
5.DB_owner
6.DB_Backup operator
7.DB_Acess admin
8.DB_Security admin
9.DB_public
10.DDL admin
DB_Reader:
user whoever having DB_reader acess,he can able to read the data for perticular
database.
DB_writer:
user whoever having DB_writer acess,he can able to write the data for
perticular database.
write operation-DML operations(insert,update,delete)
DB_Deny reader:
user whoever having deny reader,he cant able to read the data.
DB_Denywriter:
user whoever having DB_Deny writer access he cant able to write the data.
DB_owner:
user whoever having the DB_owner access ,he can able to do anything in the
database.
Backup operators:
user whoever having the Backup_operator ,he can able to take the backup of
perticular database.
DB_Acess admin:
user whoever having the 'Access admin' access,he can able to add or remove
access to the database.
DDL admin:
user whoever having the DDL access,he can access the DDL
operations(grant,revoke)
Security admin:
user whoever having the security admin access,he can able to create the new
user and remove the user for the perticular database.
Public:
user whoever having the DB_public access,he can able to see the database.
JOBS
JOB is the automatic process it can run according to the schedule
time.we can configure backup jobs
1.fully
2.differential
3.T-log
4.Rebuild
5.Reorganize
6.update statistic job
apart from this we can run some application related jobs.
sql agent can run the jobs.
job holders must be system admin or service accounts.
full and ola scripts is a scripts for backups.
Maintanace plans
If we create the maintanance plans automatically jobs will be created
under sql server agent.
what are the tasks performing in the maintanance plan??
1.Full backup
2.differential backup
3.T-log backup
4.Rebuild index
5.Reorganize index
6.update statistic
7.Maintanance cleanup task
8.Database integrity check or DBCC check DB
9.shrink database
10.cleanup history
11.execute sql server agent job
goto --->management---->maintanance plans--->maintance plan
wizard
DATABASE ARCHITECTURE
pages
Extends
Files
Filegroups
Database
A Database is a collection of information that is organized so it can be easily accessed managed
and updated .
pages and architecture :-
The page can stores the data and the size of the page is 8kb.
page header(96bytes)
Actual data (or)
Row data
RowOffSet
Page header contains actual data and rowoffset and size of the page header is 96 bytes.
Actual data(8096 bytes) is the actual information of the user.
Rowoffset can point to the actual data.
Types of pages:
1) Data page
2) Index page
3) Page free space
4) GAM(global allocation map)
5) SGAM(shared global allocation map)
6) IAM(index allocation map)
7) DCM(differential change map)
8) BCM(bulk change map)
9) Text page
Data page can stores the actual data
index page can stores the index related data
page free space can stores the free space information
GAM can stores the Extends related information
SGAM can stores the Extends related information
IAM can stores the index allocation information
DCM can stores the when was the last full backup happend verifiying
BCM :SQL engine can verify when was the last full backup happend
Text Page can stores the data types information like INT ,VARCHAR etc.
Extends:
Extends is a collection of pages and size of the extends is 64 kb.
There are 2 types of extends.they are
I. uniform extends
II. mixed extends
8 continuous same type of pages is called uniform extends
8 continuous different type of pages is called mixed extends.
Files:
A file is a collection of extends .The files are in the sql server in
the following way.
Log file
Data file or primary file or master file
secondary file
Log file:All the DML operation will be recorded in the log
files.and log file is used to recover the data whenever
something happens in the database.
Data file:data files are perminent storage .we can read any
data from the data files directly .we cant do any modification
into the data file.
Extension for datafile is .mdf
Secondary file: secondary files are perminent storage .we can
read any data from the data files directly .we cant do any
modification into the secondary file.
Extension for datafile is .ndf
File groups:
The file group is a collection of files.Tables can be stored in file
groups.
High availability & Disastor recovery
High availability:
The high availability is a technique and it can maintain the database
or application available for the users every time.
Disastor recovery:
The disastor recovery it can maintain the same copy of the data
maintain at different data servers.
Log shipping:
Log shipping is one of the database level high availability concept.
The Log shipping process is happenenig in the following way.
backup share(read/write) copy share(read)
Log backups
primary server secondary server
Backup job copy job
alert job
monitor server
log bakups are transfer from primary server to secondary server.
what are the pre-requisites for log shipping ??
1.To configure the logshipping we need to require minimum 2
servers.Those are
i. primary server
ii. secondary server
iii. monitor server
primary server: All the online transactions are happening in primary
server.
secondary server: it can maintain the same copy of the primary server
monitor server: it is optional server.it can monitoring both the
severs(primary&secondary server).
we should use same addition and same version of the servers
maintaining in the primary and secondary server.
we should use full and bulk-logged recovery models only.
we should provide same name for the severs like primary server and
secondary server.
In primary server we should use backup share only,and the backup
share requires read/write permission .
In secondary server we should use copy share only,and the copy share
requires only read permission.
we should use domain level service accounts.
According to their requirement,we can use standby-mode or
no_recovery mode.
How to configure the log shipping??
To initalize the log shipping for primary and secondary server by using
the backup and restore technique,and then we can configure the log
shipping .
After configure the logshipping servers ,4 backups are created .those
are
1.backup copy
2.copy job
3.restore job
4.alert job
The alert job is created in monitor server if it is available otherwise
alert job created in both primary server and secondary server.
what is TUF file ?
The tuf(TRANSACTION UNDO FILE) file contains the uncommitted transactions
.once commit the transaction it will go along with the next log backup.
The tuf file created into the secondary server while restoring mode is stand-by.
what will happen if TUF file is deleted??
whenever the tuf file is deleted the logshipping cant be work.and moreover
backup job,copy job ,and restore jobs are also getting fail.in this situation we
need to re-configure the logshipping.
what is work file??
The work file will be created in secondary server while the restoring mode is
standby .
initially it will be appearing as work file and finally it will be converted as
.trn(log file) files.
Logshipping scenarios
FAILOVER:
The 'failover' means the primary database is corrupted , we need to bring the
secondary server is in online.
1.First we need to apply the Tail-log backup to the primary server.
2.we need to disable all the jobs(backup job,copy job,restore job)
3.we need to compare the backup share and copy share if any backup files we
need copy to the copy share then do it.And run the copy job and restore job.
NOTE:
we can findout the when was the last log backups are happend in the log-
shipping by using on the msdb
select *from log_shipping_primary_databases
we can findout when was the last copy backup and restore backups are
happend by using on msdb
select *from log_monitor_secondary_databases
4.And we need to restore the tail log backup with recovery in secondary server.
5.They(application team) need to change their connection string secondary
server details.
6.we need inform to application team ,they need to re-configure the log
shipping.
Switch over (or) DR test (or) DR drill (or) Roll swapping:
we need to do primary server as secondary server and secondary
server as primary server.
1.we need to disable the backup job ,copy job and restore job.
2.we need to compare backup share ,copy share if any backup files
copy to copy share.
And run the copy backup and restore backup
3.we need to apply
Backup log database name to disk='path' with no_recovery
4.we need to restore
restore log database name from disk='path' with recovery
5.And we need to re-configure the Log-shipping.
ADD FILE:
How to add 'file' in log-shipping??
1.we need to disable all the jobs(backup,copy,restore)
2.we need to add the file into the primary server database.
3.we need to take the log backup of the database for the primary
server.
Backup log dbname to disk='path'
4.we need to restore log backups by using 'with move ' option in the second
server.
Restore log dbname from disk='path' with
move 'logical name','path'
move 'logical name','path'
what will happen into secondary server while insert,update,delete
operations in primary server?
if we do DML operations in primary server it will replicated to the secondary
server.
LOG SHIPPING ISSUES
space issue:
we dont have a sufficient space on a primary server or secondary
server we will remove the old backup files and to claim the space.
other option is we need to add file to the another device.
and third option is we need to inform to windows team ,and they can
add the extra space on drive.
Add file:
once we have faced 'restore job failure issue' because one of the team
member added file without disable the jobs.
so we have reslove the issue before add the file we should disable all
the jobs and we have taken log backups in primary server and
restored in secondary server by using 'with move' option.
Network issue:
we have faced network issue in primary server ,then backup job
getting fail so we need to inform to network team and they will
resolve the issue from their side.
Then we have started backup job in primary server and copy
job,restore job started in secondary server.
Access issue:
if we dont have sufficient accessing permissions on backup share and
copy share we will face backup,copy,restore jobs are getting fail.
TOO RECENTLY TO APPLY THE LOG BACKUP :
we have faced too recently to apply the log backup issue .
if we take manual log backup for the log_shipping configure database
we will face 'too recently to apply the log backup' error.
To resolve the issue we need to restore the 'manually taken log
backup'.
LOGIN ISSUE:
6.we should create same login for the database in secondary user by
using
select *from sys.syslogin
By using the above command we can get the sid of login7
7.we should maintain physical server and sql server name as same.
8.i have faced login issue in the secondary server whenever we are
using switchover primary to secondary ,in the secondary server user
not able to connect the application ,so i have trouble shooted the
issue .
i.e,sid(security identifier)mis match,so i have fixed the sid by
using
select *from sys.syslogin
Then he can able to connect the application.
MIRRORING
WHAT IS MIRRORING???
log records transfer from principle server to mirror server this process
is called mirroring.
LOG RECORDS LOG RECORDS
principle server mirroring server
witness
what are the pre-requisites for mirroring???
1.we need to minimum 2 servers
principle server
mirror server
witness server(optional server)
2.we should use fully recovery model.
3.we should use same name for both server.
4.we should use same version and same addition of the both servers.
5.we should use domain level service accounts.
6.According to their requirement,we should use synchronous or
asynchronous.
Synchronous:
first transaction gets commited in mirror server and next transaction
gets commited in principle server.
and finally we will get acknowledgement.
There is no dataloss here.
Asynchronous:
First transaction gets commited into principle server and next
transaction gets commited into mirror server.
and here we will not get any acknowledgement.
Here datalosses chances may chance.
if we want better performance we can prefer asynchronous mode.
7.we are using default port numbers or end point.
By default port numbers for
principle server -5022
mirror server----5023
witness server----5024
what is end point:
it can establish communication between principle and mirror server.
mirroring configuration:
we need to take full bckup in principle server and restore it in mirror
server with norecovery
we can start the mirror configuration.
issues for mirroring
ADD FILE:
I have faced add file issue one of my team member did added the file
manually without breaking the mirroring ,so he has faced issue.
mirroring is not in shrink.
so we have re-configured mirroring the proper steps.
LOGIN ISSUE:
we have faced login issue whenever they are doing DR DRILL they are
unable to connect the application once we have verified from our end
we can identify the issue,login was not created in mirror server,so we
have create the new login in mirror server with the same sid of
principle server.
END POINT:
we have faced an issue related to the end point we have DR Drill
activity we were issued the following.
alter db dbname set failover
by using the above command we can do the failove and then
principle server database went to restoring mode so at that time we
have verified in the error logs,issue related to service account so we
have identified the issue
"service account doesnt have a endpoint permission"
so we have to provided the connect perimission to endpoint.
NETWORK ISSUE:
we have faced network issue so mirroring was not in shrink once
resolve issue by network team,data is shrink in principle server and
mirror server.
How can you monitor mirroring????
we can monitor mirroring status through 'mirror monitoring ' we can
get from
database--->Tasks------>launch database mirroring monitor
and then we can find 'unsent log' and 'unrestored log'.
if we see mirror monitor in principle server is 0kb and mirror server is
0kb then mirror is properly working in this situation.
what is 'unsetlog'???
it means how much data need to move from principle server to the
mirror server.
what is 'unrestore log'???
it means how much data need to write the data into the disk of the
mirror server.
what is the mirror hardning??
write the data into the disk that is called mirror hardining.
senarious for mirroring
DR Test (or) Failover (or) DR Drill:
failover means roll swapping
i.e,principle server become mirror server and mirror server
become principle server.
By using below command we can do the failover
alter db dbname set partner failover
how to cange the synchronous mode to asynchronous mode
in mirroring????
alter db dbname set safty off
how to cange the synchronous mode to asynchronous mode
in mirroring????
alter db dbname set safty full
how to check end point????
select *from sys.sysendpoint
select *from sys.dm_db_mirroring(by using DMV)
DMV means less resource intensive(less cpu and less memory)
how to start /stop end point???
alter endpoint::mirroring state=stopped/start
how to grant the permissin to end point?
grant connect on endpoint::[end point name] to [service
account]
what is the state after configuration of mirroring for principle
server & mirror server??
for principle server----principle,synchronized
for mirror server-------mirror,synchronized/restoring
what is the state after doing the failover in mirroring for
principle server & mirror server??
for principle server----mirror,synchronized/restoring
for mirror server-------principle/synchronized
we should do failover in mirroring where is the principle
server we need to perform the failover in principle server.
ADD FILE:
Before adding the file(log file or secondary) we need to break
the mirroring and we can add the file into the principle server
database and we can take the log backup in principle server
and it can restore by using with move option in secondary
server
how to break the mirroring???
alter db dbname set partner off
how to add 'login' for mirroring configured database??
first we can adding login in principle server and we can take
the sid of same login for principle server and we can create
the same login in mirrored server with the same sid for
principle server
what will happen if we will do any dml operations in principle
server what will happen in mirror server???
if we do any dml operations in principle server it will
replicated the mirror server and it will not effection the mirror
configuration.
How we can shrink for mirror database??
If we shrink in a principple server it will automatically shrink
in the mirror server
shrink ---- to release the unused space
how do you apply service pack in mirroring??
first we can apply in the following sequence.
witness server----->mirror server----->principle server
Differnence between log shipping and mirroring
Log shipping Mirroring
In this log backups are transfer In this log records can transfer
from one server to another server from one server to another server
In this jobs are available In this no jobs are available
In this we should use either full In this we should use only full
recovery or bulk -logged recovery recovery model
In this we should use according to In this we should use according to
their requirement ,either with theire requirement either
norecovery or standny mode synchronous or asynchronous
There is no automatic failover There is automatic failover
This process is bases on jobs This is based on end points
Here create multiple secondary Here no option to create multiple
servers mirror servers.
ALWAYSON
Alwayson is the advanced feature of mirroring and it is introduced
from sql server-2012 onwards
In alwayson we can failover single database or multiple
databases.
To configure alwayson we need windows failover clustering.
prerequisites to configure alwayson:
To configure the alwayson we need failove cluster.
we need to enable alwayson feature and all the
replica(node).
we should use full recovery model.
we need to configure 'Listener'
we need to take database full backup
we need to create alwayson availability group.
we should use primary and secondary replica.
What is Listener:
Listener is used to connect the client applications.
Where do you monitor alwayson:
we can monitor alwayson at 'alwayson dashboard'
How to check the windows cluster install or not??
in the command prompt we can type the following command.
clueadmin.msc
CLUSTERING
The clustering is a windows feature and it is build by 3 teams.They
are in the following way.
1.windows team
2.network team
3.SAN team
clustering is a INSTANCE LEVEL HIGH AVAILABILITY CONCEPT .Multiple
nodes are working together as per same purpose to maintain the
high availability.
To build the clustering we should use domain controller(DC).
we can add the multiple nodes into the domain controller.
what is 'active-active' setup??
In active-active setup both the nodes having sql server setups.and sql
server services are running in the both nodes.
sql sql
services servies
NODE1(active) NODE2(active)
what is 'active-passive' setup??
In active-passive setup active node having sql server setup and sql
server services are running in the node1(active) node and
node2(passive) is waiting for the failover.
sql
failover
services
NODE1(active) NODE2(passive)
what is QUORUM??
Quorum is a seperate drive ,where it can store the active nodes
information.it is a windows feature.
There are differnt types of quorums.Those are
1.node majority quorum
2.node&disk majority quorum
3.node&file share majority qyorum
4.diskonly majority quorum
Node majority quorum:
it is used for odd number of nodes i.e,more than half of the nodes
must be up otherwise cluster wont be work .
Here node can act as a ''voat'.
Node&disk majority:
it is used for even number of the nodes i.e, more than half of the
nodes and disk must be in online otherwise cluster wont be work.
Here DISK is act as a 'voat'
Node &file share majority:
it is used for even number of the nodes i.e,half of the nodes and disk
must be in online otherwise cluster wont be work.
Here fileshare acting as one 'vote'.
Disk only majority:
in this cluster can work without node,if disk fail cluster wont be work.
what is 'isalive & look alive??
windows cluster service uses heatbeat process of clustering by using
isalive and look alive.
look alive:
look alive is a basic check for every 5 seconds it will veriffy all the sql
services(sql main ,agent,disk,network services) are running or not.
Is alive:
ls alive is a complete check for every 1 minute and it will verify all the
sql server services(sql main ,agent,disk,network services) are running
or not.
if sql server services are not running ,services will be bring online into
the another node.
pre-requisites for cluster-installation:
we need 'windows failover clustering' on all the nodes.
we need the quorum.
we need domain level service accounts.
we need public and private ip address.
we should use common storage(SAN) for clustering.
we need windows cluster name and windows cluster ip.
After completion of windows clustering for the nodes we
have to perform the sql server setup files installation.
we need sql server setup files for all the nodes.
we need sql server network name
we need sql server network ip
we must use identical(same) versions and edditions for all the
nodes.
what are the ip's using for clustering??
The following points are common ip's for every clustering.
2-public
2-private
1-windows ip
msdtc[optional]
EX1: active-passive:
in this above situation we need 1-sql server public ip.
EX2: 2active-2passive:
in this above situation we need 2-sql server public ip's.
public ip:
it is used to connect the servers.The servers are either physical
or virtual.
private ip:
it is used to internal communication between nodes.
what is the sql server network name??
client applications are connecting by using sql server network
name. IP is also same purpose.
what is windows cluster name??
it is used to identify number of nodes in the network.
windows ip is also same purpose.
what is failover??
failover is the process of move the sql server services from one
node(node1) to another node(node2).
sql server
services
MOVE SERVICES
(AFTER FAILOVER)
NODE1 NODE2
what is failback??
fail back is the process of move the sql server services from node2 to
node1.
what is the background process of failover??
whenever perfoming the failover in the active node(node1) following
actions will happen.
1.first network services goes to offline.
2.next sql server agent service goes to offline.
3.next sql server main service goes to offline.
4.finally disk service goes into offline.
And in the passive node(node2) following sequence services goes into
online.
1.first disk services goes to online.
2.next sql server main service goes to online.
3.next sql server agent service goes to online.
4.finally network service goes into online.
How do you failover??
goto the failover manager
Roles
sql server services
And then right click on 'services' and we can see 'move services' from
one node to another node.we can click where we want to move.
What is preffered owner or selected owner??
Preffered owner means perticular node where we want to move the
sevices.
What is possible owner??
Possible owner means while configuring the clustering ,we can
provide possible owner list.if one node down,it will go to the next
possible node.
How to install sql server clustering??
1.we can take setup files on 2 nodes.
2.we can run setup files on node1 and we can provide
network name
network ip
sql server resource group name
3.once done with node1 ,we can go to the node2,and copy the same
setup file and we can just click on 'add node' and everything will be
replicated to node2.
How to apply service pack for clustering??
first i can apply service pack on passive node,once done with passive
node and reboot the server .i can go to the active node,i can failover
services from active node to passive node and again apply service
pack and reboot the server and again back from passive to active and
reboot the server.
what is the difference between 2005 clustering and 2008 clustering???
in 2005 down time is there.
in 2008 down time is fraction of seconds only.
in 2005 we can apply service pack on active node.it will replicate to
passive node automatically.
DATABASE MIGRATION
we can move the required databases from lower version(2005) to
higher versions(2008.......2016) .This process is called migration.
we can doing side by side migration i.e, we are taking the
backup from lower version database and it can restore into higher
version.
pre-migration steps:
1.we need to take the backup which database we want to migrate.
2.we need to take the job script
3.we need to take the login script by using
sp_helprevlogin
4.we need to take the system level configuration
5.we need to take the file level information.
6.we need to verify the space in the target server.
post -migration steps:
1.we need to restore the required database which we want to
migrate.
2.we need to check the any orphan users.
whoever user having without login is called orphan user.
This will lists the orphaned users:
sp_change_users_login 'Report'
If you already have a login id and password for this user, fix it by doing:
sp_change_users_login 'Auto_Fix', 'user'
If you want to create a new login id and password for this user, fix it by doing:
sp_change_users_login 'Auto_Fix', 'user', 'login', 'password'
3.we need to create jobs by using the script which we have
previously taken.
4.we need to run rebuild and reorganize job.
5.we need to change the build number from lower version to higher version
how to change the build number:
database--->properties--->options--->compatability level option
we can change the build number from lower version to higher version
by using "compatability level" option.
DATABASE UPGRADATION
upgradation means we are moving all databases from lower versions to higher version(side by side)
(or)
Existing instance can be replaced with new one(inplace)
pre-upgradation steps:
all the points are same in migration except below point.
1.we need to download the upgrade advisor and it will analyze whether all applications will be suitable
for higher version and it will analyze
components like
database engine,integration service,reporting service,analysis service
post-upgradation steps:
all the points are same in migration.
DATABASE REFRESH
We are taking non production(test,dev,uit) server database backup
file to production server database by using
we can restore 'with replace' option in the production server.
process of database refresh:
1.we need to take backup into non production server
2.we need to take user script in production server
3.we need to take permission script in production server.
4.we need to take users in the production server by using script.
5.we can restore database from non production server into
production server 'with replace' option.
issues:
1.we used to get orphan user issue ,so we can find orphan users by
using
sp_change_users_login report
so we need to fix the orphan user by using
sp_change_users_login 'auto fix', 'user name'
2.user in use:
in this situation we need to inform the application team about
the using current session according to their approvers we can kill the
session or user and they can restore.
3.space issue:
we need to inform to windows team and they can provide the
space .
performance tunning in sql DBA
LOCKS:
LOCKS can provided the consistecy.it can be hold the table or
object.There are different types of locking mechanisms in sql server.
This can be managed by 'lock monitor'.
what are the different levels of locks???
There are different levels of locks in sql server.Those are
1.page level lock
2.row level lock
3.table level lock
4.database level lock
what are the different types of locks???
1.shared lock
2.update lock
3.exclusive lock(DML operations)
4.intent lock
shared lock:
shared lock is used for all the 'read operations' such as 'select'
command that do not change or update the data.
update lock:
whenever any updates on table ,update lock will be obtained.update
lock can prevent common form of deadlock.
Exclusive lock:
whenever any DML operations such as insert,update,delete on their
table we can see exclusive lock.it can ensure multiple updates cannot
to be made to the same resource at the same time.
How to check locks in the sql server??
sp_lock
(or)
select *from sys.dm_tran_lock
Intent lock:
Intent lock to protect shared lock (or) exclusive lock on a table.
intent locks can be aquired before a lock at lower level.
Example:
1.shared intent lock is requested at table before shared locks are
requested or page or row within the table.
Intent locks are improve the performance
2.Exclusive intent lock is requested at table before exclusive locks are
requested at page or row within the table.
how to find what kind of script run by the locked user??
By using below command we can findout the script for the perticular
user according to the session id.
DBCC inputbuffer(sessionid)
DBCC inputbuffer(55)
BLOCKING (OR) BLOCKS:
one user is having an lock on one resource(table) and another user is
trying to put a lock on same resource this situation is called as
blocking or blocks.
user1 user2
shared lock Blocking
resource or
table
How to find Blocks???
By using SP_WHO2 command we can findout the blocks in the
'blocked by' column.so we need to inform to application team
according to the approvers from application team we can kill the
session(user).
SP_WHO2
SELECT *FROM SYS.SYSPROCESSES
If we find multiple blockings how can you resolve this issue??
we need to find it in 'root blocker'.
root blocker is identifies no of times repeateldly blocks
DEADLOCKS:
one user is having a lock on one resource, and another user is having a
lock on another resource ,first user trying to put a lock on second
resource and second user trying to put a lock on first resource .this
situation is called dead lock .
user1 user2
shared lock Dead lock exclusive lock
Resource1 Resource2
By default dead lock information cant be trace into the ERROR LOG.
so we have to enable 'server side trace flag':-t1222
so we can find the dead lock information into error log .we cant do
anything for deadlock,sql engine can kill one of the session acording
to the priority.
what are other ways to identify the dead locks???
By using EXTENDED EVENTS(introducing 2008 onwards) or profiler.
what is '-t1222'???
1222 is the trace flag to find the dead lock information into the xml
format and it can specify resource information and dead lock victim.
How to identify the deadlock in sql server??
In sql server there are different ways to findout the deadlock .Those
are
1.By using extended events:
goto management--->>Extended events---->>system health---
>>package.event files
2.session wise:
DBCC trace on 1222
3.server manager
4.By using error log
By using customized script we can identify root blocker
what is the customized script or query for the root blocker?
The script contain lot of joins and inner joins .iam not a part of
developement ,so i can remember few DMV's .Those are
sys.dm_tran_locks
sys.dm_execute_sql_text
sys.dm_db_connections
How to create the deadlock situation in sql server??
By using the following link ,it can detailed described about force the
deadlock.
https://ajitananthram.wordpress.com/2014/02/23/scripts-to-force-a-
deadlock-in-sql-server/
INDEXES:
An index is a disk structure associated with table or view that speads
retrival of the data in the form of 'B-TREE' structure.
There are mainly 2 types of indexes in sql server.
1.cluster index
2.non cluster index
cluster index:
cluster index sort and store the data rows in the table based on the
key value.actual data can be stored in leaf-level.
we can create only one cluster index for the table.
why only one-cluster index for table???
There is only one cluster index for table because the data rows(actual
data) themselves can be sorted in only one order.
How to create the index on table???
create clusterindex indexname on table[column1,column2...]
Non-cluster index:
in the non cluster index ,leaf level pointers will be there and pointers
will located to actual data that may be again heap or cluster index
what is heap???
A table without index is called heap.
How to create non cluster index???
create nonclusterindex indexname on table[column1,column2...]
What is the default value for 'fill factor' ???
The default value for fill factor is zero.
FRAGMENTATION:
whenever any DML operations like insert,update,delete we can see
fragmentation.
whenever we have more page splits,we will get
fragmentation.
There are mainly 2 types of fragmentations.They are
1.internal fragmentation
2.External fragmentation
Internal fragmentation:
The logical order of the page is not match with physical order of the
page is called internal fragmentation.
External fragmentation:
The logical order of extend is not match with physical order of the
extend is called external fragmentation.
How to identify fragmentation??
we have a DMV
sys.dm_db_physical_index_stats
we will find 'avg_fragmentation' column.
If values are
0---5 ------>> indexes are good,in this case no need to do anything.
<30 ------->> we need to reorganize index.
>30 -------->> we need to rebuild the index.
what is rebuild and reorganize???
An existing index can be removed and new index can be created is
called REBUILD.
alter index index_name on table rebuild[fill factor='70]
Internally data will be Rearanged and it will remve the fragmentation
is called REORGANIZE.
alter index indexname on table reorganize[fill factor='70']
what is fill factor???
Fill factor means how much data can be stored in index page is called
fill factor for suppose if we give 70 valure for fill factor,index pages
occupies 70% and 30% is reserved.
MISSING INDEXES:
we can find missing index by using
sys.dm_db_missing_index_details
we need to inform to application team about the missing indexes so
they can create the missing indexes.
why indexes are missing???
indexes may be miss because of DML operations query excusion plan
will be change and 'query optimizer' identify as missing index.
If we find any missing indexes what you will do???
If we find any missing index,we need to inform to application team.if
they really require missing index they can create those indexes
otherwise it will impact the performance.
UNUSED INDEXES:
we can find unused index by using
sys.dm_db_index_usage_stats
we can findout unused index,
if 'user seek' and 'user-scan' are '0' ,so indexes are using.
if 'user seek' and 'user-scan' are other than '0' ,so indexes are unused.
If we find any unused indexes what you will do???
If we find any unused index,we need to inform to application team.if
they want to delete index then they can delete those indexes
otherwise it will impact the performance.
UPDATE STATISTICS:
whenever any dml operations on the table 'stats' are not upto date,so
we need to update the stats by using
DBCC updatestats -----> all tables in the database
How to update stats for perticular table???
update statistics table name with full scan
How to find when was the last stats updated??
By using DBCC command
DBCC show statistics(table name,index name)
we can find it in 'updated column'
By 'sys.indexes' command we can find update statistics.
WAIT TYPES OR WAIT STATS:
wait type means one process is waiting for another process.
How to find wait types???
sys.dm_os_wait_stats
There are differrent types of wait types we can commanly see.Those
are
1. Async_network_io:
This can be occurs on network when the task is blocked behind the
network.
2. Async_io_completion:
This can be occurs when the task is waiting for IO to finish.
3. Backup:
This can be occurs when task is block is part of backup process.
4.CX packet
when any parallel operations we can see CX packet wait types.
This is related to cpu.
4.Latch_Ex:
This can be occurs when waiting for exclusive latch.
Latch is related to internaal memory structure.
5.LCK_M_S:
This is related to lock wait type.this wait type is we can see when
aquiring lock on table.
6.Resource_cemaphore:
we can resource cemaphore wait type,query is waiting for memory at
the time we can see resource_cemphore.
HIGH CPU:
Whenever any cpu issue first we need to go to 'TASK MANAGER' and
we can verify for 'SQL.EXE'.
If sql is consuming more cpu we can trouble shooting according.
1.If sql is consuming more cpu,we need to check for blockings.
SP_WHO2
2.we need to check for long running queried.
if any long running queries we can inform to application
team.
NOTE: DBCC opentran
3.whenever any application jobs are running CPU goes to high.once
completing the job CPU goes to normal stage.
4.wheneve any rebuild ,and reorganize jobs are running cpu goes to
high once done it will comes to normal stage.
HIGH MEMORY:
Whenever any memory issue first we need to go to 'TASK MANAGER'
and we can verify for 'SQL.EXE'.
If sql is consuming more memory we can trouble shooting according.
1.If sql is consuming more memory,we need to check for blockings.
SP_WHO2
2.we need to check for long running queried.
if any long running queries we can inform to application
team.
NOTE: DBCC opentran
3.whenever any application jobs are running memory goes to
high.once completing the job memory goes to normal stage.
4.wheneve any rebuild ,and reorganize jobs are running memory goes
to high once done it will comes to normal stage.
DTA(DATABASE ENGINE TOOLING ADVISOR):
DTA is the one of the inbuild tool .it is identify the missing index and
stats.it will recommended us missing indexes if any indexes are miss,it
will recommend to create those indexes.
PROFILER:
PROFILER is also one of the inbuild tool,it is used to identify the
problem in the sql server.it is used to analyze the issue.
profiler has different types of events,Those are related to
1.LOCKS
2.AUDIT(LOGIN AND LOGOUT)
3.SP COMPLILATION
4.SP RECOMPILATION
5.DEADLOCK GRAPHS
PERFORMANCE MONITOR TOOL OR PERFMON:
This is also inbuild tool it is used to identify the issue related to sql
and os level . i.e,memory,cpu,network
perfmon have different types of counters .those are
1.processor time:
Preffered value s 70,
if value is >70 there is a cpu pressure on the server,so we need to
investigate the issue
investigation---->>>(There may/maynot have sufficient index,missing
index,unused index)
so we need to trouble shoot the issue.
1.privilized time:
If value greater than 70 ,there is a cpu pressure on the server, so we
need to investigate the issue.
so we need to trouble shoot the issue.
commands in sql dba
1) To find the version or build number for instance sql server
select @@version
2) To check the server level configuration
sp_configure
3) How can you trace the errors in sql server
sp_readerrorlog
4) To check the database health check(online or not)
select *from sys.databases
5) To check the file level information
select *from sys.sysaltfiles
6) To check the sql server health check
select *from sys.dm_server_services
7) How we can take the full backup by using below command
Backup database databasename to disk='path.bak'
8) How we can take the differential backup by using below cmd
Backup database dbname to disk='path.bak' with
differential
9) How we can take the T-Log backup by using below cmd
Backup log databasename to disk='path.trn'
10) How we can take the copyonly backup by using below cmd
Backup database databasename to disk='path.bak' with
copy_only
11) How we can take the Tail-Log backup by using below cmd
Backup log dbname to disk='path.bak' with no_truncate
12) How we can take the split backup by using below cmd
Backup database dbname to disk='path' disk='path'
13) How we can check the size&logical name,physical path of
database by using below cmd
sp_helpdb databasename
14) How we can check the where backupfiles are taking in
server(defalult path of backupfiles)
select *from [dbo].[backup media family]
15) How we can check when was the last backup happend
select *from [dbo].[backupset]
16) How we can see the how much process completed
&estimated time for the process either backup or restore
select *from sys.dm_exec_request
17) How we can take the database from restoring mode to
online mode by using below command
restore database databasename with recovery
18) How we can restore the database with full backup
restore database dbname to disk='path'
19) How we can findout when was the last backup happend for
the log backup by using on msdb
select *from log_shipping_primary_databases
20) How we can findout when was the last backup happend for
the copy and restore job by using on msdb
select *from log_shipping_monitor_secondary
21) How to identify how many files in the backupfile
restore filelistonly from disk='path'
22) How we can verify backup file is valid(corrupted) or not
restore verifyonly from disk='path'
23) How we can findout LSN number by using below cmd
restore headeronly from disk='path'
24) How we can set the single user & multi user for the db
alter database dbname set single-user
alter database dbname set multi-user
25) How we can set the database from offline and online state
alter database database name set online
alter database databasename set offline
26) How to get the sid(security identifier) for login by using
command
select *from sys.syslogins
27) How we can do the failover for mirroring by using cmd
alter db dbname set partner failover
28) How to change shynchronous mode to ashynchronous
mode in mirrorin
alter db dbname set safty off
29) How to change ashynchronous mode to shynchronous
mode in mirroring.
alter db dbname set safty full
30) How to check end points by using command.
select *from sys.sysendpoint (or)
select *from sys.dm_db_mirroring(using DMV)
31) How to start the end point
alter endpoint::endpoint name state=start
32) How to stop the end point
alter endpoint::endpoint name state=stop
33) How to grant permission to end point
grant connect on endpoint::endpointname to service
account
34) How to break the mirroring
alter db dbname set partner off
35) How to take the sid for logins
select *from sys.syslogins
36) How to perform the failover in mirroring
alter db dbname set failover
37) How to take the login script
sp_helprevlogin
38) How to get list of orphan users
sp_change_users_login report
39) If you already have a login id and password for this
user, fix it by doing:
sp_change_users_login 'auto fix', 'username'
40) If you want to create a new login id and password for this user, fix it by
doing:
sp_change_users_login 'Auto_Fix', 'user', 'login',
'password'
41) How to check the locks in the sql server
select *from sys.dm_tran_lock
sp_lock
42) How to check the Blocks in the sql server
select *from sys.sysprocesses
sp_who2
43) How to create the clusterindex for table in the sql server
create clusterindex indexname on table [column1,column2...]
44) How to create the nonclusterindex for table in the sql server
create non-clusterindex indexname on table
[column1,column2...]
45) How to create the nonclusterindex for table in the sql server
create compositeindex indexname on table
[column1,column2...]
45) How to identify the fragmentation in the sql server
sys.dm_db_physical_index_stats
46) How to perform the rebuild in the sql server
alter index indexname on table rebuild
47) How to perform the reorganize in the sql server
alter index indexname on table reorganize[fill factor='70']
48) How to identify the missing index in the sql server
sys.dm_db_missing_index_details
49) How to identify the unused index in the sql server
sys.dm_db_index_usage_stats
50) How to update stats(all tables in database) in the sql server
DBCC updatestats
51) How to update stats(perticular table in database) in the sql
server
update statistics tablename with fullscan
52) How to find the wait types in the sql server
sys.dm_os_wait_stats
53) How to find the long running queries in the sql server
DBCC opentran
Realtime questions
1) Briefly explain about yourself???
Roles and responsabilities of sql dba
2)what are your daily activities ???
(or)
what are your day-to-day activities ???
coming to my daily activities
i start my day with checking mails and shift handover whether any
incidents from previous shift is handed to me for followup or any
action need to be taken.
we have 'CA service desk ' ticketing tool,where we get incident to our
queue.shift coordinator assign them to us on rotation bases and
sometimes we can proactively pick them and start working on them
by acknowledging in on our name.
Depending upon on our incidents we can assign and start
working on them.
3)what is SLA in your environment ???
SLA---->>service level agrement
TICKETS RESPONSE TIME RESOLUTION TIME
P1(critical) 15 minutes 1 hour
P2(High) 2 hours 4 hrs
P1(Medium) 8 hours 1 day
P1(Low) 1 day 2 days
If we get p1 ticket responce time is 15 minutes and resolve time is
1hour.
If we get p2 ticket responce time is 2hours and resolve time is 4hour.
If we get p3 ticket responce time is 8 hours and resolve time is 1day.
If we get p4 ticket responce time is 1 day and resolve time is 2days.
4)what are the 'p1' activities ???
The p1 activities are in the following way.
Disk space,Tempdb full
user unable to login
Blocking
Database healthchecking
To check over running queries
DBCC opentran
5)what are the 'p2' activities ???
The p2 activities are in the following way.
Blocking checking
Deadlocks checking
checking job(rebuild,reorganize,backup) failuers.
Log file full alerts
Tempdb full alerts
Backups
6)what are the 'p3' activities ???
The p3 activities are in the following way.
Database connection issue
Db creation
Db drop
Table creation
Login creation
7)what are the 'p4' activities ???
The p4 activities are in the following way.
script executions
Deployements(script execution)
password missuse
Login issue
Backup and restore either incident(to raise sponteneously) or change
order(based on schedule) based upon situation,These are raising in
either p1,p2 or p3.
8)what are the most common issues do you have faced ???
i have faced
Disk space issue
Tempdb full issue
user unable to login
Blocking
Database health checking
To check over running jobs
To check long running queries
Dbcc opentran
9)what is your Backup strategy ???
(or)
what is frequency of the Backups ???
we need to take every full backup.
we need to take T-logs every 15 minutes.
10)why do you take like this backupstrategy ???
This is my project strategy.
11)what is your retention period of backups ???
my backup retention period is 3 days by using 'maintanance plans'.
12)what will you do ,if you get two 'p1' ticket at a time ???
i need to work on ticket which is going to impact on bussines and
then i can acknowkedge another 'p1' ticket.
ex:in p1.for suppose two issues are there
1.cpu
2.services offline
In the situation first solve the services are online.
13)If your are only one person in the shift,you are unable to resolve
the issue,what will you do ???
If iam the person in the shift,i can assign ticket on my name,and i start
working on that ticket ,i iam unable to resolve immediately i can make
a call to my 'on-call' DBA. And i can inform him about the issue where
i have struck and i can explain him findings on issue and i can resolve
issue with help of 'on-call' DBA.
'on-call' means he is a senior DBA's work from home.
14)what is your highest DB size ???
my highest database size is '1.5 TB'
15)what is the highest size of backup file of the highest DB ???
If we have 2 TB DB,backup file is '500GB' by using '3rd party Backup
Tool'.
16)what is 3 party Backup Tools ???
most popular 3rd party tool is 'Quest Light speed' and it can
compress the backup file almost 75-80%.
17)what is the version of Light speed ???
The version of Light speed is '2.1.0'.
This is only one we have.
18)what is your team size ???
in my project environment we have 8 members team.My team
members in the following way.
How many L1---->1
L2----->3
L3------>2
Team lead------>1
19)which project you have worked on???
i have worked on hsbc project with wipro.
20)Explain your project???
My project is hsbc ,it has huge inventory there are above 500
servers among those 60% on PRODUCTION servers and remaining are
UAT and DEV and DR servers.
As its huge inventory,we have a tool called 'DBAI'(server
information) which stores all the details of the servers.It is a good
tool,where we can get all the details of the servers like
Host name
Listener
cluster and coming ot high availability
Log shipping
mirroring and clustering.
21)What are the tools you have known???
in my environment i have seen the
1.Quest Light speed
2.DBAI
22)Why do you want change the company???
My contract is about to complete,so iam looking for another position
where i can sharpen my skill set and help for betterment of company
with my knowledge.
23)It is a contract position.Is it ok for you???
I wont matter,if it is a contract position or perminent position.I
want to work in an environment which is challenging where i can face
new task and it will help me to improve my knowledge.
24)What is your monitoring tool???
in my previous environment we have used SCOM(service center
operational manager) monitoring tool.
25)How can monitor servers (or) How can you get alerts???
We have monitoring tool,it can configure can threshold value is
70, if value is exceeds the 70 we will get alert.
26)What is the difference between alert and incident???
Incident:---->>
we will get 'incident' into the 'service now' ticketing tool.
There are 2 types of incidents.
1.user-raised:
user can raise a incident or ticket into the ticketing tool.
2.system-raised:
we will get automatically alerts into ticketing tool by using
monitoring team.
These are also incident but system raised.
This can be configuring with the help of monitoring team into the
monitoring team.
27)What is chage order???
If we change anything into the production server those are all
comes under the chage order.
The change order has following 3 steps.
1.implementation plan:
in this implementation plan whatever the steps we need to
perform.
2.verification plan:
we need to verify action is performed or not.
3.Backout plan:
if anything happen we need to revert erlier one(as usual before
chageorder).
28)Are you willing to work on night shifts???
Yes,i willing to work on night shift.
29)what is recent issue do you faced in your environment???
(or)
what is the critical issue do you face in your environment???
I have faced
1.Database suspect issue:::-->>
so i have resolved the issue by performing few steps.
first i have run the command
sp_resetstats
And then i have put the database into single user mode by
using 'alter' command.
alter db dbname set single_user
and then i have set emergency mode
alter db dbname set emergency
And then run
DBCC checkDB
And i found 4 consistency allocation errors so we found
that data file got corrupted,so we have available
backup,we have restored the available backup.
30)If you dont habe a backup then how can you resove the issue???
We have one option but if we do this ,there will be some minimally
loss the data.If client accept for that i can run
DBCC checkdb(dbname,Repair_allow_dataloss)
and finally we will get dataloss with minimally loss.
31)what are the reasons to database is going to suspect mode???
'Suspect database' means database is in inaccessible and state of
the database is in suspect.
We can find this information by using
select *from sys..databases
If state of the column is in suspect then we can consider as database
suspect.
32)Why database going to suspect mode ???
There are lot of reasons database went to suspect mode.Those
are
There may be page corruption.
There may be datafile missing.
There may be Logfile missing
Due to space issues,database went to suspect.
There may be a sudden reboot servers,there db goes to
suspect mode.
There may be hardware issues.
If any 'suspect flag' enable,it will goes to suspect.
33)Why we need to run 'sp_resetstats' ???
By using this we can disable the 'suspect flag'
34)Why we need to keep the database in single-user mode ???
By using single-user mode,it will allow onlyone single user
connection to resolve the issue.
35)why we need to keep the database in emergency mode ???
it is read-only mode,users are not able to perform any
operation.if it is in emergency mode,it will allow troubleshoot the
issue and it will allow to
DBCC checkdb command
36)what 'DBCC checkdb' can do???
it can identify the page corruption of the database.
37)what are the consistency errors???
There is no link between pages we can see those errors.
38)what are commands in 'DBCC checkdb???
DBCC CheckAlloc
DBCC CheckTable
DBCC CheckCatLog
39)where DBCC operation can be happen???
In background DBCC operation happen in 'Temp Db'.
interview scheduling process
where are you currently working??
iam currently working in wipro.This is my client and my payroll is tcs
Are you contract??
yes.iam contractor for wipro and perminent for tcs.
Do you have pf account??
No.i dont have a pf account .iam a contractor
Do you have URN number??
i dont have a pf account so idont have a URN.
Is it negatioble your package??
yes.i can negatioble.
what is your notice period??
My notice period is 1 month.
Are you serving notice period??
No.iam not serving just iam looking for job change.
How many days will you able to join??
Actually i have 1 month notice period but i can able to manage for 20
to 25 days.
How is it possible??
i have some leaves i can claim them and i can discuss with my
manager.
What is your current level??
sql dba 'L2' position.
Why do you leave your previous company??
The main reason is my contract is going to end with wipro.
This is also contract base.is this okay??
yes.
Where is your payroll company located and where is your client
located??
Tell about your company locations.
How to schedule the interview??
Hai this is ramu one of my friend reffered me about job oppurtunity in
hexaware.iam looking for job change.can you please schedule me
interview.