Table of Contents
项目地址
功能
设计
InitCollection
CopyData
OplogSync
问题
目前进度 :
Home Database Mysql Tutorial mongodb迁移工具

mongodb迁移工具

Jun 07, 2016 pm 04:41 PM
github mongodb address tool migrate project

项目地址 [github]地址戳这里.(https://github.com/xbsura/mongo-migrate) 使用go语言编写,与m-tools保持一致,除了go语言自带的库,还需要mgo库支持. 功能 mongodb实例之间的数据迁移,带有根据源与目的的节点性质,进行自动分片,预split与movechunk,创建索引,

项目地址

[github]地址戳这里.(https://github.com/xbsura/mongo-migrate)

使用go语言编写,与m-tools保持一致,除了go语言自带的库,还需要mgo库支持.

功能

mongodb实例之间的数据迁移,带有根据源与目的的节点性质,进行自动分片,预split与movechunk,创建索引,拷贝数据与同步oplog几个过程.

设计

迁移工具分为三个阶段,初始化阶段,数据拷贝与oplog同步,分别使用InitCollection类,CopyData类与OplogSync类实现.

InitCollection

过程:

  1. 建立与源,目标的连接,若失败,raise.
  2. 初始化两个标识位,s(shard),o(oplog),为0, 0.
  3. 检测源类型,若为mongod,检测是否为复制集,若无法检测,raise;若为复制集,令o=1;若为mongos,查看要迁移的ns是否分片,如果分片,检测数据分片类型,若都为复制集,令o=1.
  4. 检测目标类型,若为mongod,令s=0.
  5. 若s=1,在目标进行分片,按照源的chunk进行split并随机movechunk.

CopyData

过程:
1. 建立源与目的的连接.
2. 获取要迁移的ns.
4. 如果o=1,记录源每个数据分片oplog最新值.
5. 如果源ns分片,按照chunk边界从源并发读,并向目标并发写;如果源未分片,使用一个query查询数据并向目标写.

OplogSync

过程:
1. 如果o=0,退出.
2. 建立源各个数据节点,目标节点(单节点)的连接.
3. 在每个源分片查找oplog ts大于等于CopyData记录时间点的记录,并逐条应用到目标节点.

问题

  1. 日志貌似打印有一点点问题.
  2. 性能没测试.
  3. 代码有点烂.

目前进度 :

完成可运行的版本,没有完整测试.

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)

The authoritative ranking of the top ten digital currency app exchanges in the currency circle in 2025 The authoritative ranking of the top ten digital currency app exchanges in the currency circle in 2025 Apr 20, 2025 pm 05:45 PM

The top ten digital currency exchanges in the currency circle: 1. OKX, 2. Binance, 3. Gate.io, 4. Coinbase, 5. Bybit, 6. Kraken, 7. KuCoin, 8. Bitget, 9. MEXC, 10. HTX, each performs outstandingly in the world's top digital asset platforms, daily trading volume, ten-year-old exchanges, Nasdaq listing, derivative trading volume, bank-level asset custody, innovative currency, order-study systems, innovation zone projects, Huobi brand upgrades, etc.

Which 2025 currency exchanges are more secure? Which 2025 currency exchanges are more secure? Apr 20, 2025 pm 06:09 PM

The top ten safe and reliable exchanges in the 2025 cryptocurrency circle include: 1. Binance, 2. OKX, 3. Gate.io (Sesame Open), 4. Coinbase, 5. Kraken, 6. Huobi Global, 7. Gemini, 8. Crypto.com, 9. Bitfinex, 10. KuCoin. These exchanges are rated as safe and reliable based on compliance, technical strength and user feedback.

South Korea sentences crypto fraudsters South Korea sentences crypto fraudsters Apr 20, 2025 pm 09:30 PM

South Korean court sentenced three people to prison for cryptocurrency scams. South Korea's Busan District Court recently made a verdict on a complicated cryptocurrency fraud case, and the three main culprits were sentenced to jail for fraudulent investors of 110 million won (about 416,000 US dollars). The court found that the three people used the fake "exclusive trading algorithm" as bait and promised a huge monthly return of 30% to defraud many victims. This algorithm does not actually exist, it is a tool used to commit fraud. The three defendants (published by last names only: Kim, Lee and Joe) used the public's enthusiasm for cryptocurrencies to fabricate lies from a global trading network to attract investors. The main culprit Jin was sentenced to four and a half years in prison, while Li and Qiao were sentenced to three and a half years in prison respectively. The judge pointed out that their behavior was severe

Top 10 cryptocurrency exchanges ranked in the top 10 digital currency exchanges latest list Top 10 cryptocurrency exchanges ranked in the top 10 digital currency exchanges latest list Apr 21, 2025 am 10:30 AM

The top ten cryptocurrency exchanges in 2025 are: 1. Binance, 2.Bybit, 3.OKX, 4.Coinbase, 5.Kraken, 6.HTX, 7.Gate.io, 8.KuCoin, 9.Crypto.com, 10.BitMEX. These exchanges have their own characteristics to meet the needs of different users.

New donations supporting Langley Memorial Hospital are almost one-third of its $1 million target New donations supporting Langley Memorial Hospital are almost one-third of its $1 million target Apr 21, 2025 am 11:39 AM

The charity party hosted by the Langley Community Health and Hospital Foundation raised $331,000 to establish the Guru Nanak Endowment Fund. The donation raised by the "Heart of Giving" charity party for Langley Memorial Hospital has reached one-third of its million-dollar target. On April 4, more than 250 guests attended the annual fundraising event at the Cloverdale Mirage Ballroom. Activities include raffle draws, silent auctions, live auctions and fundraising games, with 50/50 draws continuing until May 2. Since 2019, the Heart of Giving charity party has brought together donors every year to celebrate the community and raise donations, said Heather Scott, executive director of the Langley Community Health and Hospital Foundation. She said: "Testimation

Recommended top ten digital currency APPs in the world (authoritative release in 2025) Recommended top ten digital currency APPs in the world (authoritative release in 2025) Apr 21, 2025 pm 12:09 PM

The world's leading ten digital currency apps include: 1. OKX, 2. Binance, 3. Huobi, 4. Matcha (MXC), 5. Bitget, 6. BitMEX, 7. Pionex, 8. Deribit, 9. Bybit, 10. Kraken. These platforms have their own characteristics in security, transaction services, technical architecture, risk control team, user experience and ecosystem.

Bitcoin (BTC) Price Forecast: Can cryptocurrencies become a safe haven as the U.S. stock market plummets? Bitcoin (BTC) Price Forecast: Can cryptocurrencies become a safe haven as the U.S. stock market plummets? Apr 21, 2025 pm 01:00 PM

Since April 2, the "Liberation Day", the U.S. stock market has experienced unprecedented drastic fluctuations. The US's aggressive trade policy caught Wall Street off guard, triggering panic selling and violent shocks last week. The Dow Jones Index plummeted 4,000 points in just 48 hours, setting an unprecedented record of falling more than 1,500 points on two consecutive days in history. Meanwhile, the S&P 500 fell 10.5%, and its market value evaporated by nearly $5 trillion. False information and speculative market false information plays an important role in recent market fluctuations. For example, a Twitter account with about 1,000 followers claimed that the United States would suspend tariffs for 90 days, and was then forwarded by another account with about 800,000 followers, "Walter Bloomberg." This incident caused severe market fluctuations and stock prices soared.

What does quantitative transactions in virtual currencies mean? What trading platforms are there? What does quantitative transactions in virtual currencies mean? What trading platforms are there? Apr 20, 2025 pm 06:30 PM

There are multiple choices for virtual currency quantitative trading platforms, including: 1. Anbi quantitative trading platform, providing rich API interfaces and real-time market conditions; 2. Gate.io quantitative trading platform, known for its stable systems and high-quality services; 3. oKx quantitative trading platform, having leading trading depth and liquidity; 4. BitMEX quantitative trading platform, focusing on Bitcoin derivatives trading; 5. Bihuo quantitative trading platform, providing strong technical support and strategy templates; 6. ZB quantitative trading platform, with high quantitative functions and high praise; 7. Matcha quantitative trading platform, developing rapidly and providing profit sharing; 8. Bybit quantitative trading platform, known for its high performance and high stability; 9. MXC quantitative trading platform, with high functionality and cost-effectiveness;

See all articles