设为首页 加入收藏

TOP

MongoDB 3 分片集群安装配置(六)
2017-04-26 10:22:18 】 浏览:753
Tags:MongoDB 3分片 集群 安装 配置
;,
    "me" : "test1.lan:37017",
    "electionId" : ObjectId("7fffffff0000000000000001"),
    "lastWrite" : {
        "opTime" : {
            "ts" : Timestamp(1493046429, 1),
            "t" : NumberLong(1)
        },
        "lastWriteDate" : ISODate("2017-04-24T15:07:09Z")
    },
    "maxBsonObjectSize" : 16777216,
    "maxMessageSizeBytes" : 48000000,
    "maxWriteBatchSize" : 1000,
    "localTime" : ISODate("2017-04-24T15:07:24.475Z"),
    "maxWireVersion" : 5,
    "minWireVersion" : 0,
    "readOnly" : false,
    "ok" : 1
}


这样 shard-a  shard-b  两个副本集已经配置完成


开始配置 config server,MongoDB 从3.2版本之后开始规定 config server 也必须要开启副本集功能。
config server 的配置文件如下:config server 一般情况下是监听在 27019 端口


# mongod.conf
 
# for documentation of all options, see:
#  http://docs.mongodb.org/manual/reference/configuration-options/
 
# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log
 
# Where and how to store data.
storage:
  dbPath: /var/lib/mongo
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:
 
# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile
 
# network interfaces
net:
  port: 27019
  bindIp: 0.0.0.0  # Listen to local interface only, comment to listen on all interfaces.
 
 
#security:
 
#operationProfiling:
 
replication:
  replSetName: cfgReplSet
 
sharding:
  clusterRole: configsvr
 
## Enterprise-Only Options
 
#auditLog:
 
#snmp:


启动三台config server 的mongod 服务


[root@test4 ~]# service mongod start
Starting mongod:                                          [  OK  ]
 
[root@test5 ~]# service mongod start
Starting mongod:                                          [  OK  ]
 
[root@test6 ~]# service mongod start
Starting mongod:                                          [  OK  ]


同样,config server 的副本集配置如上文所示,这里的代码就省略了。


配置启动 mongos 路由主机


[root@test7 ~]# mongos --configdb cfgReplSet/test4.lan,test5.lan,test6.lan:27019 --logpath /var/log/mongodb/mongos.log --fork --port 30000
about to fork child process, waiting until server is ready for connections.
forked process: 3338
child process started successfully, parent exiting


MongoDB 版本 >3.2 启动mongos 的时候,需要跟上 config server 的副本集名称 (这里是 cfgReplSet)


连接 mongos 测试


[root@test7 ~]# mongo test7.lan:30000
MongoDB shell version v3.4.4
connecting to: test7.lan:30000
MongoDB server version: 3.4.4
Server has startup

首页 上一页 3 4 5 6 7 8 9 下一页 尾页 6/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇MySQL 5.7.x开启SSL连接 下一篇MySQL分库分表备份脚本

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目