mongodb之linux通用二进制包安装

MonfoDB是开源文档数据库,提供共性能、高可用、自动扩展等

MongoDB中记录是文档,其是字段和值组成的对结构。mongodb文档类似JSON对象,字段的值可以包含其它文档、数组、文档的数组。记录组织成collection,相当于表。参考下图:

使用文档的优点是:

文档对应很多编程语言的内生数据对象

内嵌文档和数组减少了join的开销

动态schema支持顺畅多态

关键功能:

高性能:

mongodb提供高性能数据持久。特别是:

支持内嵌数据模型减少了数据库系统的I/O

索引支持快速查询且内嵌文档和数组可以包含键

高可用:

mongodb提供高可用的是replica sets

自动失败切换

数据冗余

replica set是一组mongodb服务器,它们维护这同一个数据集,提供冗余,增加数据可用性。

自动水平扩展:

水平扩展是mongodb的内核功能。

在集群上自动共享分布式数据

replica sets能为低延迟,高吞吐量的应用提供最终一致性读。

安装:

0

环境

[[email protected] ~]# uname -a

Linux host2 2.6.32-504.3.3.el6.x86_64 #1 SMP Wed Dec 17 01:55:02 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

[[email protected] ~]# cat /etc/issue

CentOS release 6.5 (Final)

Kernel \r on an \m

1

下载:

curl -O http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.7.tgz

2

[[email protected] mongodb]# tar -zxvf mongodb-linux-x86_64-2.6.7.tgz

mongodb-linux-x86_64-2.6.7/README

mongodb-linux-x86_64-2.6.7/THIRD-PARTY-NOTICES

mongodb-linux-x86_64-2.6.7/GNU-AGPL-3.0

mongodb-linux-x86_64-2.6.7/bin/mongodump

mongodb-linux-x86_64-2.6.7/bin/mongorestore

mongodb-linux-x86_64-2.6.7/bin/mongoexport

mongodb-linux-x86_64-2.6.7/bin/mongoimport

mongodb-linux-x86_64-2.6.7/bin/mongostat

mongodb-linux-x86_64-2.6.7/bin/mongotop

mongodb-linux-x86_64-2.6.7/bin/mongooplog

mongodb-linux-x86_64-2.6.7/bin/mongofiles

mongodb-linux-x86_64-2.6.7/bin/bsondump

mongodb-linux-x86_64-2.6.7/bin/mongoperf

mongodb-linux-x86_64-2.6.7/bin/mongod

mongodb-linux-x86_64-2.6.7/bin/mongos

mongodb-linux-x86_64-2.6.7/bin/mongo

[[email protected] mongodb]#

3

拷贝的规划的文件夹

[[email protected] mongodb]# mv mongodb-linux-x86_64-2.6.7 /opt/mongodb

4

配置环境变量

[[email protected] ~]# vi .bash_profile

PATH=$PATH:/opt/mongodb/bin

5

数据所在文件夹

[[email protected] mongodb]# mkdir dbdata

6

使用户 mongod可以读写数据所在文件夹

[[email protected] mongodb]# useradd -r mongod

[[email protected] mongodb]# chown mongod:mongod dbdata/

7

启动

[[email protected] mongodb]# mongod --dbpath dbdata

2015-02-13T17:56:23.704+0800 [initandlisten] MongoDB starting : pid=2035 port=27017 dbpath=dbdata 64-bit host=mgdbsvr

2015-02-13T17:56:23.708+0800 [initandlisten] db version v2.6.7

2015-02-13T17:56:23.708+0800 [initandlisten] git version: a7d57ad27c382de82e9cb93bf983a80fd9ac9899

2015-02-13T17:56:23.708+0800 [initandlisten] build info: Linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49

2015-02-13T17:56:23.708+0800 [initandlisten] allocator: tcmalloc

2015-02-13T17:56:23.708+0800 [initandlisten] options: { storage: { dbPath: "dbdata" } }

2015-02-13T17:56:23.738+0800 [initandlisten] journal dir=dbdata/journal

2015-02-13T17:56:23.741+0800 [initandlisten] recover : no journal files present, no recovery needed

2015-02-13T17:56:24.520+0800 [initandlisten] preallocateIsFaster=true 13.46

2015-02-13T17:56:25.273+0800 [initandlisten] preallocateIsFaster=true 12.5

2015-02-13T17:56:27.166+0800 [initandlisten] preallocateIsFaster=true 8.76

2015-02-13T17:56:27.166+0800 [initandlisten] preallocateIsFaster check took 3.423 secs

2015-02-13T17:56:27.167+0800 [initandlisten] preallocating a journal file dbdata/journal/prealloc.0

2015-02-13T17:56:30.089+0800 [initandlisten]         File Preallocator Progress: 891289600/1073741824    83%

2015-02-13T17:56:31.216+0800 [initandlisten] preallocating a journal file dbdata/journal/prealloc.1

2015-02-13T17:56:34.070+0800 [initandlisten]         File Preallocator Progress: 629145600/1073741824    58%

2015-02-13T17:56:35.779+0800 [initandlisten] preallocating a journal file dbdata/journal/prealloc.2

2015-02-13T17:56:38.054+0800 [initandlisten]         File Preallocator Progress: 859832320/1073741824    80%

2015-02-13T17:56:39.630+0800 [initandlisten] allocating new ns file dbdata/local.ns, filling with zeroes...

2015-02-13T17:56:39.762+0800 [FileAllocator] allocating new datafile dbdata/local.0, filling with zeroes...

2015-02-13T17:56:39.763+0800 [FileAllocator] creating directory dbdata/_tmp

2015-02-13T17:56:39.797+0800 [FileAllocator] done allocating datafile dbdata/local.0, size: 64MB,  took 0.002 secs

2015-02-13T17:56:39.832+0800 [initandlisten] build index on: local.startup_log properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.startup_log" }

2015-02-13T17:56:39.855+0800 [initandlisten]      added index to empty collection

