本文讲解下在Windows Server 2012 R2中搭建SQL Server 2012故障转移集群的详细过程。需要说明的是我们搭建的SQL Server故障转移集
本文讲解下在Windows Server 2012 R2中搭建SQL Server 2012故障转移集群的详细过程。
需要说明的是我们搭建的SQL Server故障转移集群(SQL Server Failover Cluster)是可用性集群,而不是负载均衡集群,其目的是为了保证服务的连续性和可用性,而不是为了提高服务的性能。
SQL Server始终在负载均衡集群方面都缺少自己的产品,多由第三方厂家提供,但SQL Server故障转移集群却由来已久,在SQL Server 2012还提供了一个可用性组(AlwaysOn High Availability Groups)的新特性,我们知道微软的故障转移集群(Windows Server Failover Clustering , WSFC)一般需要共享存储,SQL Server故障转移集群也是建立在WSFC的基础之上,可用性组却可以不依赖于共享存储实现SQL Server的故障转移,这为没有共享存储的环境提供了一个实现SQL Server高可用的解决方案,关于AlwaysOn特性可以参阅相关文档,这里我们实现的是仍是基于共享存储的包含两个节点的SQL Server故障转移集群。
一、搭建Windows故障转移集群(WSFC)
SQL Server故障转移集群是基于WSFC的,因而我们需要事先在两个节点中搭建一个WSFC,这里需WSFC仅是一个容器,可以放置多个角色以实现这些角色的故障转移。为搭建一个WSFC,除了需要域环境,还需要在节点,存储,网络等方面做准备。
1、在各节点中添加Failover Clustering服务器功能。
2、确保各节点操作系统的更新一致,新安装的系统要么更新到最新,要么暂不更新。
3、在各节点中配置管理网络和心跳网络,虽然一个可用网络既可以搭建集群,但是最佳实践还是分开。
4、在各节点中配置共享存储磁盘,初始化并格式化磁盘,分配盘符。这里的共享存储磁盘可以是基于IP SAN和FC SAN的磁盘,也可以是基于文件服务器的虚拟磁盘,具体可以参考Windows Server 2012 虚拟化测试:存储。在节点中可见磁盘如下:
为搭建SQL Server故障转移集群,至少需要准备两块共享磁盘:集群见证磁盘Q、为存储SQL Server数据库和日志文件准备的集群磁盘S。另外我们需要为SQL Server的集群实例配置分布式事务协调器(Distributed Transaction Coordinator, DTC),因而需要为DTC准备磁盘M。微软建议将SQL Server各类文件分开存储,最佳实践需准备两块以上共享磁盘,分别存储User Database、Backup和User Database Log文件,这就至少需要另一个集群磁盘L。综上我们对存储做如下配置:
另外值得一提的是到SQL Server 2014才提供了对集群共享卷的支持,因而这里只能使用集群磁盘。
5、使用Failover Cluster Manager验证并创建集群。完成后的集群磁盘视图如下:
二、安装SQL Server故障转移集群
Windows故障转移集群(WSFC)搭建成功后即完成了SQL Server故障转移集群的基础,接下来我们继续完成SQL Server部分。先在一个节点上安装SQL Server Failover Cluster,然后再另一个节点安装加入集群节点。
SQL Server集群部分,先通过验证,这里的警告主要是搭建Windows故障转移集群存在警告的警告,升级警告以及防火墙警告,可以继续。
选择Database Engine Services和管理组件,注意这里只有Database Engine Services和Analysis Services支持集群,其他服务都不支持。其他组件如需要也可以随后再添加,但是添加其他组建时选择Add features to an existing installation,然后选择Perfom a new installation of SQL Server 2012,而不是Add features to an existing instance of SQL Server 2012,否则最后会出现Existing clustered or cluster-prepared instance的错误,具体参考Installing SQL Integration Services after SQL Cluster Setup has Completed。
配置一个网络名称,类似于计算机名称,今后将通过该名称访问数据库实例。
三、配置DTC和SQL Server 集群
分布式事务协调器(Distributed Transaction Coordinator, DTC)在Windows中是默认安装并运行的服务。DTC的主要目的是为了实现分布式事务,确保跨进程通信的一致性,这里的进程可以是同一计算机中的两个进程,也可以是不同计算机中的进程。因而在微软的世界里,常常看到DTC的身影。
如果只是独立安装SQL Server数据库引擎则无需配置DTC。但是在同时运行SQL Serve集成服务(SQL Server Integration Services, SSIS)或者搭建SQL Sever故障转移集群等需要分布式事务的场景中,则需要配置DTC。不配置DTC并不影响SQL Server集群的安装,但是DTC没能正确配置,SQL Server集群的功能将受到影响。
Windows Server 2008及以后版本在一个Windows集群中可以有多个DTC实例,这些DTC实例可以是集群实例也可以是本地实例(这里“实例”概念的类似于SQL Server数据库引擎实例,是作为操作系统服务运行的,是同一个可执行程序的副本,在Windows集群中运行的各类服务都是以实例的形式存在,这些实例依赖Windows集群实现故障转移),甚至可以为SQL Server集群中每个SQL Server实例配置一个专属的DTC实例。SQL Server集群实例按照如下的是顺序选择DTC实例:
使用SQL Server实例专属的DTC实例,该DTC实例作为SQL Server实例以来的资源,如果DTC实例失败,将造成SQL Server实例的失败。SQL Server 2008及以后版本才有此项。
使用映射给SQL Server实例的DTC实例,使用命令msdtc可以为SQL Server实例映射DTC实例。

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.

MySQL is not a programming language, but its query language SQL has the characteristics of a programming language: 1. SQL supports conditional judgment, loops and variable operations; 2. Through stored procedures, triggers and functions, users can perform complex logical operations in the database.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL is an open source relational database management system suitable for data storage, management, query and security. 1. It supports a variety of operating systems and is widely used in Web applications and other fields. 2. Through the client-server architecture and different storage engines, MySQL processes data efficiently. 3. Basic usage includes creating databases and tables, inserting, querying and updating data. 4. Advanced usage involves complex queries and stored procedures. 5. Common errors can be debugged through the EXPLAIN statement. 6. Performance optimization includes the rational use of indexes and optimized query statements.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

InnoDB's lock mechanisms include shared locks, exclusive locks, intention locks, record locks, gap locks and next key locks. 1. Shared lock allows transactions to read data without preventing other transactions from reading. 2. Exclusive lock prevents other transactions from reading and modifying data. 3. Intention lock optimizes lock efficiency. 4. Record lock lock index record. 5. Gap lock locks index recording gap. 6. The next key lock is a combination of record lock and gap lock to ensure data consistency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version
SublimeText3 Linux latest version

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Atom editor mac version download
The most popular open source editor