1、部署节点
|
|
部署模块 |
端口号 |
配置文件路径 |
数据存放路径 |
日志路径 |
|
192.168.100.38 |
Mongos |
20002 |
/conf/mongos/mongos.conf |
|
/log/mongos.log |
|
|
config |
21000 |
/conf/config/01.conf |
/data01/config/01 |
/log/config/01.log |
|
|
Shard1 |
27001 |
/conf/shard01/01.conf |
/data01/shard01/01 |
/log/shard01/01.log |
|
|
Shard2 |
27004 |
/conf/shard02/01.conf |
/data01/shard02/01 |
/log/shard02/01.log |
|
|
|
27005 |
/conf/shard02/02.conf |
/data01/shard02/02 |
/log/shard02/02.log |
|
192.168.100.40 |
Mongos |
20002 |
/conf/mongos/mongos.conf |
|
/log/mongos.log |
|
|
config |
21000 |
/conf/config/01.conf |
/data01/config/01 |
/log/config/01.log |
|
|
|
21001 |
/conf/config/02.conf |
/data01/config/02 |
/log/config/02.log |
|
|
Shard1 |
27001 |
/conf/shard01/01.conf |
/config/shard01/01 |
/log/shard01/01.log |
|
|
|
27002 |
/conf/shard02/02.conf |
/config/shard02/02 |
/log/shard02/02.log |
|
|
Shard2 |
27004 |
/conf/shard02/01.conf |
/config/shard02/01 |
/log/shard02/0.1log |
部署逻辑结构图
部署过程
3.1配置服务器
3.1.1 40 服务器01.conf配置服务器文件
dbpath = /data01/config/01
logpath = /log/config/01.log
logappend = true
bind_ip = 0.0.0.0
port = 21000
fork = true
configsvr = true
replSet=configs
maxConns=10000
---------------------------------------
3.1.2 40服务器02.conf配置服务器文件
dbpath = /data01/config/01
logpath = /log/config/01.log
logappend = true
bind_ip = 0.0.0.0
port = 21001
fork = true
configsvr = true
replSet=configs
maxConns=10000
3.1.3 38服务器01.conf配置服务器文件
dbpath = /data01/config/01
logpath = /log/config/01.log
logappend = true
bind_ip = 0.0.0.0
port = 21000
fork = true
configsvr = true
replSet=configs
maxConns=10000
3.1.4 启动配置服务器
40服务器启动
cd /usr/local/mongodb/mongodb/bin
./mongod -f /conf/config/01.conf
./mongod -f /conf/config/02.conf
38服务器启动
./mongod -f /conf/config/01.conf
3.2分片服务器
3.2.1 38服务器shard01的01.conf配置文件
dbpath = /data01/shard01/01
logpath = /log/shard01/01.log
logappend = true
bind_ip = 0.0.0.0
port = 27001
fork = true
httpinterface=true
rest=true
replSet=shard1
#declare this is a shard db of a cluster;
shardsvr = true
maxConns=10000
3.2.2 40服务器shard01的01.conf配置文件
dbpath = /data01/shard01/01
logpath = /log/shard01/01.log
logappend = true
bind_ip = 0.0.0.0
port = 27001
fork = true
httpinterface=true
rest=true
replSet=shard1
#declare this is a shard db of a cluster;
shardsvr = true
maxConns=10000
3.2.3 40服务器shard01的02.conf配置文件
dbpath = /data01/shard01/02
logpath = /log/shard01/02.log
logappend = true
bind_ip = 0.0.0.0
port = 27002
fork = true
httpinterface=true
rest=true
replSet=shard1
#declare this is a shard db of a cluster;
shardsvr = true
maxConns=10000
3.2.4 40服务器shard02的01.conf配置文件
dbpath = /data01/shard02/01
logpath = /log/shard02/01.log
logappend = true
bind_ip = 0.0.0.0
port = 27004
fork = true
httpinterface=true
rest=true
replSet=shard1
#declare this is a shard db of a cluster;
shardsvr = true
maxConns=10000
3.2.5 40服务器shard02的02.conf配置文件
dbpath = /data01/shard02/02
logpath = /log/shard02/02.log
logappend = true
bind_ip = 0.0.0.0
port = 27005
fork = true
httpinterface=true
rest=true
replSet=shard1
#declare this is a shard db of a cluster;
shardsvr = true
maxConns=10000
3.2.6 38服务器shard02的01.conf配置文件
dbpath = /data01/shard02/01
logpath = /log/shard02/01.log
logappend = true
bind_ip = 0.0.0.0
port = 27004
fork = true
httpinterface=true
rest=true
replSet=shard1
#declare this is a shard db of a cluster;
shardsvr = true
maxConns=10000
3.2.7分片服务器启动
./mongod -f /conf/shard01/01.conf &
./mongod -f /conf/shard01/02.conf &
./mongod -f /conf/shard01/03.conf &
3.3路由服务器
3.3.1 38路由服务器配置文件
logpath = /log/mongos.log
logappend = true
bind_ip = 0.0.0.0
port = 20000
fork = true
configdb = configs/192.168.100.40:21000,192.168.100.40:21001,192.168.100.38:21000
maxConns=10000
3.3.2启动路由服务器
./mongos -f /conf/mongos/mongos.conf &
3.4启动分片
mongo --port 20002
#使用admin数据库
user admin
#串联路由服务器与分配副本集
sh.addShard("shard1/192.168.100.40:27001,192.168.100.40:27002,192.168.100.38:27001")
sh.addShard("shard2/192.168.100.38:27004,192.168.100.38:27005,192.168.100.40:27004")
#查看集群状态
sh.status()
3.4设置分片集合
#指定igfc分片生效
db.runCommand( { enablesharding :"igfc"});
#指定数据库里需要分片的集合和片键
db.runCommand( { shardcollection : "igfc.gateway",key : {_id: 1} } )
db.runCommand( { shardcollection : "igfc.operLog",key : {_id: 1} } )