mongo Cluster配備


mongo cluster配備
Mongoマシン割当
テスト環境
    shard00:
           host1:8111,host2:8111,host3:8111
    shard01:
           host1:8112,host2:8112,host3:8112
    arbiter:
           host2:10000,host3:10000
           host2:10001,host3:10001
    config server:
           host1:8222,host2:8222,host3:8222
    mongos:
           host1:8333
せいさんかんきょう
    shard00:
           hostA:8111,hostB:8111,hostC:8111
    shard01:
           hostD:8111,hostE:8111,hostF:8111
    arbiter:
           hostG:10000,hostH:10000
           hostG:10001,hostH:10001
    config server:
           hostI:8222,hostJ:8222,hostK:8222
    mongos:
           hostL:8333
スライス構築参照前編ドキュメント:mongo Shard配備
configserver:
コンフィギュレーション
vi ~/configserver/conf/configserver.conf
#log
logpath = ./log/configserver.log
logappend = true
#listen port
port = 8222
#db path
dbpath  = ./data/configserver/
#independent dir per db
directoryperdb = true
#namespace disk size
nssize = 500
#max connection numbers
maxConns = 2048
#relication log size
oplogSize = 10240
#monitor
rest = true

開始
nohup numactl --interleave=all ./bin/mongod -f ./conf/configserver.conf --configsvr --keyFile=./conf/secretKey >/dev/null 2>&1 &

--configsvr//mongodをconfig serverとして起動
mongos:
コンフィギュレーション
vi ~/mongos/conf/mongos.conf
#log
logpath = ./log/mongos.log
logappend = true
#listen port = 8333
port = 8333
#config server ip:port
configdb = host1:8222,host2:8222,host36:8222
#max connection numbers
maxConns = 2048
noAutoSplit = true

開始
nohup  ./bin/mongos -f ./conf/mongos.conf --keyFile=./conf/secretKey >/dev/null 2>&1 &

プラスチップ
./bin/mongo --host 127.0.0.1 --port 8333
>sh.addShard("shardName/ip:port")

shardName/ip:port//shardNameはスライス名、ip:portはスライス内のいずれかのip:portでよい
この例では、
>sh.addShard("shard00/host1:8111")
>sh.addShard("shard01/host1:8112")

クエリーのステータス
>sh.status()
ユーザーの追加
./bin/mongo --host 127.0.0.1 --port 8333
>use admin
>db.addUser("username","password")

ログイン
./bin/mongo 127.0.0.1:8333/admin -u username -p password