Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 9

G]Pf5SA$_}h.

lcd

CuH3Iy9<;F@zc2f

Windows operation system level Data protection API(DPAPI) protects the SMK

DMK protected b the master Key, which created by in SQL level


Asymentric keys- A Private and corresponding public key pair, each key can decrypt
data encrypted by the other,
Symemetric keys- One key that is used for both encryption and decryption.
TDE: it entrire Database using symmentric key- for best performance. it uses
Extensible Key mangement(EKM) in outside of SQL

encrypted data is at the column level

TDE uses,
Service master key(SMK)
Database master Key(DMK)
servie certitificate
Database encryption key

Archeitecture

Windows DPAPI
|SQL server setup
SQL server instance level- service master key
|create master key
Master Database leve-Database master key
|- create certificate
User database level- DB encryption key
Create Database encryption key

To view
Sys.databases
sys.certificates
sys.dm_database_encryption_key

--create master key


use master
create master kye encryptin by password='pwd'
go
--create certificate
create certificate mycert with su ject='my ek certt';

--certicate encrypte
use database

TWO types Always


Randomized encryption
Determistic encryption- more secure

ADV180002 spectre/meltdown
gQd[ul<naX9+'n'

.3l:nWl(4yz|0Ju
gQd[ul<naX9+'n'
Trigger Limitation
negative affect on performance
can be disabled by powers users
no support of select statemnts

80*4

what are availablity for DR


How you will failover in DR mirroring

select * from sys.dm_audit_actions -- List of available aduit actions


select * from sys.dm_server_audit_status -- List of definded server aduts/status
select * from sys.server_audits -- basic server audit list
select * from sys.database_audit_specifications
select * from sys.database_audit_specifications_details

Full
Complete Recovery
poin-in-time
Any time log backup
file restore
Page restore
piecemeal restore
\
Bulk-logged
some data-loss exposure
if bulk logged changes can't log backup
sometimes file restore can't
page restore can't
piecemeal restore can't

simple
-data lost upto full and diff
-Point-in-time not possible
-seconday read files only in file restore
-page restore NO
-secondary ready only files in peciemal restore

Restiration phases

*Data copy
Creates and copies data and log files
* Redo
Applies committed logged transactions
*Undo
Rolls back any uncommitted transactions

Full recovery Model


-- provides a more durable recovery
--up to tht last recoverable transaction log file
Norecovery-- Prevents additional changes

File Restore recovery


--thi

Page restores
--faster
--only in Full and bulk-logged

can't page restores


-Transaction logs
- allocation pages
-file book page(page 0)
-database file boot page(page 0 to 9)
-full-text catalog

error 823 or 824 if common errors for pages issues


error 829 while restoring a page, if a query tries to access the page

-suspect pages will restore in msdb database


use msdb
go
select * from suspect_pages

Piecemeal restores
- Allows a database containing many filegroups to be recovered in stages
- works in all recovery models
- reduce time for read-write filegroups

Each recovery starts with an initial restore sequence, called "partial restore
sequence"

In Simple recovery model


--start with Full or partial db backup
-- containing partial full backup of primary file group and Filegroups that
read/write
- backup of read-only files

In Full Recovery model


- -containing multiple filegroups and it can be restore point in time
-- sequence
-- At least primary filegroup
-- specify partial statemnet
-- specify point-in-time if applicapable

Filegroup-restore
- any offline seconday file group can be recovered(only Enterprise edition)
- if ready-only file is consistent with the database, if desn't have restored

Backups
- Recovery
-compliance
-Legal requirements

Azure Backups issues


- SQLexeception 3284 occured, sevirity 16, state 5- specify blocksize-65536 when
reissueing the backup statement
-error 412 with active leases- delete blob files

CheckDB
-dumpfile(SQLDUMPnnn.txt is created in SQL log directory detects corruption error

CheckSum- to check the pages examination to verify the data


suspect_pages from msdb
Activity monitor
select * from sys.dm_os_waiting_tasks

Data collector
-different sources to collect the data and store in warehouse
-- Dynamic management objects(DMO's)
-- Performance counters
-- SQL Trace events

Collect , store, report


SQL Utility control Points

Query Store
-introduced in 2016
- Automatically captures data & performace over time
-simplifies performance troubleshooting
- disbabled by default, requires enable if requires
- lies Queies, Plans, Runtime statistics
To Enable this,
Right click on DB--> select Query store page in DB properties, select ON in
operation mode
T-SQL-- Alter database DB with set query_store=ON

Two stores for saving data


- Plan store- Save execution plan info
-Runtime Stats store - Aggregate execution stats info over fixed time window

scenarios for usage


Performance Auditing and Troublestooting
-- Helps in identify & correct workload performances issues
* Maintaing Query Performance stablity
-- Aids you in detecting poor or inconsistent query performance

*Retrieve last specified no.of queries executed


*Retrieve no.of times each query was executed
*Re no.of queries with longest avg execution time in last Hr
*Identify no.of queries with largest avg physical IO reads in 24hrs
* identify q.s multiple plans
* Identify queries that recently showed poort execution perfomance.

Extended Events
* supports in SQL, Operation syste, Database applications, outside 3rd party

the index in place was useful in reducing the number of records that had to be read

DB MAIL:
callls SP sp_send_dbmail, the mesage for delivery to a service know as the service
broker queue, once SP executes, deliver it through SMTP
database mail-userR ole
--Supports in
Integrated configuration
logging
auditing
HTML
Public profiles can be view any users
private profiles strictly controlled

by calling dbo.sysmail_configure_sp stored procedure


logged messages dbo.sysmail_event_log
dbo.sysmail_allitems
dbo.sysmail_sentitems
dbo.sysmail_mailattachments view

Operators:
dbo.sp_add_sysoperator
Three contact methods can be configure
1. E-mail- email address(SMTP) where notifications can be sent
2.Pager E-mail- Email add(SMTP) where notifications in schdule times
3. Net send address- windows messanger sevices, where it just pop-up a message on
screen of the computer specified

*Fail-safe operators
--SQL agent can't access the tables that contain settings for operators and
notifications

Policy based management


* to make the polices

Poor indexing
Inaccurate statistics
Poor Query design
Poor execution plans, Usually caused by bad parametar sniffing
excessive blocking and deadlocks
Non-set-based operations, usaually t-sql
poor database design
execessive fragmentations
nonresuable

Table scan- scanning the entire the table- non exist index- it makes CPU, memory
Index scan- scanning the entire the index-
241813

Performance of SQL server depends on


* System resources(hardware)
*Network architecture
*Operation system
* Database applications
*Client applications

Causes of Bottelnecks
* Incorrectly configured resources
*malfunctioning resources
*workload not evenly distributed b/w resources of the same type
* insufficient resources, requiring additional or upgrade components

Five Areas to monitor when tracking the server performance to identify bottlenecks
* Memory Usage-Insufficient memory allocation to SQL degardes pefromance, Data must
be read from the disk rather than directly from data cache.
* CPU utilization- High CPU utilaztion rate may indicate that Trasacte SQL queries
need to be tuned or that a CPU upgrade is needed
*Disk Input.Output(I/O)- T SQL can be tuned to reduce unnecessary I/O,
*User connections- too many users may be accessing the server causing performacne
degradation
* Blocking locks- incorrectly designed application can cause locks and hamper
concurrency, thus causing longer response times, and lower transaction throughput
rates
Possible problems
* Application development errors
* Hardware errors
* Excessive blocking due to an incorrectly desinged database

Understanding the what going on current and previous executions

Indexes

Clustered Index
* Order Data rows
* Cluestered index key
* B-Tree Structure
* Rapid row retrieval

Non-Clustered
* Data rows not necessarily
* Non-clustered key value
* Row locator
* Heap

Hash and unique index types


Hash
* in-memory hash table
* fixed memory
* Bucket count

Unique
* Prevents value duplication
*unique rows and cloumns

Cloumnstore index
* cloumn-based data storage and query processing
* High query performance and data compression

Index with included cloumns


*Non-clustered
* Includes key and non-key cloumns

Index on computed cloumns


* Dependence on other columns

some other indexes


Spatial- Geo graphic data
XML-just content
Full-text-

common issues with SQL indexes


* Fragmentation idexes
* Missing indexes
*Underutilized Indexes
*Existing column store indexes

Buffer cache/Pool- This is an imporatant role of SQLserver architecture,


and it's responsinle for the ability to query frequently accessed data extremely
fast.
sys.dm_os_buffer_descriptors
sys.dm_os_info
Cloumnstore index
insert Order-> RowstoreClustered Index-> Table Partitioning
Create Cloumnstore indexes in parallel
* Index Creation is by default parrlel
* Plan for enough memory
Requires more memory than serial creaion

*TO improrve coloumnstore index performance?


Rowgroup elimination
Data compression
Parllel creation of coloumnstore indexes

*Data Compressed by column


* compressed data read from disk
* 10x Data compression than rowstore
10x more data in memory
Reduces IO for queries
Higher probablity of finding daa in memory

defragmentation for Columnstore index


Select * from sys.dm_db_coulmn_store_row_grow_physical_stats

sys.indexes to get stats of the indexes


Outdated data stats
* Performance issues
* Inefficiency query plans

Update statistics DB.Table with fullscan

LogShipping
Tuff file create each database one
manual failover

AG
1 primary, 8 secondary
Supports, Automatic,planned manual failover, Force failover
Key Support Functions
* AG Listner
* Flexible failover policy
* Automatic Page repair
* Encryption And Compression

Foreced Faiover
* Disaster recovery
* risk ofData loss
* Target replica role is in secondary or resolvingstate
* Secondary database are suspended

WSFC Cluster nodes work together


* Distributed metadata and notifications
* Resource management
* Heath monitoring
* Failover coordination

Quorum mode
* Heartbeat communication
* Periodic Quoram votes
* Configured at the WSFC Cluster level
* odd number of votes

Surviving cluster nodes activate


*Non-fault tolerant configuration

Distributed Availablity
* two AG groups configuren Distributed.
TWO Windows clusters and two AG groups

Difference
*Efficient for geographic distribution
* Data sent one time to secondary WSFC and replicated
* Automatic failover not supported

Single
* Not efficient for georaphic distribution
* Data sent to each replic individually
* automatic failover supported

Create Availablity group AGName


with (Distributed) availablity group on
'AG1'
with
(listener url='tcp://listener1:5022',
availablity_mode=ayscnronoud_comit,
failover_mode=Manual,
seeding_mode=Automatic),
'AG2' with
(listener url='tcp://listener2:5022',
availablity_mode=ayscnronoud_comit,
failover_mode=Manual,
seeding_mode=Automatic)
go

Couster shared volumes(CSV):


Win 2012, Fully supporting 2016
CSV feature not supported pervious versions
Storage can be managed fromany node as no specific node owns the disk

VNet,
Virtual Machines(VM)
Subnet,
NIC( Network Interface Card)
DNS
Inbound, OutBound
Resource Group
Network Group
Virtual Networks
SSL Certificate
SSD Disks
SDT Disks
Health Probes
https://www.youtube.com/watch?v=csXmYM8r8bo

You might also like