目录Outline
1. prerequisites
2. steps to follow
3. configuring the cluster
4. a little test to see

1. Prerequisites

Suppose:
(1) you have deploy a functioning network to install mongodb cluster.
(2) you have gained the latest releases of MongoDB from 10gen.
(3) you have installed mongodb in the path $MongoHome.
(4) there are three folders, that are bin,dbs,logs, in $MongoHome folder.
(5) there are four servers here to make four shards in the cluster.
(6) their IP4 addresses are:
    +pc3:192.168.0.104
    +pc2:192.168.0.103
    +pc1:192.168.0.102
    host:192.168.0.100

2. Steps to follow

#1 biuld up mongod instance on every node.
    using the following CMD in Terminal on every shard marchine:
    -bash bash-install-shard...files.

bash-install-shard#!/bin/bash

mongo=/root/mongodb
data=$mongo/data
logs=$mongo/logs if ! [ -d $data ]
then
mkdir -p $data
fi if ! [ -d $logs ]
then
mkdir -p $logs
fi read -p "input a shard name :" shard
echo $shard
read -p "input a port :" port
echo $port mongod --shardsvr --replSet $shard --port $port --dbpath $data --oplogSize 100 --logpath $logs/shrd.log --logappend --profile=1 --slowms=5 --rest --smallfiles

#2 set up mongod instance of config server
    using the following CMD in Terminal on every config server marchine:
    -bash bash-install-config

bash-install-config#!/bin/bash

mongo=/root/mongodb
cfg=$mongo/config
data=$mongo/data
logs=$mongo/logs if ! [ -d $logs ]
then
mkdir -p $logs
fi if ! [ -d $cfg ]
then
mkdir -p $cfg
fi echo config server path: $cfg ,port:27018
mongod --configsvr --dbpath $cfg --port 27018 --logpath $logs/config.log --logappend

#3 initiate every replica set
    ssh every shard server, run mongo to login its local mongod instance,
    then write a config file for the relica set, and run rs.initate(config).
    see "shard initialize"file for more information.

shard-initializeshard1:
config = {_id: 'shard1', members: [ {_id: 0, host: '192.168.0.100:27020'}, {_id: 1, host: '192.168.0.102:27020'}]} shard2:
config = {_id: 'shard2', members: [ {_id: 0, host: '192.168.0.102:27021'}, {_id: 1, host: '192.168.0.103:27021'}]} shard3:
config= {_id: 'shard3', members: [ {_id: 0, host: '192.168.0.103:27022'}, {_id: 1, host: '192.168.0.104:27022'}]} shard4:
config = {_id: 'shard4', members: [ {_id: 0, host: '192.168.0.104:27023'}, {_id: 1, host: '192.168.0.100:27023'}]} rs.initiate(config)

#4 start mongos server
    using the following CMD in Terminal on every mongos server marchine:
    -bash bash-install-mongos

bash-install-mongos#!/bin/bash

configsvr1=192.168.0.115:27018
configsvr2=192.168.0.112:27018
configsvr3=192.168.0.110:27018 mongo=/root/mongodb
data=$mongo/data
logs=$mongo/logs if ! [ -d $logs ]
then
#mkdir -p $data
mkdir -p $logs
fi mongos --configdb $configsvr1,$configsvr2,$configsvr3 --port 27017 --chunkSize 5 --logpath $logs/mongos.log --logappend

#5 add shards to the cluster
    login one of the mongos, use sh.addShard("shard1/192.168.0.100:27020") CMD to add every shard.
    see "Add shards to the cluster" file for more information.

Add-shards-to-the-cluster#Add shards to the cluster

mongos> sh.addShard("shard1/192.168.0.100:27020")
{ "shardAdded" : "shard1", "ok" : 1 } mongos> sh.addShard("shard2/192.168.0.102:27021")
{ "shardAdded" : "shard2", "ok" : 1 } mongos> sh.addShard("shard3/192.168.0.103:27022")
{ "shardAdded" : "shard3", "ok" : 1 } mongos> sh.addShard("shard4/192.168.0.104:27023")
{ "shardAdded" : "shard4", "ok" : 1 }

Up to now a distributed MongoDB cluster with replica set has established, and its architecture may go like this:

3. Configuring your cluster to make it sharded

