mongos 分片服务器 https://blog.csdn.net/weixin_49724150/article/details/121748365 1.部署的服务器ip地址 172.16.0.151 172.16.0.173 172.16.0.220 2.etcd版本 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.4.tgz 3.三台服务器安装目录 3个数据分片副本集,1个mongos副本集,1个config副本集 /data 安装目录 /data01到/data05 /data01/share1 #数据分片副本集1目录 /data02/share2 #数据分片副本集2目录 /data03/share3 #数据分片副本集3目录 /data04/configsvr #config副本集目录 /data05/mongos #mongos副本集目录 4.每个内存限制0.5G; [root@im-04 ~]# ls /data/mongodb/conf/ configsvr.conf mongos.conf shard1.conf shard2.conf shard3.conf [root@im-04 conf]# vim shard1.conf systemLog: destination: file logAppend: true path: /data02/mongodb/logs/shard2.log storage: dbPath: /data02/mongodb/data journal: enabled: true wiredTiger: engineConfig: configString : cache_size=500M processManagement: fork: true pidFilePath: /data02/mongodb/shard2/shard2.pid net: port: 27020 bindIp: 0.0.0.0 replication: replSetName: shard2 sharding: clusterRole: shardsvr [root@im-04 conf]# vim shard2.conf systemLog: destination: file logAppend: true path: /data03/mongodb/logs/shard3.log storage: dbPath: /data03/mongodb/data journal: enabled: true wiredTiger: engineConfig: configString : cache_size=500M processManagement: fork: true pidFilePath: /data03/mongodb/shard3/shard3.pid net: port: 27021 bindIp: 0.0.0.0 replication: replSetName: shard3 sharding: clusterRole: shardsvr [root@im-04 conf]# vim shard1.conf systemLog: destination: file logAppend: true path: /data01/mongodb/logs/shard1.log storage: dbPath: /data01/mongodb/data journal: enabled: true wiredTiger: engineConfig: configString : cache_size=500M processManagement: fork: true pidFilePath: /data01/mongodb/shard1/shard1.pid net: port: 27019 bindIp: 0.0.0.0 replication: replSetName: shard1 sharding: clusterRole: shardsvr [root@im-04 conf]# cat configsvr.conf systemLog: destination: file logAppend: true path: /data04/mongodb/logs/configsvr.log # Where and how to store data. storage: dbPath: /data04/mongodb/data journal: enabled: true # how the process runs processManagement: fork: true # fork and run in background pidFilePath: /data04/mongodb/configsvr/configsvr.pid # location of pidfile # network interfaces net: port: 27018 bindIp: 0.0.0.0 sharding: clusterRole: configsvr replication: replSetName: config [root@im-04 conf]# cat mongos.conf systemLog: destination: file logAppend: true path: /data05/mongodb/logs/mongos.log processManagement: fork: true pidFilePath: /data05/mongodb/mongos/mongos.pid net: port: 27017 bindIp: 0.0.0.0 sharding: configDB: config/172.16.0.151:27018,172.16.0.173:27018,172.16.0.220:27018 5.创建mongodb启动用户 groupadd mongod useradd -g mongod mongod 6.配置mongodb目录权限 chown -R mongod:mongod /data/mongodb 7.启动 /data/mongodb/bin/mongod -f /data/mongodb/conf/configsvr.conf /data/mongodb/bin/mongod -f /data/mongodb/conf/shard1.conf /data/mongodb/bin/mongod -f /data/mongodb/conf/shard2.conf /data/mongodb/bin/mongod -f /data/mongodb/conf/shard3.conf /data/mongodb/bin/mongos -f /data/mongodb/conf/mongos.conf 8.登录任意一台配置服务器,初始化配置副本集 #连接 mongo 172.16.0.151 --port 27018 初始化configServer副本集 rs.initiate( { _id: "config", configsvr: true, members: [ { _id : 0, host : "172.16.0.151:27018" }, { _id : 1, host : "172.16.0.173:27018" }, { _id : 2, host : "172.16.0.220:27018" } ] } ) 查看节点状态 rs.status() 启动三台服务器的shard1 server /data/mongodb/bin/mongod -f /data/mongodb/conf/shard1.conf mongo 172.16.0.151 --port 27020 rs.initiate( { _id: "shard2", members: [ { _id : 0, host : "172.16.0.151:27020" }, { _id : 1, host : "172.16.0.173:27020" }, { _id : 2, host : "172.16.0.220:27020" } ] } ) mongo 172.16.0.173 --port 27021 rs.initiate( { _id: "shard3", members: [ { _id : 0, host : "172.16.0.173:27021" }, { _id : 1, host : "172.16.0.151:27021" }, { _id : 2, host : "172.16.0.220:27021" } ] } ) 9、启用分片 mongo 172.16.0.220 --port 27017 sh.addShard( "shard1/172.16.0.151:27019,172.16.0.173:27019,172.16.0.220:27019") sh.addShard( "shard2/172.16.0.151:27020,172.16.0.173:27020,172.16.0.220:27020") sh.addShard( "shard3/172.16.0.151:27021,172.16.0.173:27021,172.16.0.220:27021") 这个命令可以查看MongoDB的内存限制情况,查看结果如下: SECONDARY> db.hostInfo() wiredTiger: engineConfig: configString : cache_size=500M
标签:部署,mongodb,true,集群,mongos,conf,172.16,data From: https://www.cnblogs.com/zxqblogrecord/p/16665210.html