[MongoDB] CentOS7安装MongoDB

青旅半醒 2022-05-12 05:50 355阅读 0赞

CentOS7安装MongoDB

  1. [root@vm ~]# yum install -y mongodb-org
  2. [root@vm ~]# systemctl start mongod
  3. [root@vm ~]# systemctl is-active mongod
  4. [root@vm ~]# netstat -nltp | grep 27017
  5. [root@vm ~]# mongo
  6. MongoDB shell version v4.0.2
  7. connecting to: mongodb://127.0.0.1:27017
  8. MongoDB server version: 4.0.2
  9. Welcome to the MongoDB shell.
  10. For interactive help, type "help".
  11. For more comprehensive documentation, see
  12. http://docs.mongodb.org/
  13. Questions? Try the support group
  14. http://groups.google.com/group/mongodb-user
  15. Server has startup warnings:
  16. 2018-09-14T21:03:59.333+0800 I STORAGE [initandlisten]
  17. 2018-09-14T21:03:59.333+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
  18. 2018-09-14T21:03:59.333+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
  19. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten]
  20. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
  21. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
  22. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten]
  23. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten]
  24. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
  25. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
  26. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten]
  27. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
  28. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
  29. 2018-09-14T21:04:02.032+0800 I CONTROL [initandlisten]
  30. ---
  31. Enable MongoDB's free cloud-based monitoring service, which will then receive and display
  32. metrics about your deployment (disk utilization, CPU, operation statistics, etc).
  33. The monitoring data will be available on a MongoDB website with a unique URL accessible to you
  34. and anyone you share the URL with. MongoDB may use this information to make product
  35. improvements and to suggest MongoDB products and deployment options to you.
  36. To enable free monitoring, run the following command: db.enableFreeMonitoring()
  37. To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
  38. ---
  39. > show databases;
  40. admin 0.000GB
  41. config 0.000GB
  42. local 0.000GB
  43. >

使用

  1. > use test
  2. switched to db test
  3. > db
  4. test
  5. > show dbs
  6. admin 0.000GB
  7. config 0.000GB
  8. local 0.000GB
  9. > db.test.insert({"name":"cindy"})
  10. WriteResult({ "nInserted" : 1 })
  11. > show dbs
  12. admin 0.000GB
  13. config 0.000GB
  14. local 0.000GB
  15. test 0.000GB
  16. > db.test.find()
  17. { "_id" : ObjectId("5b9bb43e63d77f5bb9465cb2"), "name" : "cindy" }
  18. >

发表评论

表情:
评论列表 (有 0 条评论,355人围观)

还没有评论,来说两句吧...

相关阅读