81
SQL Server 2012 39 th Autoexec Event 27/4/2012, Athens

Sql server 2012 autoexec event no 39

Embed Size (px)

Citation preview

Page 1: Sql server 2012 autoexec event no 39

SQL Server 2012 39th Autoexec Event 27/4/2012, Athens

Page 2: Sql server 2012 autoexec event no 39

sp_who

Solution Architect - Principal Consultant - SQL Server Evangelist

1982 >The first contact with computers.

1988 > I started my professional carrier in IT,

especially in software development.

1998 > I earned my 1st Certification as MCSD

(3rd in Greece). Since then I certified as

MCP, MCSD, MCT, MCDBA,

MCAD, MCTS, MCITP, MCPD, MCSA, OCA.

1999 > I started my Trainer carrier as MCT. Since

then I have more than 14.000 hours of

training

2010 > I became for first time Microsoft MVP

on SQL Server.

Leader of IAMCT Europe Greek Chapter

Moderator of autoexec.gr

Member of the dotNETZone.gr

Page 3: Sql server 2012 autoexec event no 39

Connect with me

@antoniosch [email protected]

“ blog”

sqlschoolgr .wordpress.com http://sqlschool.gr

Page 4: Sql server 2012 autoexec event no 39

History Lesson

Page 5: Sql server 2012 autoexec event no 39

Installation & Configuration

Page 6: Sql server 2012 autoexec event no 39

Editions

Principal Editions Enterprise Edition

Standard Edition

Business Intelligence Edition

Specialized Editions Web Edition

Breadth Edition Developer Edition

Express Edition

Page 7: Sql server 2012 autoexec event no 39

Core-Based Licensing

1 CPU ( 2 Cores) -> Minimum (4 cores/CPU)

1 CPU (4 Cores) -> 4 cores/CPU

1 CPU (6 Cores) -> 6 cores/CPU

1 CPU (8 Cores) -> 8 cores/CPU

2 CPU (2 Cores) -> Minimum (4 cores/CPU) X 2 = 8 cores

2 CPU (4 Cores) -> (4 cores/CPU) X 2 = 8 cores

2 CPU (6 Cores) -> (6 cores/CPU) X 2 = 12 cores

2 CPU (8 Cores) -> (8 cores/CPU) X 2 = 16 cores

Page 8: Sql server 2012 autoexec event no 39

Installation Requirements

Hardware

1 GB RAM

2.0 GHz CPU

2,5 GB on HD

Software IE 7

Windows PowerShell 2.0

.NET Framework 4.0

.NET Framework 3.5 SP1 on Vista & Server 2008

Page 9: Sql server 2012 autoexec event no 39

New Installation Features

Product Update

Server Core Installation

Data Quality Services

Distributed Relay

Multi-subnet clustering

System Databases can be installed on file share on an Server Message Block (SMB) file server.

Page 10: Sql server 2012 autoexec event no 39

New “Product Update” dialog

Page 11: Sql server 2012 autoexec event no 39

New inputs

New common line parameters UpdateSource: Where to search for updates • MU: Microsoft update

• \\UNCPath (network share) or local folder

UpdateEnabled • True/False: turns feature on or off

For example:

Setup.exe /Action=Install /UpdateSource=U:\DenaliCTP3b

Page 12: Sql server 2012 autoexec event no 39

Upgrade Path

All Editions from SQL Server 2005 can be upgraded direct to SQL Server 2012 except SQL Server 2000.

Use Upgrade Advisor utility.

Use Distributed Replay utility.

Page 13: Sql server 2012 autoexec event no 39

Post Upgrade Tasks

Re-register servers

Re-populate full text catalogs

Run DBCC UPDATEUDAGE on all databases to correct any incorrect row or page counts.

Validate on remove USE PLAN hints that are generated by SQL Server 2005 and applied to queries on partitioned tables and indexes

Update Statistics on all databases.

Special consideration for Replicated databases (BOL)

Page 14: Sql server 2012 autoexec event no 39

