mongodb 字符串转bson_大数据存储技术选型(六)--Mongodb专题介绍

b1ad35e87754c8fc9f0bcf94b0978e28.png

之前我曾有过一次mongodb的介绍,但那是年少无知,对mongo认识得不够充分,所以当时那篇专题介绍只是介绍了一个大概的轮廓就草草敷衍了事了。对此我做了深刻的反省与自我批评。接下来,今天就mongo的深度探索将在下面的时间里倾情为大家呈现。


MongoDB的基本概念

一、MongoDB基本概念与关系数据的对应关系

c1e28f0dca26747d6c239e0e23dd1727.png
MongoDB基本概念与关系数据的对应关系

二、MongoDB的数据层次结构

文档(Documents),集合( Collections), 和数据库( Databases)三层
§文档存储在集合中
§集合存储在数据库中
§例如:
•数据库(Database): products
•集合(Collections): books, movies, music
§数据库和集合的组合,构成MongoDB的命名空间
•products.books
•products.movies
•products.music
*数据库名最长不能超过64个字节,命名空间最长不能超过120字节

三、MongoDB的数据结构

§MongoDB采用JSON文档结构

•JSON的全称:JavaScript Object Notation
•JSON的格式:支持如下数据格式
字符串 :e.g., “Thomas”
数字 :e.g., 29, 3.7)
布尔:true / false
空值:null
数组:e.g., [88.5, 91.3, 67.1]
对象:object
{
"firstname" : "Thomas",
"lastname" : "Smith",
"age" : 29
}

§MongoDB采用BSON格式保存数据

MongoDB使用了BSON这种结构来存储数据和网络数据交换。把这种格式转化成一文档这个概念(Document),因为BSON是schema-free的,所以在MongoDB中所对应的文档也有这个特征,这里的一个Document也可以理解成关系数据库中的一条记录(Record),只是这里的Document的变化更丰富一些,如Document可以嵌套。

MongoDB以BSON做为其存储结构的一种重要原因是其可遍历性。

四、MongoDB的功能定位

c21ce0b9af405e0cecb6f51980adc988.png

Memcache所指为内存数据库

RDBMS为关系型数据库

五、MongoDB部署模型

ca12d08b5ba072e57e9e98b29e2a12e7.png

在生产上部署mongodb数据库一般采取分片或主从的模式进行部署

六、MongoDB的备份与恢复

998210bc5eeb074a4ae3b4be4d3b5f33.png

时刻1

PRIMARY/SECONDRY处于相同的状态,总文档数相同,文档内容也相同,我们称之为状态A

时刻2

PRIMARY节点上插入了一个新文档,进入状态B

时刻3

SECONDARY上复制到新文档,进入状态B

最终一致性决定了SECONDARY上只会出现PRIMARY上出现过的状态

七、MongoDB的设计原则

•为性能优化,而不是空间

•为最重要场景优化,不求面面俱到

c3f021f5d3266a0106f62fa1d3075dd5.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
为什么会这样[user_mongo@nosql01 replicaset]$ cd /opt [user_mongo@nosql01 opt]$ ll total 0 drwxr-xr-x. 3 root root 25 Mar 16 17:08 servers drwxr-xr-x. 2 root root 51 Mar 16 17:10 software [user_mongo@nosql01 opt]$ tar -zxvf /opt/software/mongodb-linux-x86_64-rhel70-4.4.12.tgz -C /opt/servers/mongodb_demo/replicaset/ mongodb-linux-x86_64-rhel70-4.4.12/LICENSE-Community.txt tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/LICENSE-Community.txt: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/MPL-2 tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/MPL-2: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/README tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/README: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/THIRD-PARTY-NOTICES tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/THIRD-PARTY-NOTICES: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/bin/install_compass tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/bin/install_compass: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/bin/mongo tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/bin/mongo: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/bin/mongod tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/bin/mongod: Cannot open: No such file or directory mongodb-linux-x86_64-rhel70-4.4.12/bin/mongos tar: mongodb-linux-x86_64-rhel70-4.4.12: Cannot mkdir: Permission denied tar: mongodb-linux-x86_64-rhel70-4.4.12/bin/mongos: Cannot open: No such file or directory tar: Exiting with failure status due to previous errors [user_mongo@nosql01 opt]$ tar -zcvf /opt/software/mongodb-linux-x86_64-rhel70-4.4.12.tgz -C /opt/servers/mongodb_demo/replicaset/ tar: Cowardly refusing to create an empty archive Try `tar --help' or `tar --usage' for more information.
最新发布
06-01

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值