欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

docker安装mangoDB

发布时间:2023/12/10 编程问答 43 豆豆
生活随笔 收集整理的这篇文章主要介绍了 docker安装mangoDB 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

1、docker search mongo 查找镜像

docker search mongo [root@izbp13y6uttfs3mmgejd5mz ~]# docker search mongo NAME DESCRIPTION STARS OFFICIAL AUTOMATED mongo MongoDB document databases provide high avai… 8123 [OK] mongo-express Web-based MongoDB admin interface, written w… 1037 [OK] tutum/mongodb MongoDB Docker image – listens in port 27017230 [OK] mongoclient/mongoclient Official docker image for Mongoclient, featu… 105 [OK] mongooseim/mongooseim Small docker image for MongooseIM - robust a… 20 cvallance/mongo-k8s-sidecar Kubernetes side car to setup and maintain a … 20 [OK] frodenas/mongodb A Docker Image for MongoDB 19 [OK] arm64v8/mongo MongoDB document databases provide high avai… 15 webhippie/mongodb Docker images for MongoDB 10 [OK] centos/mongodb-32-centos7 MongoDB NoSQL database server 9 istepanov/mongodump Docker image with mongodump running as a cro… 8 [OK] centos/mongodb-36-centos7 MongoDB NoSQL database server 7 centos/mongodb-26-centos7 MongoDB NoSQL database server 5 requilence/mongodb-backup mongo backup container 5 [OK] eses/mongodb_exporter mongodb exporter for prometheus 5 [OK] neowaylabs/mongodb-mms-agent This Docker image with MongoDB Monitoring Ag… 4 [OK] centos/mongodb-34-centos7 MongoDB NoSQL database server 3 andreasleicher/mongo-azure-backup a docker container to backup a mongodb using… 2 [OK] openshift/mongodb-24-centos7 DEPRECATED: A Centos7 based MongoDB v2.4 ima… 1 ekesken/mongo docker image for mongo that is configurable … 1 [OK] ansibleplaybookbundle/mongodb-apb An APB to deploy MongoDB. 1 [OK] ccitest/mongo CircleCI test images for Mongo 0 [OK] phenompeople/mongodb MongoDB is an open-source, document databas… 0 [OK] martel/mongo-replica-ctrl A dockerized controller for a Mongo db repli… 0 [OK] amd64/mongo MongoDB document databases provide high avai… 0

2、拉取mango的镜像

docker pull mongo [root@izbp13y6uttfs3mmgejd5mz ~]# docker pull mongo Using default tag: latest latest: Pulling from library/mongo 35807b77a593: Pull complete 664b0ebdcc07: Pull complete d598f4d3c081: Pull complete 291455135b00: Pull complete b46409342f13: Pull complete ff2b9c6e6f3a: Pull complete 149f6335fc27: Pull complete baeb6f3bec76: Pull complete 8617caab2de5: Pull complete 067d70de7828: Pull complete Digest: sha256:58ea1bc09f269a9b85b7e1fae83b7505952aaa521afaaca4131f558955743842 Status: Downloaded newer image for mongo:latest docker.io/library/mongo:latest

3、运行docker镜像

docker run --name mongodb -p 27017:27017 -v $PWD/db:/data/db -d mongo:latest [root@izbp13y6uttfs3mmgejd5mz ~]# docker run --name mongodb -p 27017:27017 -v $PWD/db:/data/db -d mongo:latest f0387b871a89f9cfc1a8d13b4a362d3bed9c54f279e449497b3e765938e0712e

4、进入docker容器

docker exec -it mongodb mongo admin [root@izbp13y6uttfs3mmgejd5mz ~]# docker exec -it mongodb mongo admin MongoDB shell version v5.0.2 connecting to: mongodb://127.0.0.1:27017/admin?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("9b1d3c17-b039-49ad-9425-5b23a30101f9") } MongoDB server version: 5.0.2 ================ Warning: the "mongo" shell has been superseded by "mongosh", which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in an upcoming release. We recommend you begin using "mongosh". For installation instructions, see https://docs.mongodb.com/mongodb-shell/install/ ================ Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, seehttps://docs.mongodb.com/ Questions? Try the MongoDB Developer Community Forumshttps://community.mongodb.com --- The server generated these startup warnings when booting: 2021-09-11T08:58:15.092+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem2021-09-11T08:58:15.552+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted2021-09-11T08:58:15.552+00:00: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never'2021-09-11T08:58:15.552+00:00: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never' --- ---Enable MongoDB's free cloud-based monitoring service, which will then receive and displaymetrics 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 youand anyone you share the URL with. MongoDB may use this information to make productimprovements 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() --- >

5、创建mangodb管理员账户

db.createUser({ user: 'admin', pwd: 'syh&cmx******', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] }); > db.createUser({ user: 'admin', pwd: 'syh&cmx********', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] }); Successfully added user: {"user" : "admin","roles" : [{"role" : "userAdminAnyDatabase","db" : "admin"}] }

6、对 admin 用户 进行身份认证

db.auth("admin","syh&cmx********") > db.auth("admin","syh&cmx********"); 1

7、创建普通的数据管理用户

db.createUser({ user: 'sunyuhua', pwd: 'syh&cmx********', roles: [ { role: "readWrite", db: "app" } ] }); > db.createUser({ user: 'sunyuhua', pwd: 'syh&cmx********', roles: [ { role: "readWrite", db: "app" } ] }); Successfully added user: {"user" : "sunyuhua","roles" : [{"role" : "readWrite","db" : "app"}] }

8、对普通用户进行身份验证

db.auth("sunyuhua","syh&cmx1314"); > db.auth("sunyuhua","syh&cmx1314"); 1

9、使用创建的app数据库进行验证

> use app; > db.test.save({name:"sunyhua"}) > db.test.find(); > use app; switched to db app > db.test.save({name:"sunyhua"}) WriteResult({ "nInserted" : 1 }) > db.test.find(); { "_id" : ObjectId("613c7060f832314229fba0dd"), "name" : "sunyhua" } > show collections; test >

10、阿里云机器安全组添加27017的端口

11、下载一个可视化管理mangodb的工具

robo3t

12、安装后查看,测试数据

总结

以上是生活随笔为你收集整理的docker安装mangoDB的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。