当前位置:网站首页>MongoDB搭建副本集集群
MongoDB搭建副本集集群
2022-06-09 03:26:00 【7258281014】
一、mongo下载安装
将压缩包上传至linux服务器,解压并创建软链接。
下载社区版地址:https://www.mongodb.com/try/download/community
tar -zxvf mongodb-linux-x86_64-rhel70-4.4.14-rc0.tgz
ln -s mongodb-linux-x86_64-rhel70-4.4.14-rc0 mongodb
二、配置准备
1.进入mongodb目录下创建文件夹
mkdir data log conf
2.上面1完成后进入conf目录创建文件夹,分别存放主节点、从节点、仲裁节点的配置文件。
mkdir master slave arbiter
主节点配置文件 conf/master/mongod.cfg
systemLog:
destination: file
path: "/opt/software/mongodb/log/master.log"
logAppend: true
storage:
dbPath: /opt/software/mongodb/data/master
journal:
enabled: true
net:
bindIp: 0.0.0.0
port: 27000
setParameter:
enableLocalhostAuthBypass: false
replication:
replSetName: "rs"
从节点配置文件 conf/slave/mongod.cfg
systemLog:
destination: file
path: "/opt/software/mongodb/log/slave.log"
logAppend: true
storage:
dbPath: /opt/software/mongodb/data/slave
journal:
enabled: true
net:
bindIp: 0.0.0.0
port: 27001
setParameter:
enableLocalhostAuthBypass: false
replication:
replSetName: "rs"
仲裁节点配置文件 conf/arbiter/mongod.cfg
systemLog:
destination: file
path: "/opt/software/mongodb/log/arbiter.log"
logAppend: true
storage:
dbPath: /opt/software/mongodb/data/arbiter
journal:
enabled: true
net:
bindIp: 0.0.0.0
port: 27002
setParameter:
enableLocalhostAuthBypass: false
replication:
replSetName: "rs"
3.上面1完成后进入data目录创建文件夹,分别存放主节点、从节点、仲裁节点的数据。
mkdir master slave arbiter
三、启动集群
执行启动脚本 mongodb_rs.sh
MONGODB_HOME=/opt/software/mongodb
${MONGODB_HOME}/bin/mongod -f ${MONGODB_HOME}/conf/master/mongod.cfg &
${MONGODB_HOME}/bin/mongod -f ${MONGODB_HOME}/conf/slave/mongod.cfg &
${MONGODB_HOME}/bin/mongod -f ${MONGODB_HOME}/conf/arbiter/mongod.cfg &
进入mongo
mongo -port 27000
依次执行以下操作
config = {
"_id":"rs",
"members":[
{"_id":0,"host":"本机ip:27000"},
{"_id":1,"host":"本机ip:27001"},
{"_id":2,"host":"本机ip:27002",arbiterOnly:true}
]
}
rs.initiate(config)
执行命令查看集群状态
rs.status()


至此MongoDB副本集集群搭建完成
附:MongoDB单机版搭建
文章仅供学习交流,侵权联系删除。
边栏推荐
- 故障分析 | 大量短时进程导致 cpu 负载过高案例一则
- Spark - logging simple to use
- 洛谷P3647 [APIO2014] 连珠线 题解
- Ccf-csp 201903-1 small, medium and large
- Leetcode 1185. Day of the week
- Ccf-csp 202012-5 Star Trek 80 points
- Binding mode of QT overloaded signal slot function
- oracle 连接PLSQL
- Boringssl compilation and testing
- The easynvr hardware of the video edge computing gateway always reports an error when it is started in the service mode. How to troubleshoot and solve it?
猜你喜欢

About JS console Log() is a problem caused by synchronous or asynchronous

关于我的那些事【我的2022】

Leetcode 1185. Day of the week

Ccp-csp 201909-3 character drawing 100

The difference between single chip and chip

Tree storage structure -- three different tree representations

SIG live broadcast of system operation and maintenance: libbpf compilation platform LCC - ebpf from getting started to enjoying | issue 20
![[detailed explanation of kubernetes 13] - dashboard deployment](/img/81/d4567d0ff0e4509ace3d62cb16bdcc.png)
[detailed explanation of kubernetes 13] - dashboard deployment
![[reinforcement learning notes] V value and Q value in reinforcement learning](/img/8a/c6143a8d6c0bc2c42a608acb019d95.png)
[reinforcement learning notes] V value and Q value in reinforcement learning

神经网络学习(六)----深度学习与机器学习的关系理解
随机推荐
Linux 安装Mysql 详细教程(图文教程)
Fault analysis - a case of excessive CPU load caused by a large number of short-time processes
Ccf-csp 202104-1 gray histogram 100 points
Research on MySQL open source license
Ccf-csp 202012-5 Star Trek 80 points
Ccf-csp 202112-3 boarding pass bar code 100 points
What does the seven layer network structure do?
Shocked, you can't debug remotely
并发操作之——ReentrantReadWriteLock
RTSP/Onvif协议视频平台EasyNVR如何配置用户的视频流播放时长?
现在VB6.0已经和SQL连接了,但是使用查询功能时无法做到任意条件查询,网上的情况和我的也不太相符,请问该如何实现呢?
No cached version available for offline mode
InfoQ geek media's 15th anniversary solicitation | one minute Automated Deployment Based on ECs [elastic ECS]
Use of rich text boxes
[detailed explanation of kubernetes 13] - dashboard deployment
[reinforcement learning notes] V value and Q value in reinforcement learning
神经网络学习(六)----深度学习与机器学习的关系理解
技术分享 | 调整 max-write-buffer-size 优化 pika 性能10倍的案例
Binding mode of QT overloaded signal slot function
What is the network transformer for? (Ethernet network LAN LAN communication isolation filter) production plant / product schematic diagram / common products / price influencing factors