search
HomeDatabaseMysql Tutorial同步复制OneWay的数据库表研究

同步复制OneWay的数据库表研究 通过使用同步复制Oneway的数据库表的研究,来更加深入的了解同步复制的原理,数据同步的步骤。 本文以OneWay的父到子为例(从子到父只是角色变了,表的变化可以类比一下)。 系统环境 父库:Oracle 11.2.0.1 64Bit、 ArcSDE10 S

同步复制OneWay的数据库表研究

       通过使用同步复制Oneway的数据库表的研究,来更加深入的了解同步复制的原理,数据同步的步骤。

       本文以OneWay的父到子为例(从子到父只是角色变了,表的变化可以类比一下)。

系统环境

       父库:Oracle 11.2.0.1 64Bit、 ArcSDE10 SP2 64Bit

       子库:SQL Server 2008 64Bit、ArcSDE10 SP2 64Bit

       两个库里面没有任何版本,STATE=0

执行操作

         1:父库:注册版本、添加GlobeID。

         2:执行复本操作,父库将相关的所有数据都导入到子库中。

       父库:VERSIONS表中添加一条同步复制版本的记录。使用同步复制产生的版本名称都是以”SYNC_SEND_ReplicaObjectiD_”为前缀的,状态为16777216(这个数字还没有具体研究过,好像Oneway和Twoway是不一样的),一开始没有编辑之前,这两条记录的STATE_ID=0。

同步复制OneWay的数据库表研究

  GDB_ITEMS表中添加一项Replica名称,默认为MyRelplica,是以XML存储,我们来看一下这个内容:子库的相关的连接参数信息,父库的相关角色等都描述的非常清楚。

同步复制OneWay的数据库表研究

         子库:导入父库的所有数据(如果不加任何条件的话),导入之后直接就是注册版本状态。我查看了子库一开始的整体数据同步(非编辑父库同步),是不走状态表和增量表的,直接将父库的基表数据导入到子库的基表中。

VERSIONS表中无任何新添加的信息。

        GDB_ITEMS表中添加一项Replica名称,默认为MyRelplica,是以XML存储,我们来看一下这个内容:父库的相关的连接参数信息,子库的相关角色等都描述的非常清楚。

同步复制OneWay的数据库表研究

3:对父库进行编辑

       我对父库进行增、删、改三种方式的编辑行为,每做一次保存一下编辑,目的是记录一下相关的编辑状态。

       父库的Versions表、States表等相关的版本表、增量表肯定发生了变化。如下Versions:

同步复制OneWay的数据库表研究

4:将父库变化的数据进行同步

       父库的Versions表中发生了一些变化,首先我们查看一下同步复制的版本名称由原来的SYNC_SEND_4177_0变为SYNC_SEND_4177_1,这说明这个数字可以记录同步的次数。

同步复制OneWay的数据库表研究

       GDB_ITEMS表中的Replica信息也发生了相关的变化

<mygenerationnumber>1</mygenerationnumber>
<sibgenerationnumber>0</sibgenerationnumber>
<sibmygenerationnumber>1</sibmygenerationnumber>

        GDB_REPLICALOG表里面记录了同步的相关日志信息

同步复制OneWay的数据库表研究

      子库里面我们可以看到,父库是通过版本表、增量表等信息将变化的数据同步过去的,那么我们在子库里面的相关表也同步过来了。

同步复制OneWay的数据库表研究

同步复制OneWay的数据库表研究

      从上面的A表和STATES表可以看出,尽管我在父库里面是记录了三个不同状态的操作,但是在同步过程中,子库只记录一个相关的状态,这个状态可以记录同时编辑了N个数据,这样的话势必会提高子库的数据查询分析效率。

     GDB_ITEMS表中的Replica信息也发生了相关的变化

<mygenerationnumber>0</mygenerationnumber>
 <sibgenerationnumber>1</sibgenerationnumber>
 <sibmygenerationnumber>0</sibmygenerationnumber>
<replicastate>esriReplicaStateSendingAcknowledgment</replicastate>

       同样也会更新子库中VERSIONS表的STATE_ID,将最新的ID同步更新。这样一次同步复制就完成了,那么我还是有一个疑问,系统是怎么将父库中关于某个同步要素类的变化的数据区分过去同步的,也就是他是将所有变化的数据给同步过去还是只同步最新变化的数据呢?带着这个问题我再一次做一个同步操作。

       5:对父库做第二次编辑

       我们可以看到父库里面VERSIONS表中

同步复制OneWay的数据库表研究

       然后我们再看看族系表

同步复制OneWay的数据库表研究

       其实从上面两个表我已经可以猜到系统肯定是只同步变化的数据,因为根据这两个表就能推出哪些是最新编辑的数据,因为系统记录了第一次同步之后第二次编辑之前的最新的状态值STATE_ID=55,根据这个值可以找到相关的族系名称LINEAGE_NAME=53,那么顺着这个族系名称找到最大的状态值就是最新编辑的记录的状态,从图上我们可以看到56、57、58都是最新编辑的,那么我们就可以从STATES表和增量表中将相关的信息记录出来。

5:第二次同步

      父库GDB_REPLICALOG表里面记录了同步的相关日志信息

同步复制OneWay的数据库表研究

       VERSIONS表中,果然同步版本名称又增加了1,同时更新了最新的状态值

同步复制OneWay的数据库表研究

      GDB_ITEMS表中的Replica信息也发生了相关的变化

<mygenerationnumber>2</mygenerationnumber>
<sibgenerationnumber>0</sibgenerationnumber>
<sibmygenerationnumber>2</sibmygenerationnumber>

      子库里面的A表和状态表

同步复制OneWay的数据库表研究

同步复制OneWay的数据库表研究

       从上面的图更加坚定我刚才的猜测,系统只同步变化的数据,原来的状态值等于52的仍然没有变化,第二次同步过来的就是53(根据状态序列)。

      GDB_ITEMS表中的Replica信息也发生了相关的变化

<mygenerationnumber>0</mygenerationnumber>
 <sibgenerationnumber>1</sibgenerationnumber>
 <sibmygenerationnumber>0</sibmygenerationnumber>
<replicastate>esriReplicaStateSendingAcknowledgment</replicastate>

       结论:通过上面对同步复制OneWay操作后数据库表信息的变化,基本上可以将这个编辑同步过程的步骤,或者系统设计的思路弄清楚,系统是根据子库父库存储的Replica的XML获取相关的角色、连接、数据描述等相关信息,然后编辑数据根据版本表、增量表将变化的数据读取然后进行相关的操作。


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do you handle database upgrades in MySQL?How do you handle database upgrades in MySQL?Apr 30, 2025 am 12:28 AM

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

What are the different backup strategies you can use for MySQL?What are the different backup strategies you can use for MySQL?Apr 30, 2025 am 12:28 AM

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

What is MySQL clustering?What is MySQL clustering?Apr 30, 2025 am 12:28 AM

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

How do you optimize database schema design for performance in MySQL?How do you optimize database schema design for performance in MySQL?Apr 30, 2025 am 12:27 AM

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

How can you optimize MySQL performance?How can you optimize MySQL performance?Apr 30, 2025 am 12:26 AM

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

How to use MySQL functions for data processing and calculationHow to use MySQL functions for data processing and calculationApr 29, 2025 pm 04:21 PM

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

An efficient way to batch insert data in MySQLAn efficient way to batch insert data in MySQLApr 29, 2025 pm 04:18 PM

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

Steps to add and delete fields to MySQL tablesSteps to add and delete fields to MySQL tablesApr 29, 2025 pm 04:15 PM

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor