docker安装mangoDB
生活随笔
收集整理的這篇文章主要介紹了
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 27017… 230 [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… 02、拉取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:latest3、運行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 f0387b871a89f9cfc1a8d13b4a362d3bed9c54f279e449497b3e765938e0712e4、進入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********"); 17、創建普通的數據管理用戶
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"); 19、使用創建的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的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [Leedcode][JAVA][第15
- 下一篇: 基于OpenCV与MFC的人脸识别