npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mongodb-sharding-bitnami-yaml-generator

v1.2.0

Published

generate bitnami/mongodb-sharded docker-compose.yaml file

Downloads

15

Readme

mongodb-sharding-bitnami-yaml-generator

generate bitnami/mongodb-sharded docker-compose.yaml file

Installation

Global package

If you want to use in command line.

npm i -g mongodb-sharding-bitnami-yaml-generator

Project package

If you want to use in node.js.

npm i mongodb-sharding-bitnami-yaml-generator

Usage

Configuration

  • You can refer to examples.config.json file to configure.
  • The file need to be json file.
{
    "generator": {
        "projectName": "", //The project name, use to generator docker-compose service name, e.g. `hello` will generate `hello-mongodb-monogos`. When empty string will generate `mongodb-mongos`
        "shardCount": 1,
        "useSameShardConfig": true //When true, every shards use first configuration. Otherwise will detect `shards` length is same to `shardCount`, this mean that you need to config every shards,respectively.
    },
    "mongos": {
        "replicaSetKey": "replicaSet123",
        "rootPassword": "password"
    },
    "shards": [
        {
            "secondaryCount": 1,
            "enableArbiter": true
        }
    ],
    "cfg": {
        "secondaryCount": 0
    }
}

Command line

Usage: mongodb-sharding-bitnami-yaml-generator [options]

Options:
  -V, --version          output the version number
  -c, --config <string>  input config file path (required)
  -o, --output <string>  output file path (required)
  -h, --help             display help for command

Node.js

const { generateMongoDBShardYamlConfig } = require('mongodb-sharding-bitnami-yaml-generator')

let yamlStr = generateMongoDBShardYamlConfig({
    projectName: "",
    shardCount: 2,
    useSameShardConfig: false
} ,{
    mongos: {
        replicaSetKey: "replicaSet123",
        rootPassword: "password"
    },
    shards: [
        {
            secondaryCount: 2,
            enableArbiter: true
        }
    ] ,
    cfg : {
        secondaryCount: 0
    }
});
console.log(yamlStr);

Example Generated docker-compose.yaml

version: '3.4'
services:
  mongodb-mongos:
    image: docker.io/bitnami/mongodb-sharded:4.4
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-mongos
      - MONGODB_SHARDING_MODE=mongos
      - MONGODB_CFG_PRIMARY_HOST=mongodb-cfg-primary
      - MONGODB_CFG_REPLICA_SET_NAME=replicaSet-cfg
      - MONGODB_REPLICA_SET_KEY=replicaSet123
      - MONGODB_ROOT_PASSWORD=password
    volumes:
      - ./mongodb-shard/mongos-data:/bitnami
    ports:
      - '27017:27017'
  mongodb-cfg-primary:
    image: docker.io/bitnami/mongodb-sharded:4.4
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg-primary
      - MONGODB_SHARDING_MODE=configsvr
      - MONGODB_ROOT_PASSWORD=password
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_KEY=replicaSet123
      - MONGODB_REPLICA_SET_NAME=replicaSet-cfg
    volumes:
      - ./mongodb-shard/cfg-data:/bitnami
  mongodb-shard0-primary:
    image: docker.io/bitnami/mongodb-sharded:4.4
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-primary
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_MONGOS_HOST=mongodb-mongos
      - MONGODB_ROOT_PASSWORD=password
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_KEY=replicaSet123
      - MONGODB_REPLICA_SET_NAME=replicaSet-shard0
    volumes:
      - ./mongodb-shard/shard0-primary-data:/bitnami
  mongodb-shard0-secondary0:
    image: docker.io/bitnami/mongodb-sharded:4.4
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-secondary0
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_MONGOS_HOST=mongodb-mongos
      - MONGODB_INITIAL_PRIMARY_HOST=mongodb-shard0-primary
      - MONGODB_INITIAL_PRIMARY_PORT_NUMBER=27017
      - MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD=password
      - MONGODB_REPLICA_SET_MODE=secondary
      - MONGODB_REPLICA_SET_KEY=replicaSet123
      - MONGODB_REPLICA_SET_NAME=replicaSet-shard0
    volumes:
      - ./mongodb-shard/shard0-secondary0-data:/bitnami
  mongodb-shard0-arbiter:
    image: docker.io/bitnami/mongodb-sharded:4.4
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0-arbiter
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_MONGOS_HOST=mongodb-mongos
      - MONGODB_INITIAL_PRIMARY_HOST=mongodb-shard0-primary
      - MONGODB_INITIAL_PRIMARY_PORT_NUMBER=27017
      - MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD=password
      - MONGODB_REPLICA_SET_MODE=arbiter
      - MONGODB_REPLICA_SET_KEY=replicaSet123
      - MONGODB_REPLICA_SET_NAME=replicaSet-shard0
    volumes:
      - ./mongodb-shard/shard0-arbiter-data:/bitnami
  mongodb-shard1-primary:
    image: docker.io/bitnami/mongodb-sharded:4.4
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-primary
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_MONGOS_HOST=mongodb-mongos
      - MONGODB_ROOT_PASSWORD=password
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_KEY=replicaSet123
      - MONGODB_REPLICA_SET_NAME=replicaSet-shard1
    volumes:
      - ./mongodb-shard/shard1-primary-data:/bitnami
  mongodb-shard1-secondary0:
    image: docker.io/bitnami/mongodb-sharded:4.4
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-secondary0
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_MONGOS_HOST=mongodb-mongos
      - MONGODB_INITIAL_PRIMARY_HOST=mongodb-shard1-primary
      - MONGODB_INITIAL_PRIMARY_PORT_NUMBER=27017
      - MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD=password
      - MONGODB_REPLICA_SET_MODE=secondary
      - MONGODB_REPLICA_SET_KEY=replicaSet123
      - MONGODB_REPLICA_SET_NAME=replicaSet-shard1
    volumes:
      - ./mongodb-shard/shard1-secondary0-data:/bitnami
  mongodb-shard1-arbiter:
    image: docker.io/bitnami/mongodb-sharded:4.4
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard1-arbiter
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_MONGOS_HOST=mongodb-mongos
      - MONGODB_INITIAL_PRIMARY_HOST=mongodb-shard1-primary
      - MONGODB_INITIAL_PRIMARY_PORT_NUMBER=27017
      - MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD=password
      - MONGODB_REPLICA_SET_MODE=arbiter
      - MONGODB_REPLICA_SET_KEY=replicaSet123
      - MONGODB_REPLICA_SET_NAME=replicaSet-shard1
    volumes:
      - ./mongodb-shard/shard1-arbiter-data:/bitnami