443 chapter5.designing SQL Server endpoints

Source: Internet
Author: User
Tags failover

Designing SQL Server endpoints
Lesson 1: Overview of endpoint
Endpoints control the capability to connect to an instance of SQL Server as well as dictating the communications methods that are acceptable.
1. endpoint types of payloads
An endpoint has two basic parts: a transport and payload.
Transport Payload
TCP tsql
TCP Service Broker
TCP database processing ing
HTTP soap
By combing an endpoint transport and payload, SQL Server can filter acceptable traffic before a command event reached the SQL server instance. (first the validate the transport and payload, then authenticate)
2. endpoint access
(1) Even if traffic going to the endpoint matches the correct transport and payload, a connection is still not allowed unless access has been granted on the endpoint.
(2) The first layer of access security is determined by the endpoint State. An endpoint can have one of three states: started, stopped, and disabled.
Started: the endpoint is actively listening for connections and will replay to an application
Stopped: the endpoint is actively listening, but returns a connection error to an application
Disabled: the endpoint does not listen and does not respond to any connection attempted
(3) the second layer of security is permission to connect to the endpoint. an application muse have a login created in SQL Server hat has the connect permission granted on the endpoint before the connection is allowed through the endpoint.
(4) SQL Server 2005 ensures that only valid requests can be submitted by a valid user before a request is scheduled within the engine. administrators also have a master switch to immediately shut off access if they feel someone is attempting to compromise their SQL Server, by setting the state of the endpoint being used to Disabled
3. Practice: Inspecting existing endpoints
Select * From SYS. endpoints
Select * From SYS. tcp_endpoints
Select * From SYS. http_endpoints
Select * From SYS. database_mongoing_endpoints
Select * From SYS. service_broker_endpoints

Lesson 2: TCP endpoints
1. TCP protocol arguments
(1) TCP endpoints are configured to listen on specific IP addresses and port numbers. The two arguments that can be specified that are universal for all TCP endpoints are the following. lisener_port and lisener_ip.
(2) lisener_port argument is required. The TCP or tsql endpoint that is created for each instance during installation is already configured for port 1433 o the alternative port number for the instance.
(3) lisener_ip argument is an optional argument that can provide a powerful Security Layer for some types of applications. you can specify a specific IP address for the endpoint to listen on. the default setting is all.
2. database processing ing and service broker common arguments
(1) Database Authentication and service broker endpoints provide options to specify the authentication method and the encryption setting. You can use either Microsoft Windows-based authentication or certificates.
(2) Windows-based authentication: NTLM, Kerberos, negotiate (negotiate means that dynamical select the authentication method .)
(3) Best practices
If the same domain or your SS trusted domain, use the Windows-based authentication
If different non-trusted domain, use the certification
(4) All communication between endpoints can be encrypted, and you can specify which algorithm to use for the communications. the default algorithm is RC4, but you can specify the much stronger Advanced Encryption Standard (AES) algorithm.
3. database processing ing specific arguments
(1) database processing ing endpoints include a third argument related to the role within the database processing session.
(2) database partitioning ing endpoints role
Role description
Partner the endpoint can be only as the principal or the mirror
Witness the endpoint can be only as the witness
All the endpoints can be either partner or witness

(3) Other
4. database processing ing practice
(1) Structure

 

 

(2) Preparing works
Set the recovery mode of the principal to full.
Backup the database on principal
Restore the database on mirror with norecovery
Backup the transaction log on principal, restore the transaction log on the mirror
Transfer to the instance hosting the mirror all logins, jobs, linked server, and other objects external to the database.
-- On the principal server
Use master
Go
Backup database db_mirror_sample
To disk = 'C: \ test \ db_assist_sample.bak'
With format
Go

Backup log db_assist_sample
To disk = 'C: \ test \ db_assist_sample_log.bak'
With norecovery
Go

-- On the processing ing Server
Use master
Go

Restore database db_assist_sample
From disk = 'C: \ test \ db_assist_sample.bak'
With file = 1, norecovery
Go

Restore log db_assist_sample
From disk = 'C: \ test \ db_assist_sample_log.bak'
With file = 1, norecovery
Go
(3) Establishing endpoints.
Enable the database mirror
 
Configure Security
 
 
 

Change the SQL Server service account for principal, mirror, and witness.
 



