mongodb 的云数据库产品 atlas 的使用

前言:最近发现 mlab 被mongodb 收购以后,不再支持新用户,推荐使用 MongoDB Atlas

第一步:注册或登陆

在MongoDB atlas首页,如果有账号,那就点击登陆。否则点击Get Started here 来注册,注册页面都是必填项:

第二步:创建新的Cluster

登陆之后,如果尚未创建任何Cluster,那么会提示创建一个新的Cluster,如下所示:

注意 只有M0是免费的,这个里面很多选项都是针对M0以上的,不过M0对于学习也足够了。下面是M0可以设置的选项:

Cloud Provider & Region:集群部署的位置

选一个亚洲节点好了。

Cluster Tier:服务套餐

当然是M0啦,共享内存 CPU,512M存储也够了,M0包含一个3个节点组成的replica set。

Additional settings 设置,不过M0没有啥可以设置的

可以看到,默认是WT引擎,这也表明,MongoDB官方在慢慢放弃Mmapv1存储引擎,大多数新的feature都支持WT引擎。

Cluster Name: 集群的名字

点击Create Cluster 开始创建(可能还需要人机校验)

第三步: 创建用户,设置白名单

创建新的Cluster需要几分钟时间,在这个等待时间内,可以按提示创建user和设置白名单:

为了方便访问,白名单IP就设置为0.0.0.0好了

回到overview界面,集群创建好了,有一些基本的监控:Operation、 Connections、Logical Size

第四步: 连接试用Cluster

集群是有了,那怎么连接使用呢,最左边有很多按钮,可以每个点点看看。doc 是 atlas文档的链接, support里面有文档介绍如何链接cluster。

可以用mongoshell,也可以用mongo driver连接。这里用Mongo shell试试

step4.1:获取连接URL

在clusters这个view点击 CONNECT按钮,出现如下

点击第一个,然后会提示,没有mongodb3.6的话就得装一个

我本地有mongod3.6 那么点击第二项,这样会给出一个链接的url

step4.2: 用Mongoshell 连接

使用mongo shell连接。mongo "mongodb+srv://free-yc5um.mongodb.net/test" --username try

如下所示:

mongo "mongodb+srv://free-yc5um.mongodb.net/test" --username try
MongoDB shell version v3.6.6
Enter password:
connecting to: mongodb+srv://free-yc5um.mongodb.net/test
2018-08-10T13:51:29.072+0800 I NETWORK  [thread1] Starting new replica set monitor for free-shard-0/free-shard-00-00-yc5um.mongodb.net.:27017,free-shard-00-01-yc5um.mongodb.net.:27017,free-shard-00-02-yc5um.mongodb.net.:27017
2018-08-10T13:51:30.389+0800 I NETWORK  [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to free-shard-00-02-yc5um.mongodb.net.:27017 (1 connections now open to free-shard-00-02-yc5um.mongodb.net.:27017 with a 5 second timeout)
2018-08-10T13:51:30.594+0800 I NETWORK  [thread1] Successfully connected to free-shard-00-00-yc5um.mongodb.net.:27017 (1 connections now open to free-shard-00-00-yc5um.mongodb.net.:27017 with a 5 second timeout)
2018-08-10T13:51:30.811+0800 I NETWORK  [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to free-shard-00-01-yc5um.mongodb.net:27017 (1 connections now open to free-shard-00-01-yc5um.mongodb.net:27017 with a 5 second timeout)
2018-08-10T13:51:30.890+0800 I NETWORK  [ReplicaSetMonitor-TaskExecutor-0] changing hosts to free-shard-0/free-shard-00-00-yc5um.mongodb.net:27017,free-shard-00-01-yc5um.mongodb.net:27017,free-shard-00-02-yc5um.mongodb.net:27017 from free-shard-0/free-shard-00-00-yc5um.mongodb.net.:27017,free-shard-00-01-yc5um.mongodb.net.:27017,free-shard-00-02-yc5um.mongodb.net.:27017
2018-08-10T13:51:30.995+0800 I NETWORK  [thread1] Successfully connected to free-shard-00-01-yc5um.mongodb.net.:27017 (1 connections now open to free-shard-00-01-yc5um.mongodb.net.:27017 with a 5 second timeout)
2018-08-10T13:51:31.191+0800 I NETWORK  [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to free-shard-00-02-yc5um.mongodb.net:27017 (1 connections now open to free-shard-00-02-yc5um.mongodb.net:27017 with a 5 second timeout)
2018-08-10T13:51:31.395+0800 I NETWORK  [thread1] Successfully connected to free-shard-00-00-yc5um.mongodb.net:27017 (1 connections now open to free-shard-00-00-yc5um.mongodb.net:27017 with a 5 second timeout)
MongoDB server version: 3.6.6
MongoDB Enterprise free-shard-0:PRIMARY> show dbs
admin  0.000GB
local  7.142GB

回到MongoDB Atlas管理界面,可以看到,已经有连接了

至此,就可以免费试用MongoDB3.6了。

转自:https://www.cnblogs.com/xybaby/p/9460634.html

.

原文地址:https://www.cnblogs.com/crazycode2/p/11094651.html