Table of Contents
同步复制OneWay的数据库表研究
系统环境
执行操作
Home Database Mysql Tutorial 同步复制OneWay的数据库表研究

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

Jun 07, 2016 pm 03:48 PM
Synchronize copy database Research

同步复制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>
Copy after login

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

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

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

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

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

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

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

<mygenerationnumber>0</mygenerationnumber>
 <sibgenerationnumber>1</sibgenerationnumber>
 <sibmygenerationnumber>0</sibmygenerationnumber>
<replicastate>esriReplicaStateSendingAcknowledgment</replicastate>
Copy after login
Copy after login

       同样也会更新子库中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>
Copy after login

      子库里面的A表和状态表

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

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

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

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

<mygenerationnumber>0</mygenerationnumber>
 <sibgenerationnumber>1</sibgenerationnumber>
 <sibmygenerationnumber>0</sibmygenerationnumber>
<replicastate>esriReplicaStateSendingAcknowledgment</replicastate>
Copy after login
Copy after login

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


Statement of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

An in-depth analysis of how HTML reads the database An in-depth analysis of how HTML reads the database Apr 09, 2024 pm 12:36 PM

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

How to connect to remote database using Golang? How to connect to remote database using Golang? Jun 01, 2024 pm 08:31 PM

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

The key concept of C++ multi-threaded programming is how to synchronize threads? The key concept of C++ multi-threaded programming is how to synchronize threads? Jun 03, 2024 am 11:55 AM

Key concepts of C++ multi-thread synchronization: Mutex lock: ensure that the critical section can only be accessed by one thread. Condition variables: Threads can be awakened when specific conditions are met. Atomic operation: A single uninterruptible CPU instruction ensures the atomicity of shared variable modifications.

See all articles