(4) You can change operation mode if possible
Mode witness explanation
High Performance (asynchronous) n/a to maximize performance, the mirror database always lags somewhat behind the principal database, never quite catching up. however, the gap between the databases is typically small. the loss of a partner has the following effect:
If the mirror server instance becomes unavailable, the principal continues.
If the principal server instance becomes unavailable, the mirror stops; but if the session has no witness (as recommended) or the witness is connected to the mirror server, the mirror server is accessible as a warm standby; the database owner can force service to the mirror server instance (with possible data loss ).
High safety without automation Failover (synchronous) No all committed transactions are guaranteed to be written to disk on the mirror server.
Manual failover is possible when the partners are connected to each other and the database is synchronized.
The loss of a partner has the following effect:
If the mirror server instance becomes unavailable, the principal continues.
If the principal server instance becomes unavailable, the mirror stops but is accessible as a warm standby; the database owner can force service to the mirror server instance (with possible data loss ).
High safety with automatic failover (synchronous) Yes all committed transactions are guaranteed to be written to disk on the mirror server.
Availability is maximized by including a witness server instance to support automatic failover. Note that you can select the high safety with automatic failover (synchronous) option only if you have first specified a witness server address.
Manual failover is possible when the partners are connected to each other and the database is synchronized.
Important: if the witness becomes disconnected, the partner must be connected to each other for the database to be available.

In the presence of a witness, the loss of a partner has the following effect:
If the principal server instance becomes unavailable, automatic failover occurs. The mirror server instance switches to the role of principal, and it offers its database as the principal database.
If the mirror server instance becomes unavailable, the principal continues.

 
 
(5) failover
 

 
(6) removing the mirror
Alter database db_mirror_sample set partner off

 
5. Service Broker-specific arguments
(1) In addition to authentication modes and encryption, the Service Broker endpoints implement arguments related to message forwarding.
(2) The message_forwareding (disabled | enabled) option enables messages destined for a different broker instance to be forwarded to a specified forwarding address.
6. Service Broker practice
 

Use master
Go
Alter database db_sb
Set enable_broker
Go

Use db_sb
Go

Create master key
Encryption By Password = 'Pa $ w0rd'
Go

-- Message Type
Create Message Type submitbomproduct
Validation = well_formed_xml
Create Message Type receivebom
Validation = well_formed_xml
-- Create contract
Create contract bomcontract
(Submitbomproduct sent by initiator,
Receivebom sent by target)

/* Create queue */
-- 1. Create queue
Create queue bomproductqueue
Create queue bomresultqueue
-- 2 create a service
Create service bomrequestservice
On queue bomproductqueue (bomcontract)
Create service bomresultservice
On queue bomresultqueue (bomcontract)

/* Create a conversation */
Declare @ dialoghandle uniqueidentifier

Begin dialog conversation @ dialoghandle
From Service bomrequestservice
To service 'bomresultservice'
On contract bomcontract

Select @ dialoghandle

/* Send and reveive message */
Select * From bomproductqueue
Select * From bomresultqueue

-- 1. Send msg
Send on conversation 'ac0996ff-1c16-de11-aa62-0003ff1d2e78'
Message Type submitbomproduct
(N' <pdtid> 1 </pdtid> <pdtid> 2 </pdtid> <pdtid> 3 </pdtid> ')

Select * From bomproductqueue
Select * From bomresultqueue

-- 2. Receive msg
Receive top (1 )*
From bomresultqueue

Select * From bomproductqueue
Select * From bomresultqueue

Lesson 3: HTTP endpoints
1. HTTP Endpoint Security
(1) In addition to specifying the HTTP protocol with a soap payload that restricts the endpoints to accepting only a well-formed SOAP request, HTTP endpoints provide additional layers of security.
(2) authentication method
type details
Windows NTLM, Kerberos, or negotiate (Dynamic select)
certificate use a certificate from a trusted authority or generate your own windows certificate
(3) encryption
clear text or SSL
(4) login type
Windows or mixed
(5) specifying web methods
2. creating an endpoint
Create endpoint sample_endpoint
state = started
as HTTP
(
Path = '/HP ',
authentication = (integrated),
ports = (SSL),
ssl_port = 443,
site = 'www .sample.com '
)

For soap
(
Webmethod 'listcourse' (name = 'db _ cmd_sample.dbo.course ', schema = default, format = all_results ),
WSDL = default,
Database = 'db _ resource_sample ',
Namespace = 'HTTP: // temuri.org'
)

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.