SQL Service Startup Parameters

Page 15: Sql server 2012 autoexec event no 39

Availability

Page 16: Sql server 2012 autoexec event no 39

What’s New

AlwaysOn SQL Server Failover Cluster Instances Multi-subnet failover clusters

Flexible failover policy for clusters health detection

Indirect checkpoints

AlwaysOn Availability Groups

Online Operations Extended support for online index builds (LOB, XML data types)

Reduced downtime for application upgrade (less than a second an exclusive lock held)

Page 17: Sql server 2012 autoexec event no 39

AlwaysOn Solution

Shared Storage

Instance Level HA

Protection

Non-Shared Storage

Database Level HA

Protection

Active Secondaries

Availability Groups Failover Cluster Instances

Page 18: Sql server 2012 autoexec event no 39

Failover Clustering over Stretched V-LAN SQL Server 2008 R2 and below

V-LAN

SAN Replication

IP: 10.10.10.10

subnet

1

subnet

2

Network Name: SqlClus

Local Site Remote Site

Page 19: Sql server 2012 autoexec event no 39

Multi-subnet Clustering

subnet

2 subnet

1

SAN Replication

IP1: 10.168.0.10 IP2: 192.168.0.10

Corpnet

OR

Network Name: SqlClus

Local Site Remote Site

Page 20: Sql server 2012 autoexec event no 39

Configure New IP Address when AddNode

Page 21: Sql server 2012 autoexec event no 39

Multi-Subnet Cluster Properties

Page 22: Sql server 2012 autoexec event no 39

Multi-Subnet Clustering Requirements

SQL SKU: Enterprise Edition

OS version: Windows Server 2008 R2 +

SAN replication for cross-site DR (e.g. EMC SRDF)

Single AD domain for all nodes

Page 23: Sql server 2012 autoexec event no 39

Indirect Checkpoints

Previously checkpoints on ?????? intervals

Variance in failover time

Variance in IO load

New in SQL Server 2012 Background checkpointing over time

Smoother IO load

More predicable failover times

Configurable per database

Off-by-default for backcompat

Page 24: Sql server 2012 autoexec event no 39

Current Algorithm: Dirty Pages

Buffer Pool

1, 100

10, 111

20, 108

30, 112

40, 110

40

10

0

30

10

1

40

10

2

30

10

3

20

10

4

30

10

5

40

10

6

40

10

7

20

10

8

10

10

9

40

11

0

10

11

1

30

11

2

Log Order

1. Checkpoint starts

2. FlushCache() visits all pages and writes each dirty

page: P10, P20, P30, P40 in that order

3. FlushCache() order has nothing to do with log order

4. MinRecLSN must be == begin checkpoint LSN

Algorithm

Page 25: Sql server 2012 autoexec event no 39

Indirect Checkpoint: Dirty Pages

Buffer Pool

1, 100

10, 111

20, 108

30, 112

40, 110

40

10

0

30

10

1

40

10

2

30

10

3

20

10

4

30

10

5

40

10

6

40

10

7

20

10

8

10

10

9

40

11

0

10

11

1

30

11

2

Log Order

1. New structure links dirtied buffers in the order they are first

dirtied.

2. Checkpoint can write buffers in that order:

• Writing page 40 covers log up to < LSN 101. Writing

page 30 next covers up to < LSN 104. Writing page

20 next covers log up to < 109.

3. MinRecLSN can advance independently of checkpoint

Algorithm

40, 100 30, 101 20, 104 10, 109

Dirtied buffers

with “first

dirtied LSN”

Page 26: Sql server 2012 autoexec event no 39

Flexible Failover Policy - Configuration

HealthCheckTimeout Default: 60 sec Min: 15 sec Frequency of responses

FailureConditionLevel Default Level: 3 “Failover or restart on critical SQL Server errors” User configurable Diagnostics always captured

Page 27: Sql server 2012 autoexec event no 39

Flexible Failover Policy - FailureConditionLevels

