- 由于MongoDb的事务只能在集群模式下才可用,查看了资料和官方文档后,进行了Docker环境下的伪集群部署。以下为部署过程
- 版本:
MongoDb:
使用Docker进行部署
root@119ce58d3c1f:/# mongo
MongoDB shell version v4.4.5
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session {
"id" : UUID("c278fd96-dbe5-44bc-a608-3a0bb3307b3d") }
MongoDB server version: 4.4.5
- 用Docker安装MongoDb:
安装命令:
docker run -p 27017:27017 -v /home/mongodb/data/db:/data/db -v /home/mongodb/config/mongod.conf:/etc/mongo/mongod.conf --name mongodb -d mongo:4.4.5 --config /etc/mongo/mongod.conf
配置文件:mongod.conf:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /data/db
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
# bindIp: 127.0.0.1
bindIpAll: true
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
# authorization: enabled
# keyFile: /etc/mongo/keyFilers0.key
#operationProfiling