设为首页 加入收藏

TOP

MongoDB 3 分片集群安装配置(一)
2017-04-26 10:22:18 】 浏览:741
Tags:MongoDB 3分片 集群 安装 配置

MongoDB版本:3.4.3


集群主机拓扑:


test1-3  分别在一台主机上启动两个不同副本集名称的mongod实例。


test4-6  三台主机作为 config server 单独运行。


test7    主机作为 mongos 路由主机。


wKioL1j-LBGjP3x6AAMWvUMRzRk121.gif


安装 MongoDB


配置 repo 源


选择国内 阿里云 镜像资源。


# yum install mongodb-org -y


配置 /etc/mongod.conf


# 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: 27017
  bindIp: 0.0.0.0  # Listen to local interface only, comment to listen on all interfaces.
 
 
#security:
 
#operationProfiling:
 
replication:
    replSetName: shard-a       
 
sharding:
    clusterRole: shardsvr
 
## Enterprise-Only Options
 
#auditLog:
 
#snmp:


replication 处配置 副本集 名,sharding 开启 shardsvr 模式。


启动 mongod 服务


[root@test1 ~]# service mongod start
Starting mongod:                                          [  OK  ]
 
[root@test2 ~]# service mongod start
Starting mongod:                                          [  OK  ]
 
[root@test3 ~]# service mongod start
Starting mongod:                                          [  OK  ]


配置 shard-a 副本集


[root@test1 ~]# mongo test1.lan:27017
MongoDB shell version v3.4.3
connecting to: test1.lan:27017
MongoDB server version: 3.4.3
Server has startup warnings: 
2017-04-24T22:46:19.703+0800 I STORAGE  [initandlisten] 
2017-04-24T22:46:19.703+0800 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-04-24T22:46:19.703+0800 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-04-24T22:46:20.321+0800 I CONTROL  [initandlisten] 
> rs.initiate()
{
    "info2" : "no configuration specified. Using a default configuration for the set",
    "me" : "test1.lan:27017",
    "ok" : 1
}
shard-a:SECONDARY> 
shard-a:PRIMARY> config  = rs.config()        # 保存配置对象
{
    "_id" : "shard-a",
    "version" : 1,
    "protocolVersion" : NumberLong(1),
    "members" : [
        {
            "_id" : 0,
            "host" : "test1.lan:27017",
            "arbiterOnly" : false,
&

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

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目