【运维】set模式

【运维】set模式

1. 搭建运行三个单节点

可以参考单节点搭建步骤:

配置文件使用如下:

dbpath=data
logpath=log/mongod.log
fork=true
bind_ip_all=true
logappend=true
auth=false
port=27017
oplogSize=1024
journal=true
replSet=univer

官方配置文件选项解释如下:

https://docs.mongodb.com/manual/reference/configuration-options/#configuration-file

2.6之后引入yaml格式,老格式依然向后兼容,使用yum安装生成的默认配置文件

2. 三个单节点的配置成replica set

2.1 定义配置集群信息

2.2 初始化rs集群

3. 验证

主节点插入数据,从节点查询数据

官方搭建步骤

  1. Start each member of the replica set with the appropriate options

  2. Connect a mongo shell to one of the mongod instances

  3. Initiate the replica set

  4. View the replica set configuration

  5. Ensure that the replica set has a primary

1. 启动每一个节点用合适的配置选项

和单节点配置项相比,主要是添加了replication.replSetName配置项

2. 连接一个mongo-shell到其中一个实例

3. 初始化副本集

4. 查看副本集配置

5. 查看集群状态

6. 验证数据

Last updated

Was this helpful?