MongoDB 启动多实例 和 MongoDB创建删除、备份、复制

MongoDB 启动多实例 和 MongoDB创建删除、备份、复制

在单台服务器资源充足的情况下启用多实例

创建数据和日志存放位置

# 数据存放位置
[[email protected] ~] mkdir -p /data/mongodb/mongodb1
#日志存放位置
[[email protected] ~] mkdir /data/logs
[[email protected] ~] touch /data/logs/mongodb1.log

复制mongodb的配置文件

#复制原有的配置文件重新命名为mongod1.conf
[[email protected] ~] cp /etc/mongod.conf /etc/mongod.conf
#修改配置文件
[[email protected] ~] vim /etc/mongod1.conf
systemLog:
  destination: file
  logAppend: true
  path: /data/mongodb/logs/mongodb1.log #修改日志储存位置

  storage:
  dbPath: /data/mongodb/mongodb1 #修改数据文件存放位置
  net:
  port: 27018 #修改端口号

重新启动mongod1.conf

[[email protected] ~] mongod -f /etc/mongod1.conf
about to fork child process, waiting until server is ready for connections.
forked process: 7142
child process started successfully, parent exiting
#进入多实例数据库
[[email protected] mongodb1]# mongo --port 27018
MongoDB shell version v3.6.6
connecting to: mongodb://127.0.0.1:27018/
MongoDB server version: 3.6.6
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
Server has startup warnings:
2018-07-16T16:59:47.637+0800 I CONTROL  [initandlisten]
2018-07-16T16:59:47.637+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-07-16T16:59:47.637+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-07-16T16:59:47.637+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-07-16T16:59:47.637+0800 I CONTROL  [initandlisten]
2018-07-16T16:59:47.638+0800 I CONTROL  [initandlisten]
2018-07-16T16:59:47.638+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always‘.
2018-07-16T16:59:47.638+0800 I CONTROL  [initandlisten] **        We suggest setting it to ‘never‘
2018-07-16T16:59:47.638+0800 I CONTROL  [initandlisten]
2018-07-16T16:59:47.638+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always‘.
2018-07-16T16:59:47.638+0800 I CONTROL  [initandlisten] **        We suggest setting it to ‘never‘
2018-07-16T16:59:47.638+0800 I CONTROL  [initandlisten]
>
# MongDB关闭命令
[[email protected] ~]# mongod -f /etc/mongod.conf --shutdown

多实例就创建好了每个多实例都是单独分开的

MongoDB的存储结构

MongoDB逻辑存储结构

MongoDB的逻辑结构主要有文档、集合、和数据库三那个部分组成。其中文档储存是MongoDB的核心概念,它是逻辑储存的最小单元,选购党羽关系型数据库中一行的记录

1:数据库

MongoDB可以建立多个数据库。MongoDB的默认数据库是test,该数据库存储在数据文件要显示它需要向数据库插入一些数据

> show dbs;      #查看数据库命令,里面是默认的数据库
admin   0.000GB
config  0.000GB
local   0.000GB
> use shcool;
#创建数据库直接use进入在里面创建集合,
# 输入数据会自动生成数据库
switched to db shcool
> db.createCollection(‘info1‘)   #创建数据集合
{ "ok" : 1 }
> show collections             #查看数据集合
info1
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
shcool  0.000GB

在几何中插入数据命令db.创建的集合.insert({"joect格式"})固有格式

> db.info1.insert ({"name":"zhangsa","id":2,"hobb":"jap"})
WriteResult({ "nInserted" : 1 })

查询集合里面的数据命令

> db.info1.find()
{ "_id" : ObjectId("5b4d46223ee32e205a4122c2"), "name" : "zhangsa", "id" : 2, "hobb" : "jap" }

循环创建数据

