images\cherry_red.png1 Docker的学习-gaogaoTwo
      images\cherry_blue.png1.1 docker常见问题故障
         images\cherry_orange.png1.1.1 docker容器无法远程连接MySQL
      images\cherry_blue.png1.2 Docker基础命令
         images\cherry_orange.png1.2.1 docker logs
         images\cherry_orange.png1.2.2 镜像构建优化
         images\cherry_orange.png1.2.3 network
         images\cherry_orange.png1.2.4 内部安装应用命令
         images\cherry_orange.png1.2.5 docker ps
      images\cherry_blue.png1.3 Docker网络模式
      images\cherry_blue.png1.4 docker compose
         images\cherry_orange.png1.4.1 docker-compose安装
      images\cherry_blue.png1.5 部署Tomcat 运行环境
      images\cherry_blue.png1.6 docker(compose) LNMP环境的部署
      images\cherry_blue.png1.7 docker 搭建部署Redis集群
      images\cherry_blue.png1.8 docker 搭建部署MongoDB集群
         images\cherry_orange.png1.8.1 MongoDB(configsvr)配置服务器
         images\cherry_orange.png1.8.2 MongoDB(shared) 分片初始化操作
         images\cherry_orange.png1.8.3 配置MongoDB(Mongos)路由服务器
         images\cherry_orange.png1.8.4 MongoDB测试集群可用性
      images\cherry_blue.png1.9 docker 搭建部署MySQL主从复用
      images\cherry_blue.png1.10 docker+Keepalived+Nginx高可用
      images\cherry_blue.png1.11 docker+Ansible多节点集群管理
      images\cherry_blue.png1.12 docker(compose)+Zabbix 多节点监控服务
      images\cherry_blue.png1.13 docker 部署文件目录下载
      images\cherry_blue.png1.14 docker
         images\cherry_orange.png1.14.1 docker镜像管理
         images\cherry_orange.png1.14.2 docker容器
         images\cherry_orange.png1.14.3 docker容器高级操作
配置Mongos (3台)路由服务器

mongos 路由服务器
172.17.140.41:27017
172.17.140.42:27017
172.17.140.43:27017

三台主机都需要添加配置文件

# mkdir /data/mongod/conf/mongos -p

# vim /data/mongod/conf/mongos/mongod.conf
net:
  bindIpAll: true

sharding: 
   configDB: rs_configsvr/172.17.140.41:9001,172.17.140.42:9001,172.17.140.43:9001   # 定义为mongos配置服务器


mongos 部署
1、分片路由部署,三台均执行相同操作
docker run --name mongos -d \
  -p 27017:27017 \
  --entrypoint "mongos" \
  -v /data/mongod/conf/keyfile/:/data/keyfile/ \
  -v /data/mongod/conf/mongos/:/data/conf/ \
  mongo:4.0.21 -f /data/conf/mongod.conf

# 进入mongos 容器中
# docker exec -it mongos bash
 
# 连接mongos
# mongo --host 127.0.0.1 --port 27017
# use admin

images\7-1.png


# 添加分片服务器
sh.addShard("rs_shardsvr1/172.17.140.41:9005,172.17.140.42:9005,172.17.140.43:9005")
images\7-2.png


sh.addShard("rs_shardsvr2/172.17.140.41:9006,172.17.140.42:9006,172.17.140.43:9006")
images\7-3.png


sh.addShard("rs_shardsvr3/172.17.140.41:9007,172.17.140.42:9007,172.17.140.43:9007")
images\7-4.png

sh.status() //查看状态
images\7-5.png