快速搭建MongoDB分布式集群的更多相关文章

  1. 带你快速了解 MongoDB 分布式集群

    在分布式应用系统中,mongodb 已经成为 NoSQL 经典数据库.要想很好的使用 mongodb,仅仅知道如何使用它是不够的.只有对其架构原理等有了充分认识,才能在实际运用中使其更好地服务于应用, ...

  2. mongodb分布式集群搭建手记

    一.架构简介 目标单机搭建mongodb分布式集群(副本集 + 分片集群),演示mongodb分布式集群的安装部署.简单操作. 说明在同一个vm启动由两个分片组成的分布式集群,每个分片都是一个PSS( ...

  3. 超快速使用docker在本地搭建hadoop分布式集群

    超快速使用docker在本地搭建hadoop分布式集群 超快速使用docker在本地搭建hadoop分布式集群 学习hadoop集群环境搭建是hadoop入门的必经之路.搭建分布式集群通常有两个办法: ...

  4. hadoop搭建伪分布式集群(centos7+hadoop-3.1.0/2.7.7)

    目录: Hadoop三种安装模式 搭建伪分布式集群准备条件 第一部分 安装前部署 1.查看虚拟机版本2.查看IP地址3.修改主机名为hadoop4.修改 /etc/hosts5.关闭防火墙6.关闭SE ...

  5. hadoop(二)搭建伪分布式集群

    前言 前面只是大概介绍了一下Hadoop,现在就开始搭建集群了.我们下尝试一下搭建一个最简单的集群.之后为什么要这样搭建会慢慢的分享,先要看一下效果吧! 一.Hadoop的三种运行模式(启动模式) 1 ...

  6. Storm环境搭建(分布式集群)

    作为流计算的开篇,笔者首先给出storm的安装和部署,storm的第二篇,笔者将详细的介绍storm的工作原理.下边直接上干货,跟笔者的步伐一块儿安装storm. 原文链接:Storm环境搭建(分布式 ...

  7. 超详细!CentOS 7 + Hadoop3.0.0 搭建伪分布式集群

    超详细!CentOS 7 + Hadoop3.0.0 搭建伪分布式集群 ps:本文的步骤已自实现过一遍,在正文部分避开了旧版教程在新版使用导致出错的内容,因此版本一致的情况下照搬执行基本不会有大错误. ...

  8. 在 Ubuntu 上搭建 Hadoop 分布式集群 Eclipse 开发环境

    一直在忙Android FrameWork,终于闲了一点,利用空余时间研究了一下Hadoop,并且在自己和同事的电脑上搭建了分布式集群,现在更新一下blog,分享自己的成果. 一 .环境 1.操作系统 ...

  9. 搭建MongoDB分片集群

    在部门服务器搭建MongoDB分片集群,记录整个操作过程,朋友们也可以参考. 计划如下: 用5台机器搭建,IP分别为:192.168.58.5.192.168.58.6.192.168.58.8.19 ...

随机推荐

  1. 如何给你的VS2010添加创建文件后的头注释

    修改VS自带的模板 1) 类文件 D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCache\ ...

  2. c# 反射学习笔记

    首先了解C#反射的概念,反射是一个运行库类型发现的过程.通过反射可以得到一个给定程序集所包含的所有类型的列表, 这个列表包括给定类型中定义的方法.字段.属性和事件.也可以动态的发现一组给定类支持的借口 ...

  3. libIconv.lib编码库的生成和使用

    iconv是将一种编码格式转换为另一种编码格式的开源库,例如可以把Windows环境下通用的ASCii(中文是GB2312)编码转换为国际通用的Unicode编码 iconv最新版本只支持MingW和 ...

  4. GLSL实现Ambient Occlusion 【转】

    http://blog.csdn.net/a3070173/archive/2008/11/04/3221181.aspx 相信使用OpenGl或DirectX3D的朋友都知道到固定功能管线在光照处理 ...

  5. C++ Caption

    主题 1. 设置控件的标题文本 2. 获取控件的标题文本     Caption属性 取得一个窗体的标题(caption)文字,或者一个控件的内容   红色的部分就是 Caption 标题   Set ...

  6. C语言默认參数值的实现

    from http://blog.csdn.net/pipisorry/article/details/25437893 C语言中没有參数默认值的概念,能够利用宏来模拟參数默认值: (对于有多个參数的 ...

  7. SparkGraphXTest.scala

    /** * Created by root on 9/8/15. */ import org.apache.spark._ import org.apache.spark.graphx._ impor ...

  8. 利用 Composer 一步一步构建自己的 PHP 框架(四)——使用 ORM

    本教程示例代码见 https://github.com/johnlui/My-First-Framework-based-on-Composer 回顾 经过前三篇文章 基础准备 . 构建路由 和 设计 ...

  9. const int * pi/int * const pi的区别

    前面有一篇文章:数组名就是常量指针 参考文章:http://blog.pfan.cn/whyhappy/5164.html const int * pi .int const * pi与int *   ...

  10. 使用GPS经纬度定位附近地点(某一点范围内查询)

    需要手机查找附近N米以内的商户,致想法是已知一个中心点,一个半径,求圆包含于圆抛物线里所有的点,经纬度是一个点,半径是一个距离,不能直接加减,下面提供C#的解决方法 数据库中记录了商家在百度标注的经纬 ...