【MongoDB 高可用篇】MongoDB 副本集添加新成员

目录

1 软件环境

2 新增副本集成员

2.1 创建新成员mongod实例

2.2 启动新成员

2.3 连接到主库

2.4 增加新成员

2.5 查看副本集状态

2.6 重新配置新成员

2.7 查看最新配置


副本集(replica set)是一组mongod进程维护的相同的数据集,提供了MongoDB的冗余和高可用,本篇将对向现有副本集环境中如何增加新成员进行演示。

1 软件环境

使用的软件分别为:

  • VirtualBox 6.0
  • Oracle Linux 6.7
  • MongoDB 4.2.0

2 新增副本集成员

2.1 创建新成员mongod实例

参照:安装MongoDB单实例

2.2 启动新成员

[mongod@sec02 ~]$ mongod -f /u01/data/conf/mongod.cnf
about to fork child process, waiting until server is ready for connections.
forked process: 3156
child process started successfully, parent exiting

2.3 连接到主库

[mongod@sec conf]$ mongo localhost:27017/admin -uroot -p
MongoDB shell version v4.2.0
Enter password:
connecting to: mongodb://localhost:27017/admin?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("94500bee-57dc-4b9a-9da7-63760d8093dd") }
MongoDB server version: 4.2.0
Server has startup warnings:
2019-10-02T20:45:51.262+0800 I STORAGE [initandlisten]
2019-10-02T20:45:51.262+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-10-02T20:45:51.262+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
rep1:PRIMARY>
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值