0 – No Automatic Failover or restart

Service is

down

1 – Failover or restart on server

down

No response from

sp_server_diagnostics

2 – Failover or restart on server

unresponsive

System errors 3 – Failover or restart on critical SQL

Server errors

Resource errors 4 – Failover or restart on moderate

SQL Server errors

Query Processing errors 5 – Failover/restart on any qualified

failure conditions

Page 28: Sql server 2012 autoexec event no 39

AlwaysOn A deep dive into Availability Groups

Page 29: Sql server 2012 autoexec event no 39

Mission Critical High Availability Solution

Meets mission

critical high

availability SLA Integrated Efficient Flexible

Page 30: Sql server 2012 autoexec event no 39

AlwaysOn Availability Groups A new feature that enhances and combines database mirroring and log shipping capabilities

• Multi-database failover

• Multiple secondaries

• Total of 4 secondaries

• 2 synchronous secondaries

• 1 automatic failover pair

• Synchronous and

asynchronous

• data movement

• Built in compression and

encryption

• Automatic and manual

failover

• Flexible failover policy

• Automatic Page Repair

• Application failover

using virtual name

• Configuration Wizard

• Dashboard

• System Center

Integration

• Rich diagnostic

infrastructure

• File-stream

replication

• Replication publisher

failover

Flexible Integrated Efficient

• Active Secondary

• Readable

Secondary

• Backup from

Secondary

• Automation using

power-shell

Page 31: Sql server 2012 autoexec event no 39

Starting Topology

Log Shipping

Database Mirroring

Page 32: Sql server 2012 autoexec event no 39

New Topology Phase 1

A

A

A

Page 33: Sql server 2012 autoexec event no 39

New Topology Phase 2

A

A

A

A

Reports

Backups

Synchronous

Data Movement

Asynchcronous

Data

Movement

Page 34: Sql server 2012 autoexec event no 39

Additional Topology Examples AlwaysOn provides the flexibility of different HA configurations

Synchronous

Data Movement

Asynchcronous

Data

Movement

Shared Storage, regional and geo secondaries

A

A

A

A

A

Direct attached storage local, regional and geo secondaries

A A

Page 35: Sql server 2012 autoexec event no 39

New Topology Benefits • Better SLAs • Multiple no data loss secondaries

• Better data loss protection for DR secondaries through continuous replication

• Faster failover to DR secondaries through virtual name failover

• Easier deployment/management • Unified solution

• Simple deployment

• Unified dashboard

• Rich diagnostics

• Centralized management of client connection topology

• Multi-DB failover

Page 36: Sql server 2012 autoexec event no 39

Windows Server Pre-Reqs • KB 976097

• Supports SQL Server Failover Cluster Instances with AlwaysOn Availability Groups

• KB 2494036 • Supports configuring optimal quorum with non-automatic failover targets

• All nodes should be in the same AD domain

• To create WFSC cluster user running creation must have: • Domain account

• Administrator on all machines

• Have Create Computer objects and Read All Properties rights in AD

• Detailed Article: http://technet.microsoft.com/en-us/library/cc731002(WS.10).aspx

Page 37: Sql server 2012 autoexec event no 39

Quorum Configuration • Quorum: need majority of votes to operate and avoid split brain

• Two-Steps process: 1. Select nodes to vote (KB 2494036)

• 1 vote if node’s that host a replica that is currently:

• Primary (if primary is an FCI include all possible owner nodes for that FCI)

• An auto failover target if the primary is also configured for auto failover

• 0 votes for rest of nodes

2. Select the quorum type:

• Odd number of votes, use “Node Majority”

• Even number of votes, add a witness by either:

• Adding an additional witness node and use “Node Majority”

• Using “Node and File Share Majority” with a protected file share (blog with details)

• Re-evaluate and adjust quorum after manual failover outside automatic target

Page 38: Sql server 2012 autoexec event no 39

Active Secondary Offloading Backup

Page 39: Sql server 2012 autoexec event no 39

