快速搭建MongoDB分布式集群


目录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分布式集群的更多相关文章
- 带你快速了解 MongoDB 分布式集群
在分布式应用系统中,mongodb 已经成为 NoSQL 经典数据库.要想很好的使用 mongodb,仅仅知道如何使用它是不够的.只有对其架构原理等有了充分认识,才能在实际运用中使其更好地服务于应用, ...
- mongodb分布式集群搭建手记
一.架构简介 目标单机搭建mongodb分布式集群(副本集 + 分片集群),演示mongodb分布式集群的安装部署.简单操作. 说明在同一个vm启动由两个分片组成的分布式集群,每个分片都是一个PSS( ...
- 超快速使用docker在本地搭建hadoop分布式集群
超快速使用docker在本地搭建hadoop分布式集群 超快速使用docker在本地搭建hadoop分布式集群 学习hadoop集群环境搭建是hadoop入门的必经之路.搭建分布式集群通常有两个办法: ...
- hadoop搭建伪分布式集群(centos7+hadoop-3.1.0/2.7.7)
目录: Hadoop三种安装模式 搭建伪分布式集群准备条件 第一部分 安装前部署 1.查看虚拟机版本2.查看IP地址3.修改主机名为hadoop4.修改 /etc/hosts5.关闭防火墙6.关闭SE ...
- hadoop(二)搭建伪分布式集群
前言 前面只是大概介绍了一下Hadoop,现在就开始搭建集群了.我们下尝试一下搭建一个最简单的集群.之后为什么要这样搭建会慢慢的分享,先要看一下效果吧! 一.Hadoop的三种运行模式(启动模式) 1 ...
- Storm环境搭建(分布式集群)
作为流计算的开篇,笔者首先给出storm的安装和部署,storm的第二篇,笔者将详细的介绍storm的工作原理.下边直接上干货,跟笔者的步伐一块儿安装storm. 原文链接:Storm环境搭建(分布式 ...
- 超详细!CentOS 7 + Hadoop3.0.0 搭建伪分布式集群
超详细!CentOS 7 + Hadoop3.0.0 搭建伪分布式集群 ps:本文的步骤已自实现过一遍,在正文部分避开了旧版教程在新版使用导致出错的内容,因此版本一致的情况下照搬执行基本不会有大错误. ...
- 在 Ubuntu 上搭建 Hadoop 分布式集群 Eclipse 开发环境
一直在忙Android FrameWork,终于闲了一点,利用空余时间研究了一下Hadoop,并且在自己和同事的电脑上搭建了分布式集群,现在更新一下blog,分享自己的成果. 一 .环境 1.操作系统 ...
- 搭建MongoDB分片集群
在部门服务器搭建MongoDB分片集群,记录整个操作过程,朋友们也可以参考. 计划如下: 用5台机器搭建,IP分别为:192.168.58.5.192.168.58.6.192.168.58.8.19 ...
随机推荐
- BZOJ 1051: [HAOI2006]受欢迎的牛 缩点
1051: [HAOI2006]受欢迎的牛 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/ ...
- HttpClient 设置代理方式
HttpClient httpClient = new HttpClient(); //设置代理服务器的ip地址和端口 httpClient.getHostConfiguration().setPro ...
- Android Service AIDL 远程调用服务 【简单音乐播放实例】
Android Service是分为两种: 本地服务(Local Service): 同一个apk内被调用 远程服务(Remote Service):被另一个apk调用 远程服务需要借助AIDL来完成 ...
- 一起聊聊 Swift 3.0
Swift3.0将会给我们带来哪些改变: 1. 稳定二进制接口(ABI) ABI是什么呢?API大家都知道是应用程序接口 API只是提供函数签名 而ABI是系统和语言层面的 如果ABI稳定 意味着以后 ...
- as3中使用stage ,root ,this 区别详解
stage:最顶层舞台root:stage的下一级舞台,属于第二层舞台(继承自DisplayObject)this:当前的对象(如果是主时间轴上的this,那它就是root) 继承方面:Stage - ...
- 高级I/O之readn和writen函数
管道.FIFO以及某些设备,特别是终端.网络和STREAMS设备有下列两种性质: (1)一次read操作所返回的数据可能少于所要求的数据,即使还没有达到文件尾端也可能是这样.这不是一个错误,应当继续读 ...
- 【不怕坑】之 Node.js加密 C#解密
本人也不太了解AES加密解密,为了解决Node.js加密,但是无法C#解密的问题,在网上搜了大量的相关文章. 但是多数是Node.js vs Java 或 Java vs C#的双向加密解密代码,但是 ...
- Android WebView的使用方法总结
本文主要讲解WebView的一些常用使用方法 代码如下: xml文件: <LinearLayout xmlns:android="http://schemas.android.com/ ...
- 小白日记40:kali渗透测试之Web渗透-SQL手工注入(二)-读取文件、写入文件、反弹shell
SQL手工注入 1.读取文件[load_file函数] ' union SELECT null,load_file('/etc/passwd')--+ burpsuite 2.写入文件 ' unio ...
- Asp.Net 之 通过调用 WScript.Shell 启动本地 exe 程序时产生“ automation服务器不能创建对象 ”的错误
我们经常需要通过生成 ActiveXObject("WScript.Shell"); 来调用某一exe文件. 设置网页打印的页眉页脚为空: var HKEY_Root,HKEY_P ...