SQLSERVER复制的要点 在论坛里经常有人问: SQLSERVER复制出问题了!!SQLSERVER复制不运行了!! SQLSERVER复制遇到阻塞了!! 然后最后来一句:怎麽办??????????????? 大家知道:我们使用SQLSERVER复制功能主要用来读写分离,当然还有其他
SQLSERVER复制的要点
在论坛里经常有人问:SQLSERVER复制出问题了!!SQLSERVER复制不运行了!!SQLSERVER复制遇到阻塞了!!
然后最后来一句:“怎麽办???????????????”
大家知道:我们使用SQLSERVER复制功能主要用来读写分离,当然还有其他的场景会用到SQLSERVER复制,不过大部分还是用在"读写分离"
根据《SQLSERVER数据库大型应用解决方案总结》里总结的SQLSERVER复制的优缺点
文章地址:
优缺点 :
(1) 数据的实时性差:数据不是实时同步到自读服务器上的,当数据写入主服务器后,要在下次同步后才能查询到。
(2) 数据量大时同步效率差:单表数据量过大时插入和更新因索引,磁盘IO等问题,性能会变的很差。
(3) 同时连接多个(至少两个)数据库:至少要连接到两个数据数据库,实际的读写操作是在程序代码中完成的,容易引起混乱。
(4) 读具有高性能高可靠性和可伸缩:只读服务器,免备案空间,因为没有写操作,会大大减轻磁盘IO等性能问题,大大提高效率。
只读服务器可以采用负载均衡,主数据库发布到多个只读服务器上实现读操作的可伸缩性。
------------------------------------------------------华丽的分割线-----------------------------------------------------------
其实我们可以只同步某些表,不需要将整个数据库里的所有表都同步到订阅服务器上,而且SQLSERVER还支持只同步一张表里的某些列
有些人就是将整个数据库里的表都同步,不管哪些表是经常访问的,哪些表数据量比较大,哪些表不适合加主键或者索引
因为同步的一个条件是,表里必须要有主键,如果你需要同步所有表,那不是所有表都要加上主键??大家知道加上主键
相当于给表加了聚集索引,那么肯定影响数据修改的性能,所以大家只需要把需要同步/发布的表发布出来就可以了
没必要把整个库都发布出来,还有一些存储过程、函数、视图也是一样,只需要同步经常访问的或者必须要用到的就可以了
--------------------------------------------------------华丽的分割线---------------------------------------------------------
复制的前提条件:
(1)为了提高执行效率,可以限制订阅服务器获得的所有数据,或仅发布订阅者真正需要的数据或订阅者有权得到的数据
(2)在实现快照复制之前,网站空间,为快照复制留出充足的磁盘空间
(3)在实现事务复制之前,分配足够的日志空间,为分发数据库留有足够的磁盘空间
(4)为每一个表创建主键
(5)实现合并复制前移去timestamp列,由于订阅服务器的数据也会传递到发布服务器,
应确保数据的完整性在各个订阅服务器上都能得到保证,维护表之间的关联参照
(6)在所有IDENTITY属性字段上加上NOT FOR REPLICATION设置,以保证SQLSERVER在复制代理程序所添加的行上保留起始标识值,
但是继续在其他用户所添加的行上增加标识值。当用户将某个新行添加到表时,标志值以通常的方式增加。当复制代理程序将该新行复制到
订阅服务器时,再将该行插入到订阅服务器表中时不更改标识值
----------------------------------------------------------华丽的分割线-----------------------------------------------------
下面附上我写的一篇文章,虚拟主机,关于复制的介绍和复制的注意事项,如果提高复制性能,定制复制标准,定义复制等
SQLSERVER复制
1、只发布必要的表或字段
2、定制性能标准
3、提高常规复制的性能
里面有几个注意点,希望读者可以详细认真地读一下,o(∩_∩)o
希望文章能帮到大家
如有不对的地方,欢迎大家拍砖!!

ACID attributes include atomicity, consistency, isolation and durability, and are the cornerstone of database design. 1. Atomicity ensures that the transaction is either completely successful or completely failed. 2. Consistency ensures that the database remains consistent before and after a transaction. 3. Isolation ensures that transactions do not interfere with each other. 4. Persistence ensures that data is permanently saved after transaction submission.

MySQL is not only a database management system (DBMS) but also closely related to programming languages. 1) As a DBMS, MySQL is used to store, organize and retrieve data, and optimizing indexes can improve query performance. 2) Combining SQL with programming languages, embedded in Python, using ORM tools such as SQLAlchemy can simplify operations. 3) Performance optimization includes indexing, querying, caching, library and table division and transaction management.

MySQL uses SQL commands to manage data. 1. Basic commands include SELECT, INSERT, UPDATE and DELETE. 2. Advanced usage involves JOIN, subquery and aggregate functions. 3. Common errors include syntax, logic and performance issues. 4. Optimization tips include using indexes, avoiding SELECT* and using LIMIT.

MySQL is an efficient relational database management system suitable for storing and managing data. Its advantages include high-performance queries, flexible transaction processing and rich data types. In practical applications, MySQL is often used in e-commerce platforms, social networks and content management systems, but attention should be paid to performance optimization, data security and scalability.

The relationship between SQL and MySQL is the relationship between standard languages and specific implementations. 1.SQL is a standard language used to manage and operate relational databases, allowing data addition, deletion, modification and query. 2.MySQL is a specific database management system that uses SQL as its operating language and provides efficient data storage and management.

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

Key metrics for EXPLAIN commands include type, key, rows, and Extra. 1) The type reflects the access type of the query. The higher the value, the higher the efficiency, such as const is better than ALL. 2) The key displays the index used, and NULL indicates no index. 3) rows estimates the number of scanned rows, affecting query performance. 4) Extra provides additional information, such as Usingfilesort prompts that it needs to be optimized.

Usingtemporary indicates that the need to create temporary tables in MySQL queries, which are commonly found in ORDERBY using DISTINCT, GROUPBY, or non-indexed columns. You can avoid the occurrence of indexes and rewrite queries and improve query performance. Specifically, when Usingtemporary appears in EXPLAIN output, it means that MySQL needs to create temporary tables to handle queries. This usually occurs when: 1) deduplication or grouping when using DISTINCT or GROUPBY; 2) sort when ORDERBY contains non-index columns; 3) use complex subquery or join operations. Optimization methods include: 1) ORDERBY and GROUPB


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

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor