副本: 副本集集群基础配置

环境介绍

系统版本

服务器ip地址

MongoDB版本

端口号

CentOS Linux release 7.6.1810 (Core)

192.168.0.92

mongodb-linux-x86_64-rhel62-3.6.5.tgz

27017

CentOS Linux release 7.6.1810 (Core)

192.168.0.93

mongodb-linux-x86_64-rhel62-3.6.5.tgz

27017

CentOS Linux release 7.6.1810 (Core)

192.168.0.94

mongodb-linux-x86_64-rhel62-3.6.5.tgz

27017

正式开始

本实践其中有使用ansible工具便于快速部署。

1、安装MongoDB

$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.22.tgz
$ ansible -i inventory mongocluster -m copy -a 'src=/Users/jinxiaozhang/mongodb-linux-x86_64-rhel62-3.6.5.tgz dest=/usr/local/'
$ ansible -i inventory mongocluster -m shell -a 'tar zxvf /usr/local/mongodb-linux-x86_64-rhel62-3.6.5.tgz -C /usr/local/

2、创建我们所需要的目录

$ ansible -i inventory mongocluster -m shell -a 'mkdir /usr/local/mongodb-linux-x86_64-rhel70-3.2.22/data' 
$ ansible -i inventory mongocluster -m shell -a 'mkdir /usr/local/mongodb-linux-x86_64-rhel70-3.2.22/shard1' 
$ ansible -i inventory mongocluster -m shell -a 'mkdir /usr/local/mongodb-linux-x86_64-rhel70-3.2.22/logs' 
$ ansible -i inventory mongocluster -m shell -a 'mkdir /usr/local/mongodb-linux-x86_64-rhel70-3.2.22/config' 
$ ansible -i inventory mongocluster -m shell -a 'mkdir /usr/local/mongodb-linux-x86_64-rhel70-3.2.22/key'

3、创建配置文件

4、启动服务

5、初始化副本集群

6、向副本集群添加节点成员

7、查看副本集群状态

Last updated

Was this helpful?