{"id":13480842,"url":"https://github.com/rick446/mmm","last_synced_at":"2025-03-27T11:31:02.273Z","repository":{"id":3674921,"uuid":"4744315","full_name":"rick446/mmm","owner":"rick446","description":"MongoDB Multi-Master","archived":false,"fork":false,"pushed_at":"2012-07-13T18:23:23.000Z","size":153,"stargazers_count":68,"open_issues_count":4,"forks_count":16,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-25T10:52:19.662Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rick446.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-21T20:52:36.000Z","updated_at":"2025-02-12T11:52:01.000Z","dependencies_parsed_at":"2022-09-01T06:22:26.351Z","dependency_job_id":null,"html_url":"https://github.com/rick446/mmm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rick446%2Fmmm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rick446%2Fmmm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rick446%2Fmmm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rick446%2Fmmm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rick446","download_url":"https://codeload.github.com/rick446/mmm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245552548,"owners_count":20634201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:00:45.769Z","updated_at":"2025-03-27T11:31:01.965Z","avatar_url":"https://github.com/rick446.png","language":"Python","funding_links":[],"categories":["Tools"],"sub_categories":["Data"],"readme":"# MongoMultiMaster\n\nThis is a tool which allows you to set up multi-master replication with\nMongoDB. It is emphatically *not* supported by 10gen, the makers of MongoDB.\n\nIt works by querying the oplog on one replica set and applying its operations to\nanother replica set. It supports bidirectional replication by tagging each\ndocument replicated with its source.\n\n## Installing\n\nTo install, use pip:\n\n    pip install MongoMultiMaster\n    \n## MongoDB Setup\n\nMMM needs access to the replica set oplog for each master. This means it doesn't\nwork with servers that are configured as standalone servers. To convert a\nstandalone server to a singleton replica set, first you need to tell it about the\nset it's in at launch time:\n\n~~~~\n$ mongod --replSet foo\n~~~~\n\nThen, to start the replica set, you need to execute the following at the `mongo`\nshell:\n\n~~~~\n\u003e rs.initiate()\n~~~~\n\n## MongoMultiMaster Replication Setup\n\nOnce you've created the replica set master, you'll need to tell MMM where the\nservers are. This is done through a YAML config file. A sample config file with\ntwo servers is included below:\n\n~~~~\nserver_a:\n  id: '2c88ae84-7cb9-40f7-835d-c05e981f564d'\n  uri: 'mongodb://localhost:27019'\nserver_b:\n  id: '0d9c284b-b47c-40b5-932c-547b8685edd0'\n  uri: 'mongodb://localhost:27017'\n~~~~\n\nFirst, let's verify that there's no configuration and that we can connect to all\nthe servers in the config file:\n\n~~~~\n$ mmm -c test.yml clear-config\nAbout to clear config on servers: ['server_a', 'server_b'], are you sure? (yN) y\nClear config for server_a\nClear config for server_b\n$ mmm -c test.yml dump-config\n=== Server Config ===\nserver_a (2c88ae84-7cb9-40f7-835d-c05e981f564d) =\u003e mongodb://localhost:27019\nserver_b (0d9c284b-b47c-40b5-932c-547b8685edd0) =\u003e mongodb://localhost:27017\n\n=== server_a Replication Config\n=== server_b Replication Config\n\n~~~~\n\nNext, we'll set up two replicated collections:\n\n~~~~\n$ mmm -c test.yml replicate --src=server_a/test.foo --dst=server_b/test.foo\n$ mmm -c test.yml replicate --src=server_a/test.bar --dst=server_b/test.bar\n~~~~\n\nAnd confirm they're configured correctly:\n\n~~~~\n$ mmm -c test.yml dump-config\n=== Server Config ===\nserver_a (2c88ae84-7cb9-40f7-835d-c05e981f564d) =\u003e mongodb://localhost:27019\nserver_b (0d9c284b-b47c-40b5-932c-547b8685edd0) =\u003e mongodb://localhost:27017\n\n=== server_a Replication Config\n=== server_b Replication Config\n     - test.foo \u003c= server_a/test.foo\n     - test.bar \u003c= server_a/test.bar\n~~~~\n\nNow, let's make the replication bidirectional:\n\n~~~~\n$ mmm -c test.yml replicate --src=server_b/test.foo --dst=server_a/test.foo\n$ mmm -c test.yml replicate --src=server_b/test.bar --dst=server_a/test.bar\n~~~~\n\nAnd verify that it's correct...\n\n~~~~\n$ mmm -c test.yml dump-config\n=== Server Config ===\nserver_a (2c88ae84-7cb9-40f7-835d-c05e981f564d) =\u003e mongodb://localhost:27019\nserver_b (0d9c284b-b47c-40b5-932c-547b8685edd0) =\u003e mongodb://localhost:27017\n\n=== server_a Replication Config\n     - test.foo \u003c= server_b/test.foo\n     - test.bar \u003c= server_b/test.bar\n=== server_b Replication Config\n     - test.foo \u003c= server_a/test.foo\n     - test.bar \u003c= server_a/test.bar\n~~~~\n\nNow we can run the replicator:\n\n~~~~\n$ mmm -c test.yml run\n~~~~\n\n## Things to Consider\n\n- Replication can fall behind if you're writing a lot. This is not handled at\n  all.\n- Replication begins at the time when `mmm run` was first called. You should be\n  able to stop/start `mmm` and have it pick up where it left off.\n- Conflicts between masters aren't handled; if you're writing to the same\n  document on both heads frequently, you can get out of sync.\n- Replication inserts a bookkeeping field into each document to signify the\n  server UUID that last wrote the document. This expands the size of each\n  document slightly.\n\n\nThere are probably sharp edges, other missed bugs, and various nasty things\nwaiting for you if you use MMM in a production system without thorough\ntesting. But if you like running with scissors and otherwise living dangerously,\nfeel free to try it out.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frick446%2Fmmm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frick446%2Fmmm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frick446%2Fmmm/lists"}