mongodb迁移工具
项目地址 [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
过程:
- 建立与源,目标的连接,若失败,raise.
- 初始化两个标识位,s(shard),o(oplog),为0, 0.
- 检测源类型,若为mongod,检测是否为复制集,若无法检测,raise;若为复制集,令o=1;若为mongos,查看要迁移的ns是否分片,如果分片,检测数据分片类型,若都为复制集,令o=1.
- 检测目标类型,若为mongod,令s=0.
- 若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记录时间点的记录,并逐条应用到目标节点.
问题
- 日志貌似打印有一点点问题.
- 性能没测试.
- 代码有点烂.
目前进度 :
完成可运行的版本,没有完整测试.
原文地址:mongodb迁移工具, 感谢原作者分享。

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

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

Hot Article

Hot Tools

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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.

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 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

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.

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

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.

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.

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;
