windows下MongoDB4.0的副本集搭建

复制三个MongoDB Server,一个为主节点Primary ,一个为辅节点Secondary,另一个为仲裁节点Arbiter

以无认证方式启动三个Server节点

server1> mongod --noauth --config mongod.cfg   
server2> mongod --noauth --config mongod.cfg
server3> mongod --noauth --config mongod.cfg

//server1 mongod.cfg
net: port: 27017 bindIp: 0.0.0.0
replication: oplogSizeMB: 200 replSetName: replset

//server2 mongod.cfg net: port: 27018 bindIp: 0.0.0.0
replication: oplogSizeMB: 200 replSetName: replset

//server3 mongod.cfg net: port: 27019 bindIp: 0.0.0.0
replication: oplogSizeMB: 200 replSetName: replset

连接server1

> mongo
> rs.initiate(); //初始化副本集设置
> rs.add('mg.imily.net:27018'); //添加server2
> rs.addArb('mg.imily.net:27019'); //添加server3
> cfg = rs.conf();
> cfg.members[0].priority = 100; //设置server1优先级
> cfg.members[1].priority = 50; //设置server2优先级
> rs.reconfig(cfg); //重新配置副本集信息

按照上一篇方式创建帐号密码后,接着需要创建节点之间的认证keyfile,用来在各节点之间的认证。

> openssl.exe rand 128 -base64 -out ./keyfile
//附下载: openssl.zip

//创建后复制到server1,server2,server3的bin目录中,并在三个mongod.cfg中添加 security: authorization: enabled keyFile: keyfile

最后添加server1,server2,server3作为系统服务,启动即可

显示更多

379 thoughts on “windows下MongoDB4.0的副本集搭建

  1. I have been browsing on-line more than three hours as of late, but I by no means discovered any fascinating article like
    yours. It is beautiful worth sufficient for me.
    In my view, if all site owners and bloggers made good content as
    you probably did, the internet can be much more helpful than ever
    before.

  2. Its such as you read my mind! You appear to
    understand a lot approximately this, such as you wrote the ebook
    in it or something. I feel that you simply could do with a few percent to power
    the message home a bit, however instead of that,
    this is excellent blog. A fantastic read. I will certainly be
    back.

  3. Howdy just wanted to give you a quick heads up. The text in your content
    seem to be running off the screen in Internet explorer.
    I’m not sure if this is a format issue or something to do with browser compatibility but I figured I’d post to let
    you know. The design and style look great though!
    Hope you get the problem resolved soon. Thanks

  4. I’ve been surfing online more than 4 hours today, yet I never found any interesting article
    like yours. It’s pretty worth enough for me.

    In my opinion, if all site owners and bloggers made good content as you did, the net will be a lot more useful
    than ever before.

发表评论

电子邮件地址不会被公开。 必填项已用*标注