> for (var i=2;i<50;i++)db.info1.insert({"id":i,"name":"jccp"+i})
WriteResult({ "nInserted" : 1 })
# 查看创建的信息
> db.info1.find()
{ "_id" : ObjectId("5b4d46223ee32e205a4122c2"), "name" : "zhangsa", "id" : 2, "hobb" : "jap" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122c3"), "id" : 2, "name" : "jccp2" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122c4"), "id" : 3, "name" : "jccp3" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122c5"), "id" : 4, "name" : "jccp4" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122c6"), "id" : 5, "name" : "jccp5" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122c7"), "id" : 6, "name" : "jccp6" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122c8"), "id" : 7, "name" : "jccp7" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122c9"), "id" : 8, "name" : "jccp8" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122ca"), "id" : 9, "name" : "jccp9" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122cb"), "id" : 10, "name" : "jccp10" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122cc"), "id" : 11, "name" : "jccp11" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122cd"), "id" : 12, "name" : "jccp12" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122ce"), "id" : 13, "name" : "jccp13" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122cf"), "id" : 14, "name" : "jccp14" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122d0"), "id" : 15, "name" : "jccp15" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122d1"), "id" : 16, "name" : "jccp16" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122d2"), "id" : 17, "name" : "jccp17" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122d3"), "id" : 18, "name" : "jccp18" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122d4"), "id" : 19, "name" : "jccp19" }
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122d5"), "id" : 20, "name" : "jccp20" }
Type "it" for more #(输入it往下查看)

查找某个指定的数据

> db.info1.find({"id":10})
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122cb"), "id" : 10, "name" : "jccp10" }

修改把第十行的jccp10改为tom

> db.info1.update({"id":10},{$set:{"name":"tom"}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.info1.find({"id":10})
{ "_id" : ObjectId("5b4d48ee3ee32e205a4122cb"), "id" : 10, "name" : "tom" }

删除(集合,数据库)

> db.info1.drop()
true
> db.info1.find()
> db.shcool.database
shcool.shcool.database
> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
> 

备份数据库

下面是我创建的school数据库,集合里面也有信息,把他们备份导出

> use shcool;
switched to db shcool
> db.createCollection(‘info1‘)
{ "ok" : 1 }
> for (var i=2;i<50;i++)db.info1.insert({"id":i,"name":"jccp"+i})
WriteResult({ "nInserted" : 1 })
> db.info1.find()
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122f3"), "id" : 2, "name" : "jccp2" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122f4"), "id" : 3, "name" : "jccp3" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122f5"), "id" : 4, "name" : "jccp4" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122f6"), "id" : 5, "name" : "jccp5" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122f7"), "id" : 6, "name" : "jccp6" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122f8"), "id" : 7, "name" : "jccp7" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122f9"), "id" : 8, "name" : "jccp8" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122fa"), "id" : 9, "name" : "jccp9" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122fb"), "id" : 10, "name" : "jccp10" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122fc"), "id" : 11, "name" : "jccp11" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122fd"), "id" : 12, "name" : "jccp12" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122fe"), "id" : 13, "name" : "jccp13" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a4122ff"), "id" : 14, "name" : "jccp14" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a412300"), "id" : 15, "name" : "jccp15" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a412301"), "id" : 16, "name" : "jccp16" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a412302"), "id" : 17, "name" : "jccp17" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a412303"), "id" : 18, "name" : "jccp18" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a412304"), "id" : 19, "name" : "jccp19" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a412305"), "id" : 20, "name" : "jccp20" }
{ "_id" : ObjectId("5b4d4bf03ee32e205a412306"), "id" : 21, "name" : "jccp21" }
Type "it" for more

# 导出
[[email protected] ~]# mongoexport -d school -c info1 -o /opt/school.json
2018-07-17T09:55:16.306+0800    connected to: localhost
2018-07-17T09:55:16.306+0800    exported 0 records
[[email protected] ~]# cd /opt/
[[email protected] opt]# ls
rh  school.json
# 恢复重命名
[[email protected] opt]# mongoimport -d kfc -c   info --file /opt/school.json -h 0.0.0.0:27018
2018-07-17T09:57:02.564+0800    connected to: localhost
2018-07-17T09:57:02.564+0800    imported 0 documents
# 导入那个多实例加入-h ip:端口号
[[email protected] opt]# mongoimport -d school -c info1 --file /opt/school1.json -h 0.0.0.0:27018
2018-07-17T10:27:58.921+0800    connected to: 0.0.0.0:27018
2018-07-17T10:27:58.925+0800    num failures: 48
2018-07-17T10:27:58.925+0800    error inserting documents: multiple errors in bulk operation:
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9914‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9915‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9916‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9917‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9918‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9919‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a991a‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a991b‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a991c‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a991d‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a991e‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a991f‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9920‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9921‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9922‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9923‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9924‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9925‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9926‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9927‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9928‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9929‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a992a‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a992b‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a992c‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a992d‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a992e‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a992f‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9930‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9931‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9932‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9933‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9934‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9935‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9936‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9937‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9938‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9939‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a993a‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a993b‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a993c‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a993d‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a993e‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a993f‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9940‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9941‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9942‘) }
  - E11000 duplicate key error collection: school.info1 index: _id_ dup key: { : ObjectId(‘5b4d53622211edb9633a9943‘) }