Database Mirroring Backups

SQL 2008 Database Mirroring

R/W workload

Primary Secondary

Failed

Backups Backups

Page 40: Sql server 2012 autoexec event no 39

Enabling Backup On Secondary R/W workload

Primary

Backups

Secondary

Backups

Secondary

Backups

Page 41: Sql server 2012 autoexec event no 39

Restrictions, cautions, and gotchas

Differential backups are not supported on secondary

Only Copy-only full backups are supported on secondary The only distinction is the differential bitmap clearing

Advisable for backups to be stored centrally

Page 42: Sql server 2012 autoexec event no 39

Distributed Replay

Page 43: Sql server 2012 autoexec event no 39

What is Distributed Replay?

Multi-client scalability to drive higher throughput

Higher workload replay fidelity

Useful for stress testing production workload or performing application compatibility testing before upgrades

Page 44: Sql server 2012 autoexec event no 39

Why an enhanced replay tool?

Use multiple low-cost clients (workstations) to handle large workload traces within reasonable time

Address limitations of current SQL Trace based tools (Profiler, Upgrade Assistant)

Provide enhanced features

Lay groundwork for future workload replay capabilities

Page 45: Sql server 2012 autoexec event no 39

Distributed Replay Data & Workflow

… Controller

Multiple Replay Clients

SQL Server

Preprocess

Replay

Batch Request

Batch Request

Batch Request

Batch Request

User

1

2

Page 46: Sql server 2012 autoexec event no 39

Distributed Replay Concepts

Connect Time = delta time between trace start and login

Think Time = delta time between two events on the same connection

2

4

Login

3

5

1

Connection 51 Connection 52

Login

Logout

Logout

Connect

Time

Connect

Time

Trace Start

Think

Time

Think

Time

Page 47: Sql server 2012 autoexec event no 39

Preprocess & Replay Steps • What Happens During Preprocess:

• Sort the events in ascending order of EventSequence

• Trim away events and columns not used for replay

• Generate an intermediate file

• Goal: preprocess the trace once, and intermediate file can be replayed with different options

• What Happens During Replay:

• User specified the replay options, including which clients to use

• Shred the intermediate file into chunks in a load-balanced fashion

• Dispatch the file chunks to the clients

• Two replay modes, stress and synchronization

• Under stress mode, each client sends request independently

• Under sync mode, client needs to coordinate with controller to know when a specific event can be released (this is optimized so it is not done for every single event)

Page 48: Sql server 2012 autoexec event no 39

Preprocess Options • IncSystemSession: Whether system session events are filtered out

• MaxIdleTime: cap max idle time between events

Page 49: Sql server 2012 autoexec event no 39

Replay Options for Sequence Control

Synchronization

Mode

Stress Mode

StressScaleGranularity =

SPID

StressScaleGranularity =

Connection

Submit order Event submit

ordering across

SPIDs

Event submit ordering within

SPIDS

Event submit ordering

within connections

Submit timing Submit time

synchronization

ConnectTimeScale (0%–100%)

ThinkTimeScale (0%–100%)

UseConnectionPooling (Yes | No)

When to use High-fidelity replay

mode, such as

functional runs

Use 100% connect time

scale and 100% think time

scale for performance runs.

Use SPID granularity and

reduce connect time scale

and think time scale for

moderate-stress runs.

Use Connection granularity

and reduce connect time

scale and think time scale

for high-stress runs.

Page 50: Sql server 2012 autoexec event no 39

Supported SQL Server versions

Input Trace File Version Target SQL Server

SQL Server 2005 SQL Server 2008 / 2008 R2 / 2012

SQL Server 2008 SQL Server 2008 / 2008 R2 / 2012

SQL Server 2008 R2 SQL Server 2008 R2 / 2012

SQL Server 2012 SQL Server 2012

Page 51: Sql server 2012 autoexec event no 39

Performance & Scalability

Page 52: Sql server 2012 autoexec event no 39

Security Enhancements