2015-02-13T17:56:39.894+0800 [initandlisten] command local.$cmd command: create { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 numYields:0  reslen:37 281ms

2015-02-13T17:56:39.897+0800 [initandlisten] waiting for connections on port 27017

8

连接,简单使用

[[email protected] ~]# mongo

MongoDB shell version: 2.6.7

connecting to: test

#查看当前数据库

> db

test

#切到数据库 mydb

> use mydb

switched to db mydb

> db

mydb

#用javascript创建两个文档

> j = { name : "mongo" }

{ "name" : "mongo" }

> k = { x : 3 }

{ "x" : 3 }

#创建mydb数据库和testdata collection

> db.testdata.insert(j)

WriteResult({ "nInserted" : 1 })

> db.testdata.insert(k);

WriteResult({ "nInserted" : 1 })

> show collections

system.indexes

testdata

> db.testdata.find()

{ "_id" : ObjectId("54ddd717d692cfe0bd20d983"), "name" : "mongo" }

{ "_id" : ObjectId("54ddd728d692cfe0bd20d984"), "x" : 3 }

>

>

> show dbs

admin  (empty)

local  0.078GB

mydb   0.078GB

>

> use hahadb

switched to db hahadb

> show dbs

admin  (empty)

local  0.078GB

mydb   0.078GB

> db

hahadb

> j = { name : "mongo" }

{ "name" : "mongo" }

> show dbs

admin  (empty)

local  0.078GB

mydb   0.078GB

> db.testdata.insert(j)

WriteResult({ "nInserted" : 1 })

> show dbs

admin   (empty)

hahadb  0.078GB

local   0.078GB

mydb    0.078GB

>

> use mydb

switched to db mydb

> show collections

system.indexes

testdata

>

>  db.testdata.insert(j)

WriteResult({ "nInserted" : 1 })

> db.testdata.find()

{ "_id" : ObjectId("54ddd717d692cfe0bd20d983"), "name" : "mongo" }

{ "_id" : ObjectId("54ddd728d692cfe0bd20d984"), "x" : 3 }

{ "_id" : ObjectId("54ddda64d692cfe0bd20d986"), "name" : "mongo" }

> db.testdata.insert(k)

WriteResult({ "nInserted" : 1 })

>

>

> db.testdata.find()

{ "_id" : ObjectId("54ddd717d692cfe0bd20d983"), "name" : "mongo" }

{ "_id" : ObjectId("54ddd728d692cfe0bd20d984"), "x" : 3 }

{ "_id" : ObjectId("54ddda64d692cfe0bd20d986"), "name" : "mongo" }

{ "_id" : ObjectId("54ddda7dd692cfe0bd20d987"), "x" : 3 }

>

> db.testdata.find({x:3})

{ "_id" : ObjectId("54ddd728d692cfe0bd20d984"), "x" : 3 }

{ "_id" : ObjectId("54ddda7dd692cfe0bd20d987"), "x" : 3 }

>

>

> exit;

[[email protected] ~]#

参考:

docs.mongodb.org/manual/tutorial/install-mongodb-on-linux/

-----------------

转载请著明出处:

blog.csdn.net/beiigang

时间: 2024-12-25 11:44:46

mongodb之linux通用二进制包安装的相关文章

通用二进制包安装mariadb

解压二进制包: # tar xf   mariadb-5.5.43-linux-x86_64.tar.gz   -C   /usr/local   解压源码包(建议放在/usr/local目录下) # ln -s   /usr/local/mariadb-5.5.43-linux-x86_64   /usr/local/mysql  为解压目录创建个目录链接mysql(因为,名字虽说叫mariadb,实际内容还是mysql) 初始化: # mkdir /data  (新建存储目录) # /usr

通用二进制包安装 MySQL5.5

修改文件句柄 vim /etc/security/limits.conf # 修改 * soft nofile 65535 * hard nofile 65535 添加用户 useradd  -s /usr/sbin/nologin mysql mkdir -p /home/mysqldata chown -R mysql:mysql /home/mysqldata 下载解压授权 wget http://cdn.mysql.com/archives/mysql-5.5/mysql-5.5.49-

Linux下通用二进制MySQL安装

(本文转载自 http://superve.leanote.com/post/Untitled-560d35b538f4117cf700031d) Linux下通用二进制MySQL安装 下载通用二进制包 > cd /usr/local/src > wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.44-linux2.6-i686.tar.gz 将源码解压至 /usr/local/ 目录下 > tar -zxvf mysql-5.

mariadb通用二进制格式安装

一.MariaDB安装介绍: 对于通用二进制格式的包,我们只需要解压缩后就能够使用数据库,听起来很容易,但必须要注意一些问题.二进制 格式的程序包是已经编译好的二进制程序,所以里边有很多脚本都是在固定的路径下执行的,所以安装过程中mysql这个路径必须安装在/usr/local目录下,并且目录名称必须叫mysql.如果不这样设置,一些脚本无法运行,更别提能成功安装了. Mariadb通用二进制格式相关文件说明 当获取到Mariadb通用二进制格式文件,解压后查看其文件如下:     [[emai

MariaDB的二进制包安装方法

软件包的安装方式有三种:源码包安装.二进制包安装.rpm包安装.这三种安装方法都各有优劣.RPM安装:适合小环境,核心功能都具备,快速搭建环境,但它的版本一般都不会太高:二进制安装:它是发布出来时预先编译过的,既避免了编译的麻烦,又提供了增强功能:编译安装:它的要求高,要有编译环境,编译时可指定几乎所有选项,可满足你的所有选择. 今天就来讲讲二进制方式的安装,它即解决了版本的问题,又不会像源码编译一样需要我们花费大量的时间去编译.对于二进制格式的包,我们只需要解压缩后就能够使用数据库,这听起来很

模拟生成环境的MySQL安装方法-通用二进制方式安装

模拟生成环境的MySQL安装方法-通用二进制方式安装 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.并发响应用户请求的网络IO模型 1>.单进程 特点:一个进程响应一个请求.而且只有一个进程,所以执行任务是串行的. 2>.多进程/线程 特点:一个进程响应一个请求,如prefork多进程模式(由master进程提前开启的多个prefork进程,然后由这些prefork进程去响应多个请求.):也可以一个线程响应一个请求,如worker多线程模式(由master进程开启多个子

CentOS 7以通用二进制格式安装mariadb

系统环境:CentOS 7 1611(系统安装完成后自带有mariadb) mariadb版本:mariadb-5.5.56-linux-x86_64.tar.gz(Generic Linux) 下载地址:http://mirrors.neusoft.edu.cn/mariadb//mariadb-galera-5.5.56/bintar-linux-x86_64/mariadb-galera-5.5.56-linux-x86_64.tar.gz 1.下载通用二进制程序并展开 [[email p

Nginx部署文档(二进制包安装)

Nginx部署文档(二进制包安装) 创建时间:2016-06-27 修改时间:2017-03-04 修改时间:2017-03-06 文档目的2 基础知识2 常用命令2 系统环境2 操作步骤3 1. 安装依赖3 2. 安装nginx3 3. 启动nginx5 3. 关闭防火墙6 4. 修改生产环境配置6 常见问题7 问题一:报错"cp: `conf/koi-win' and `/usr/local/nginx/conf/koi-win' are the same file"7 问题二:[

二进制包安装golang

之前讲过arm平台上的golang的源代码编译安装,这次补充下golang官方提供的其它平台上二进制包安装方法. 1.下载golang二进制包 首先是要下载golang的二进制包,官方下载地址:https://golang.org/dl/ 选择对应平台的二进制包,目前golang官方只提供了以下平台的二进制包: 1.1 基于386或amd64处理器的Mac OS X 10.6+平台二进制包 1.2 基于386或amd64处理器的FreeBSD 8+平台的二进制包 1.3 基于386或amd64处