导入指定一行或者一个范围

# 把school数据库中yo的集合中的id为10的信息导入到/opt/里面命名为school-top10.json
[[email protected] opt]# mongoexport -d school -c yo -q ‘{"id":{"$eq":10}}‘ -o /opt/school-top10.json
2018-07-17T10:57:38.100+0800    connected to: localhost
2018-07-17T10:57:38.101+0800    exported 1 record
[[email protected] opt]# ls
school-top10.json
[[email protected] opt]# cat school-top10.json
{"_id":{"$oid":"5b4d5aa9e2d41b39e5e9cbec"},"id":10.0,"name":"ject10"}
[[email protected] opt]# 

备份恢复

创建空目录文件夹
[[email protected] opt]# mongodump -d school -o /backup/
2018-07-17T11:01:07.474+0800    writing school.yo to
2018-07-17T11:01:07.475+0800    done dumping school.yo (19 documents)
[[email protected] opt]# ls
school-top10.json
[[email protected] opt]#  ls /
backup  boot  dev  home  lib64  mnt  proc  run   srv  tmp  var
bin     data  etc  lib   media  opt  root  sbin  sys  usr
[[email protected] opt]# cd /b
backup/ bin/    boot/
[[email protected] opt]# cd /backup/
[[email protected] backup]# ls
school
[[email protected] backup]# cd school/
[[email protected] school]# ls
yo.bson  yo.metadata.json
[[email protected] school]#

还原

[[email protected] school]# mongorestore -d school2 --dir=/backup/school/
2018-07-17T11:03:31.614+0800    the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead
2018-07-17T11:03:31.614+0800    building a list of collections to restore from /backup/school dir
2018-07-17T11:03:31.615+0800    reading metadata for school2.yo from /backup/school/yo.metadata.json
2018-07-17T11:03:31.621+0800    restoring school2.yo from /backup/school/yo.bson
2018-07-17T11:03:31.624+0800    no indexes to restore
2018-07-17T11:03:31.624+0800    finished restoring school2.yo (19 documents)
2018-07-17T11:03:31.624+0800    done
[[email protected] school]# mongo
MongoDB shell version v3.6.6
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.6
Server has startup warnings:
2018-07-17T10:45:19.749+0800 I CONTROL  [initandlisten]
2018-07-17T10:45:19.749+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-07-17T10:45:19.750+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-07-17T10:45:19.750+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-07-17T10:45:19.750+0800 I CONTROL  [initandlisten]
2018-07-17T10:45:19.750+0800 I CONTROL  [initandlisten]
2018-07-17T10:45:19.750+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always‘.
2018-07-17T10:45:19.750+0800 I CONTROL  [initandlisten] **        We suggest setting it to ‘never‘
2018-07-17T10:45:19.750+0800 I CONTROL  [initandlisten]
2018-07-17T10:45:19.750+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always‘.
2018-07-17T10:45:19.750+0800 I CONTROL  [initandlisten] **        We suggest setting it to ‘never‘
2018-07-17T10:45:19.750+0800 I CONTROL  [initandlisten]
> show dbs
admin    0.000GB
config   0.000GB
local    0.000GB
school   0.000GB
school2  0.000GB
>

复制数据库

> db.copyDatabase("school","school8")
{ "ok" : 1 }
> show dbs
admin    0.000GB
config   0.000GB
local    0.000GB
school   0.000GB
school2  0.000GB
school8  0.000GB

原文地址:http://blog.51cto.com/13645280/2145270

时间: 2024-10-11 00:54:47

MongoDB 启动多实例 和 MongoDB创建删除、备份、复制的相关文章

