Skip to content

Instantly share code, notes, and snippets.

View marantz's full-sized avatar

DongHan Kim marantz

View GitHub Profile
/******************************************************************************
* Copyright ⓒ [Anonymous Company] All rights reserved.
******************************************************************************/
/********************************H i s t o r y*********************************
* Day Version Name Note
* 20XX.XX.XX 1.0.0 XXXXXX Create Class
******************************************************************************/
/**
* @logicalName XXXXX
{
"key" : "77-AF-9A-FA-B6-F3",
"key_type" : "MAC",
"history" : [
{
"I_DATETIME" : "20141103011530",
"USER_ID" : "test1"
},
{
"I_DATETIME" : "20141103011529",
@marantz
marantz / AggregateExample
Last active August 29, 2015 14:10
MongoDB Array Distinct Count
db.test.aggregate(
[{ $unwind : "$history" }
,{ $match : { "key_type" : "MAC"} }
,{ $group : { _id:{"key":"$key","USER_ID":"$history.USER_ID"}, USER_COUNT:{$addToSet:1} } }
,{ $unwind :"$USER_COUNT" }
,{ $group : { _id:"$_id.key", count:{"$sum":1} } }]
);
@marantz
marantz / mongodb shards config file
Last active August 29, 2015 14:12
mongodb shards config file
net:
bindIp: [127.0.0.1] #[hostname/ip/DNS] ARRAY
port: 37148 # [MONGOS:27018,CONFIG:271X8,SHARDS:272X8]
processManagement:
fork: true
sharding:
clusterRole: shardsvr # [shardsvr/configsvr]
security:
authorization: disabled # [enabled/disabled]
javascriptEnabled: true
@marantz
marantz / DBDump.sh
Last active August 29, 2018 15:30
MongoDB Dump shell script
#!/bin/sh
PORT=27017
MONGODB_HOME=/opt/mongodb
MONGODB_BIN=${MONGODB_HOME}/bin
MONGO="${MONGODB_BIN}/mongo --host centos --port ${PORT} --quiet"
MONGODUMP="${MONGODB_BIN}/mongodump --host centos --port ${PORT}"
BACKUP_DIR=${MONGODB_HOME}/data/backup
echo "BACKUP DATABASE"
_DB_LIST=(`echo "show dbs" | $MONGO | grep -v admin | grep -v config | awk {'print $1'}`)
@marantz
marantz / mongos.conf
Created November 3, 2015 06:58
MongoDB YAML CONFIG
net:
bindIp: hostName
port: 27018
processManagement:
fork: true
sharding:
configDB: "hostName:hostName:27228,hostName:27238"
autoSplit: false
systemLog:
destination: file
@marantz
marantz / config_01.conf
Created November 3, 2015 06:59
MongoDB CONFIG SERVER CONFIG YAML
net:
bindIp: [127.0.0.1,hostName]
port: 27218
processManagement:
fork: true
sharding:
clusterRole: configsvr # [shardsvr/configsvr]
security:
authorization: disabled
javascriptEnabled: true
@marantz
marantz / mongo_start.sh
Last active November 3, 2015 07:29
MongoDB Start Shell
#!/bin/bash
/opt/mongodb/bin/mongod -f /opt/mongodb/conf/shard_mongod_01.conf
/opt/mongodb/bin/mongod -f /opt/mongodb/conf/shard_mongod_02.conf
/opt/mongodb/bin/mongod -f /opt/mongodb/conf/shard_mongod_03.conf
/opt/mongodb/bin/mongod -f /opt/mongodb/conf/shard_config_01.conf
/opt/mongodb/bin/mongod -f /opt/mongodb/conf/shard_config_02.conf
/opt/mongodb/bin/mongod -f /opt/mongodb/conf/shard_config_03.conf
echo ‘READY TO TAKE OFF DATABASE WAIT 10 SEC’;sleep 10
/opt/mongodb/bin/mongos -f /opt/mongodb/conf/shard_cluster.conf
@marantz
marantz / MongoDB Settting.md
Last active March 29, 2024 08:03
MongoDB Setting Markdown

MongoDB Shard Setting

1.서버 데몬의 구성

본 문서는 기본 샤딩의 개념을 실습하고 학습하는 데에 목표를 두고 3대의 서버를 둔다는 가정하에 한대의 물리적인 서버에 샤딩을 구성하며 Sharding 의 Rule 이라고 볼 수 있는 Collectoin의 Shard Chunk 구성은 하지 않는다.

각 싸이트마다 데이터의 규칙을 살펴보고 Chunk 구성까지 하여야 하며 Autosharding 은 가급적 구성하지 않는 것으로 한다.

  • mongod

>Sharding이 되는 기본 데몬, 옵션에 따라 configsvr 또는 shardsvr로 나뉘게 된다.