Giter VIP home page Giter VIP logo

mongodb-cluster-migration's Introduction

mongodb-cluster-migration

mongodb-cluster-migration项目用于在不同MongoDB Cluster(或者MongoDB实例)之间进行无缝的数据库迁移,零停机。

实现原理与基本框架

基于Python Flask Web框架,并使用Flask-RESTful模块实现类RESTful接口。 使用的模块为:pymongo 和 flask-restful。

实现的基本思路:

  1. RESTful接口接收迁移时用到路径db和参数source、target(source表示迁移的MongoDB源副本集群、target表示迁移的MongoDB目标副本集群、db表示要迁移的数据库名);
  2. 启动迁移线程,获取最新的db的oplog信息;
  3. 使用mongodump和mongostore工具进行数据库的导入导出;
  4. 实时进行oplog的同步回放;
  5. 提供状态查询接口。

运行环境

Python 3.5 + MongoDB 3.0 +

项目启动方法

  1. 根据实际情况,添加配置文件中的MongoDB和log信息;
  2. 进入项目目录mongodb-cluster-migration;
  3. 执行 bash ./bin/startup.sh start,会自动进行Python3 venv创建和依赖安装; 提前安装好Python 3.5+各种环境

接口

  1. /migrate/ 开始迁移和同步db数据
  2. /status/ 查看db的迁移任务的执行进度,为0-100的整数,代表进度的百分比,100代表任务完成

参考资料

http://api.mongodb.com/python/current/examples/tailable.html
https://docs.mongodb.com/manual/

mongodb-cluster-migration's People

Contributors

xl0shk avatar

Stargazers

weichunshen89 avatar  avatar juzhen avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.