使用JavaScript操作DOM节点元素的常用方法(创建/删除/替换/复制等)

getElementById(id)这是通过id来访问某一元素,最常用的之一,例:<html><body><div id="myid">test</div><script language="javascript">alert(document.getElementById("myid").innerHTML);</script></body></html&

MongoDB启动配置等

目录: 一.mongoDB 启动配置 二.导出,导入,运行时备份 三.Fsync锁,数据修复 四.用户管理,安全认证 一.启动项 mongod --help C:\Windows\system32>mongod --help 1.常用配置项 --dbpath 指定数据库的目录,默认在window下是c:\data\db\ --port 指定服务器监听的端口号码,默认是27017 --fork 用守护进程的方式启动mongoDB --logpath 指定日志的输出路径,默认是控制台 --confi

SQL server 2008 Express Edition实现自动备份和自动删除备份

1.查看SQL 版本: select @@VERSION --可以看到 Express Edition 精简免费版 Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)   Jun 28 2012 08:36:30   Copyright (c) Microsoft Corporation  Express Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pac

MongoDB安装以及MongoDB开启多实例

MongoDB安装方法 一.手工编译安装 软件包百度网盘链接:https://pan.baidu.com/s/19oPP-3k7MiPsemO2cLsdng 密码:k86h 1.挂载本地后解压到opt目录下tar zxf mongodb-linux-x86_64-rhel70-4.0.0.tgz -C /opt/ 2.移动解压过后的包到/usr/local/目录中并重命名mv mongodb-linux-x86_64-rhel70-4.0.0/ /usr/local/mongodb 3.创建配置

mongodb 启动步骤

mongodb启动步骤 1.在对应的目录下创建一个data的文件夹 2.打开cmd 跳转到bin路径下运行 (启动服务 运行 http://localhost:27017) D:\>cd D:\MongoDB\Server\3.0\bin D:\MongoDB\Server\3.0\bin>mongod --dbpath D:\MongoDB\Server\3.0\data 3.重新打开一个cmd 跳转到bin路径下运行 mongo D:\>cd D:\MongoDB\Server\3.

1. MONGODB启动&amp;关闭

[前记]  最近由于公司系统改造:借用内存库来达到快速响应.公司借用mongodb数据库.下面是学习整理的note 从启动&关闭开始:至于安装这个太简单了. mongodb启动 mongodb服务器启动(跟postgresql数据库启动方式有点类似):是使用mongod命令.至于启动参数:可以使用mongod --help.mongod常用参数如下: --dbpath:指定数据目录.例如E:\mongodb\date\db.要确定该目录存在:不存在则创建.不然启动时会报目录不存在错误. --po

第五部分 架构篇 第十五章 MongoDB Replica Sets 架构(动态增加删除结点)

1.Replica Set增加结点 MongoDB Replica Set不仅提供高可用性的解决方案,它也同时提供负载均衡的解决方案,增减Replica Sets结点在实际应用中非常普遍,比如当应用的读压力暴增时,3台结点的环境已经不能满足需求,那么就需要增加一些结点将压力平均分配一下,当应用的压力小时,可以减少一些结点来减少硬件资源的成本,总是是一个长期且持续的工作. 官方给我们提供了2个方案用于增加结点,一种是通过oplog来增加结点,一种是通过数据库快照(--fastsync)和oplog

mongodb启动出现问题解决方法。

之前MongoDB启动的时候是蛮正常的,不知道后来启动报错了,就把粘贴出来查询了.最后才知道是由于自己不正常的关闭导致的这个情况. --摘录:MongoDB非正常关闭后修复记录 mongod没有后台执行,在终端连接非正常断开后,再次执行mongod报错,如下所示: [[email protected] mongodb]# ./bin/mongod ./bin/mongod --help for help and startup options Thu Nov 17 22:42:49 Thu No

mongoDB 启动与停止

MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案.它以高性能.易部署.易使用,存储数据非常方便等优点被广泛使用.其安装配置相当简单,有如轻量级的mysql,但功能丝毫不差.本文主要描述mongoDB的启动与停止. 一.准备环境 1.当前环境 # more /etc/redhat-release CentOS release 6.7 (Final) 2.安装mongod # which mongod /var/lib/mongod