设为首页 收藏本站
查看: 1609|回复: 0

[经验分享] 第二章 MongoDb初体验

[复制链接]

尚未签到

发表于 2018-10-28 10:22:42 | 显示全部楼层 |阅读模式
  第二章 MongoDb初体验
  Windows Xp 下使用MongoDB
  
  1、下载mongodb
  mongodb-win32-i386-1.4.3.zip
  http://downloads.mongodb.org/win32/mongodb-win32-i386-1.4.3.zip
  
  2、解压到c盘
DSC0000.png

  
  3、创建默认存储的文件夹(\data\db)
DSC0001.png

  即:C:\data\db
  
  4、启动mongodb服务器端
  C:\mongodb>cd bin
  C:\mongodb\bin>mongod.exe
  mongod.exe --help for help and startup options
  Mon Jun 28 10:40:19 Mongo DB : starting : pid = 0 port = 27017 dbpath = /data/db
  / master = 0 slave = 0  32-bit
  
  ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
  
  **       see http://blog.mongodb.org/post/137788967/32-bit-limitations for more
  
  Mon Jun 28 10:40:19 db version v1.4.3, pdfile version 4.5
  Mon Jun 28 10:40:19 git version: 47ffbdfd53f46edeb6ff54bbb734783db7abc8ca
  Mon Jun 28 10:40:19 sys info: windows (5, 1, 2600, 2, 'Service Pack 3') BOOST_LI
  B_VERSION=1_35
  Mon Jun 28 10:40:19 waiting for connections on port 27017
  Mon Jun 28 10:40:19 web admin interface listening on port 28017
  ,,,,,
  
  看到以上信息,说明启动成功。
  MongoDB 使用文件存储数据. (默认位置 /data/db/), 使用内存映射文件进行高效的数据管理.
  MongoDB 进程默认情况下使用监听端口为 27017  (可以在启动时用命令行参数修改,详细信息参考 [Command Line Parameters] ).
  
  5、简单测试
  这里调用的是mongo.exe,不是mongodb.exe,要看清楚哟
  C:\mongodb\bin>mongo.exe
  MongoDB shell version: 1.4.3
  url: test
  connecting to: test
  type "exit" to exit
  type "help" for help
  > db.foo.save({a:1})
  > db.foo.findOne()
  { "_id" : ObjectId("4c280be19764000000005452"), "a" : 1 }
  > exit
  bye
  
  6、补充参数说明
  Allowed options:
  
  General options:
  -h [ --help ]              show this usage information
  --version                  show version information
  -f [ --config ] arg         configuration file specifying additional options
  --port arg                 specify port number
  --bind_ip arg              local ip address to bind listener - all local ips
  bound by default
  -v [ --verbose ]           be more verbose (include multiple times for more
  verbosity e.g. -vvvvv)
  --dbpath arg (=/data/db/)   directory for datafiles    指定数据存放目录
  --quiet                    quieter output   静默模式
  --logpath arg              file to send all output to instead of stdout  指定日志存放目录
  --logappend                 appnd to logpath instead of over-writing
  指定日志是以追加还是以覆盖的方式写入日志文件
  --fork                     fork server process   以创建子进程的方式运行
  --cpu                      periodically show cpu and iowait utilization  周期性的显示cpu和io的使用情况
  --noauth                   run without security  无认证模式运行
  --auth                     run with security  认证模式运行
  --objcheck                 inspect client data for validity on receipt
  检查客户端输入数据的有效性检查
  --quota      enable db quota management   开始数据库配额的管理
  --quotaFiles arg           number of files allower per db, requires --quota
  规定每个数据库允许的文件数
  --appsrvpath arg           root directory for the babble app server
  --nocursors                diagnostic/debugging option  调试诊断选项
  --nohints                  ignore query hints  忽略查询命中率
  --nohttpinterface          disable http interface  关闭http接口,默认是28017
  --noscripting              disable scripting engine  关闭脚本引擎
  --noprealloc               disable data file preallocation  关闭数据库文件大小预分配
  --smallfiles               use a smaller default file>
  --nssize arg (=16)         .ns file>
  新数据库ns文件的默认大小
  --diaglog arg              0=off 1=W 2=R 3=both 7=W+some reads
  提供的方式,是只读,只写,还是读写都行,
  还是主要写+部分的读模式
  --sysinfo                  print some diagnostic system information 打印系统诊断信息
  --upgrade                  upgrade db if needed  如果需要就更新数据库
  --repair                   run repair on all dbs  修复所有的数据库
  --notablescan              do not allow table scans  不运行表扫描
  --syncdelay arg (=60)      seconds between disk syncs (0 for never)
  系统同步刷新磁盘的时间,默认是60s
  
  Replication options:
  --master                master mode 主复制模式
  --slave                 slave mode  从复制模式
  --source arg            when slave: specify master as
  当为从时,指定主的地址和端口
  --only arg              when slave: specify a single database to replicate
  当为从时,指定需要从主复制的单一库
  --pairwith arg          address of server to pair with
  --arbiter arg           address of arbiter server
  仲裁服务器,在主主中和pair中用到
  --autoresync            automatically resync if slave data is stale 自动同步从的数据
  --oplogSize arg         size limit (in MB) for op log 指定操作日志的大小
  --opIdMem arg           size limit (in bytes) for in memory storage of op>
  指定存储操作日志的内存大小
  
  Sharding options:
  --configsvr             declare this is a config db of a cluster
  指定shard中的配置服务器
  --shardsvr              declare this is a shard db of a cluster 指定shard服务器


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-627405-1-1.html 上篇帖子: 第一章 MongoDb概述 下篇帖子: 第三章 MongoDb Java应用 3.2
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表