Page 53: Sql server 2012 autoexec event no 39

SQL Server 2008 Security Recap Customer challenges Security feature

Protect data-at-rest Transparent Data Encryption

Data/Key separation Extensible Key Managements

Use strong authentication Kerberos authentication enhancements

Monitor all activity SQL Server Audit

Detect non-compliant

configurations

Policy-Based Management

Change Data Capture

Industry Certification Common Criteria Certification (EAL4+)

PR

OTEC

T

DA

TA

EN

SU

RE

CO

MP

LIA

NC

E

CO

NTR

OL

AC

CESS

Page 54: Sql server 2012 autoexec event no 39

The SQL Server 2008 Security Story

Page 55: Sql server 2012 autoexec event no 39

Default Schema for Groups

• Can now assign default schema to a group

• Eases Administration

• Avoids implicit schema creation

• Reduces chances of wrong schema used in queries

Group1

Default schema =

schema1

Page 56: Sql server 2012 autoexec event no 39

User-Defined Server Roles • Server-level principal

• Administrator defined "server

group"

• Collection of principals

• Holds permissions

• Compared to fixed roles

• Securable class

• Permission set can change

• Increase flexibility, manageability and facilitate compliance

CONTROL

SERVER

ALTER ANY

LOGIN

DBARole

Page 57: Sql server 2012 autoexec event no 39

Database Authentication

Available in Contained Databases

Allow authentication without Logins

SQL Users with passwords

Windows authentication without Login

Easier deployment for some applications

Tightly scoped security boundary

Page 58: Sql server 2012 autoexec event no 39

Database Auth – SQL Users

User=Alice; Pwd; IC=NormalDB Login

User=Alice; Pwd; IC=CDB Contained

User

User=Alice; Pwd; IC=CDB Login

(Contained user Alice exists)

(Contained user Alice does not exist)

Page 59: Sql server 2012 autoexec event no 39

Database Auth – Windows Users

User=Domain\Alice; IC=NormalDB Login

User=Domain\Alice; IC=CDB Login

User=Domain\Alice; IC=CDB Contained

User

(Login Alice exists)

(Login Alice does not exist)

Page 60: Sql server 2012 autoexec event no 39

Crypto Changes

• CREATE CERTIFICATE FROM BYTES

• 4K certificates supported for import

• SMK/DMK default to AES256

• Key backups encrypted with AES256

• SHA2 (256 and 512) support

• Password hashes use SHA512

• RC4 deprecated

Page 61: Sql server 2012 autoexec event no 39

Audit Enhancements

Page 62: Sql server 2012 autoexec event no 39

Audit Supported on All SKUs

• Basic Audit on all SKUs • Server Audit Specs only

• DB Audit Specs for Enterprise and

Datacenter

• No longer need SQLTrace

• Enjoy advantages of Audit • Performance

• Multiple Audits and multiple targets

• Persist state

• Audit Resilience

SQL Server Express

Page 63: Sql server 2012 autoexec event no 39

Improved Resilience

• Before: • Write failures may silently lose Audit records

• Use ON_FAILURE = SHUTDOWN

• Now: • Automatically recover from most file or network errors

• Added “ON_FAILURE = FAIL_OPERATION”

• Added “MAX_FILES” option

Select…

Rollback

Page 64: Sql server 2012 autoexec event no 39

T-SQL Stack Information

Audit Log

hr.viewsalary hr.payroll

exec hr.viewsalary select salary from hr.payroll

Page 65: Sql server 2012 autoexec event no 39

User-Defined Audit Event

• sp_audit_write( )

exec sp_audit_write

1234,

1,

N‘Hello World’

@user_defined_event_id

@succeeded

@user_defined_info

Audit Log

Page 66: Sql server 2012 autoexec event no 39

Record Filtering CREATE SERVER AUDIT audit_name

TO { [ FILE (<file_options> [ , ...n ]) ] | APPLICATION_LOG |

SECURITY_LOG }

[ WITH ( <audit_options> [ , ...n ] ) ]

