Mongodb 集群实战

  该实战过程完全跟着官网一步一步实现 ,官网教程:https://docs.mongodb.com/manual/tutorial/atlas-free-tier-setup/

  使用Mongo Shell连接Cluster

  1. 官网登录,创建免费集群 (补:只能免费一个月,而且有各种限制) ,点击 Build  a New Cluster  按钮,下面是我成功创建Cluster的图。

  2. 设置Mongodb User , 和 IP 白名单,注意IP白名单不是自己网络IP。了解: https://www.imooc.com/qadetail/249703?lastmedia=1





  3. 点击Connect
  4. 选择连接方法,下载对应的连接客户端,此处选择Shell

  5. 下载对应的客户端
  6. 设置环境变量至bin文件夹,不设也ok,但是到时运行程序要在对应路径下运行。
  7. copy 下载命令

  8. 打开cmd窗口 , 连接


    连接成功~ 至于警告,问了问客服回答如下:

    Hi bibi thank you for getting in touch and sending the screenshot.
    The messages displayed in the screenshot can be treated a warnings.
    The warning message that says 'shell and versions do not match' is displayed as you appear to have downloaded version 4.0 of MongoDB (you can see this at the top of the screenshot) and version 3.6.6 of MongoDB Atlas. Rest assured that this is just a notification and version 4.0 of MongoDB and version 3.6.6 of MongoDB Atlas are compatible.
    The message 'user is  not allowed to do action [getlog] on [admin]' appears when you have a free tier (M0) Instance of MongoDB Atlas. The free tier (M0), M2 and M5 Instances have some limitations and command limitations, including limited metrics for analysis. In spite of receiving this message, you should still be able to perform MongoDB CRUD Operations in the shell.
    For example, you can list your database there by entering;
    show dbs
    and create a new database, called test, by entering;
    use test
    You may also find the following MongoDB Atlas article helpful;

    客服态度超级棒!

  9. 操作数据库
    例如:
    MongoDB Enterprise Cluster0-shard-0:PRIMARY> use myNewDB
    switched to db myNewDB
    MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.myNewCollection1.insertOne({x:1})
    {
            "acknowledged" : true,
            "insertedId" : ObjectId("5b63d28b15b047a6f9a9d004")
    }
    MongoDB Enterprise Cluster0-shard-0:PRIMARY>
    

     
    后台看看集合变化

     

 

posted @ 2018-08-03 12:21  舒碧  阅读(845)  评论(0编辑  收藏  举报