首页 技术 正文
技术 2022年11月13日
0 收藏 311 点赞 2,710 浏览 1904 个字

本文演示:(一个主服务器,一个备份服务器,三个仲裁服务器)

官方推荐副本集的成员数量为奇数,最多12个副本集节点,最多7个节点参与选举。

本文演示基于本机,用端口区分服务(每个服务器下新建db文件夹用于存储数据,mongodb.conf文件配置启动参数)

各个服务器配置文件内容如下:

27000主服务器

dbpath=D:\MongoDB\Server27000\3.2\db

port=27000

replSet=datamip/127.0.0.1:27001

//副本集下面有其他服务器27001

27001备份服务器

dbpath=D:\MongoDB\Server27001\3.2\db

port=27001

replSet=datamip/127.0.0.1:27000

//主服务器

27002仲裁服务器

dbpath=D:\MongoDB\Server27002\3.2\db

port=27002

replSet=datamip/127.0.0.1:27001

//主服务器

27003仲裁服务器

dbpath=D:\MongoDB\Server27003\3.2\db

port=27003

replSet=datamip/127.0.0.1:27001

//主服务器

27004仲裁服务器

dbpath=D:\MongoDB\Server27004\3.2\db

port=27004

replSet=datamip/127.0.0.1:27001

//主服务器

27000主服务器27001备份服务器27002仲裁服务器27003仲裁服务器27004仲裁服务器创建服务sc.exe create MongoDB27000 binPath= “C:\MongoDB\Server27000\bin\mongod.exe –service –config=\”C:\MongoDB\Server27000\mongodb.conf”” DisplayName= “MongoDB27000” start= “auto”sc.exe create MongoDB27001 binPath= “C:\MongoDB\Server27001\bin\mongod.exe –service –config=\”C:\MongoDB\Server27001\mongodb.conf”” DisplayName= “MongoDB27001” start= “auto”sc.exe create MongoDB27002 binPath= “C:\MongoDB\Server27002\bin\mongod.exe –service –config=\”C:\MongoDB\Server27002\mongodb.conf”” DisplayName= “MongoDB27002” start= “auto”sc.exe create MongoDB27003 binPath= “C:\MongoDB\Server27003\bin\mongod.exe –service –config=\”C:\MongoDB\Server27003\mongodb.conf”” DisplayName= “MongoDB27003” start= “auto”sc.exe create MongoDB27004 binPath= “C:\MongoDB\Server27004\bin\mongod.exe –service –config=\”C:\MongoDB\Server27004\mongodb.conf”” DisplayName= “MongoDB27004” start= “auto”启动服务>mongo 192.168.200.111:27000/admin//连接primary>db.runCommand({“replSetInitiate”:{“_id”:”datamip”,”members”:[{“_id”:1,”host”:”192.168.200.111:27000″},{“_id”:2,”host”:”192.168.200.111:27001″}]}}) 稍等片刻,等待27000变为primary时添加如下配置>mongo 192.168.200.111:27000/admin>rs.addArb(“192.168.200.111:27002”)>rs.addArb(“192.168.200.11127003”)>rs.addArb(“192.168.200.111:27004”)

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,117
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,589
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,435
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,206
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,842
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,927