[ FILTER = <predicate_expression> ]

}

<predicate_expression> ::=

{

[ NOT ] <predicate_factor> | {( <predicate_expression> ) }

[ { AND | OR } [ NOT ] { <predicate_factor> | (

<predicate_expression> ) } ]

[ ,...n ]

}

• Tightly constrain info written to Audit log

● Audit record generated but not written

• Leverages Xevent filtering

Page 67: Sql server 2012 autoexec event no 39

Management Enchancments

Page 68: Sql server 2012 autoexec event no 39

Backup - Restore

Backup Timeline

Page Restore Window

Page 69: Sql server 2012 autoexec event no 39

Server Related DMVs

sys.dm_server_services

sys.dm_server_registry

sys.dm_server_memory_dumps

Page 70: Sql server 2012 autoexec event no 39

Other Enhacements

Page 71: Sql server 2012 autoexec event no 39

Scalability & Performance

Columnstore Indexes

Online Index operations

Partition Support Increased (15.000 instead of 1.000)

Filestream filegroups can contain multiple files

Page 72: Sql server 2012 autoexec event no 39

Programmability Filetables

Statistical Semantic Search

Full-Text Search – GREEK Support!!!!

New and Enhanced Spatial features

Metadata Discovery

Execute Statement

UTF-16 Support

Ad-hoc Query Paging Implementation

Sequence Objects

Throw statement

14 new functions

Page 73: Sql server 2012 autoexec event no 39

Ad-hoc Query Paging Implementation

• OFFSET • Ορίζει τον αριθμό των records που θα αγνοηθούν πριν

ξεκινήσει το query να επιστρέψει αποτέλεσμα.

• FETCH • Ορίζει τον αριθμό των records που θα επιστραφούν μετά

από τον ορισμό του OFFSET

SELECT DepartmentID, Name, GroupName

FROM HumanResources.Department

ORDER BY DepartmentID

OFFSET 5 ROWS

FETCH NEXT 10 ROWS ONLY;

Page 74: Sql server 2012 autoexec event no 39

Support for UTF-16

• Introducing _SC collations

• Common Unicode characters occupy 16-bits each (NCHAR / NVARCHAR)

• Rarer Unicode characters occupy 2 x 16-bits each • “Supplementary Characters”, “Surrogate Pairs”

• Ancient scripts; Music Notation; Math Symbols etc.

Page 75: Sql server 2012 autoexec event no 39

Sequences • New Database Object, similar to the IDENTITY property

• Separates number-generation from column and table

• ANSI standard compliant implementation

CREATE SEQUENCE MySchema.IdSequence

AS INT

START WITH 10000 INCREMENT BY 1;

GO

INSERT INTO Employees (EmployeeId, Name)

VALUES (NEXT VALUE FOR MySchema.IdSequence, 'Jane');

INSERT INTO Contractors (ContractorId, Name)

VALUES (NEXT VALUE FOR MySchema.IdSequence, 'John');

Page 76: Sql server 2012 autoexec event no 39

Metadata Discovery • Ο παλιός τρόπος που όμως θα καταργηθεί και δεν μου έδινε και πολλά

• sp_describe_first_result_set

• sp_describe_undeclared_parameters

• sys.dm_exec_describe_first_result

USE AdventureWorks2008R2;

GO

SET FMTONLY ON;

GO

SELECT * FROM HumanResources.Employee;

GO

SET FMTONLY OFF;

GO

Page 77: Sql server 2012 autoexec event no 39

SSDT

SQL Server Data Tools

Page 78: Sql server 2012 autoexec event no 39

Έχει και άλλα…

Αντέχουμε;;;;;;;;;;;;;;;;;;;;;;

Page 79: Sql server 2012 autoexec event no 39

Looking ahead

Page 80: Sql server 2012 autoexec event no 39

Σας ευχαριστώ

Page 81: Sql server 2012 autoexec event no 39

ROCKING WITH KNOWLEDGE IN SQL SERVER