developer zone - ¿ìËÙÆô¶¯MongoDB - mongodbÖ¸ÄÏ£¨·Ò룩£¨Èý£©
ÔÚOS X¿ìËÙÆô¶¯
°²×°mongodb
×î¼òµ¥µÄ°²×°mongodbµÄ·½·¨¾ÍÊÇʹÓðü¹ÜÀíÆ÷»òÕßÔ¤±àÒëºÃµÄ¶þ½øÖÆÎļþ£º
°ü¹ÜÀíÆ÷
Èç¹ûÄãʹÓÃHomebrew°ü¹ÜÀíÆ÷£¬ÇëÔËÐУº
- $ brew update
- $ brew install mongodb
Èç¹ûÄãʹÓÃMacPorts£¬Äã¿ÉÒÔÕâÑù°²×°£º
- $ sudo port install mongodb
Õû¸ö°²×°¹ý³Ì»á»¨·ÑÉÔÐíʱ¼ä¡£
32λ¶þ½øÖÆÎļþ
×¢£ºÍƼöʹÓÃ64루Èç¹ûÄãÓÐ64λ²Ù×÷ϵͳ£©
- $ curl http://downloads.mongodb.org/osx/mongodb-osx-i386-x.y.z.tgz > mongo.tgz
- $ tar xzf mongo.tgz
½«x.y.zÌ滻Ϊµ±Ç°Îȶ¨°æ±¾µÄ°æ±¾ºÅ
64λ¶þ½øÖÆÎļþ
- $ curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-x.y.z.tgz > mongo.tgz
- $ tar xzf mongo.tgz
½«x.y.zÌ滻Ϊµ±Ç°Îȶ¨°æ±¾µÄ°æ±¾ºÅ
´´½¨Ò»¸öÊý¾ÝĿ¼
ĬÈÏÇé¿öÏÂmongodb»á½«Êý¾Ý´æ´¢ÔÚ/data/db£¬µ«ÊÇËü²»»á×Ô¶¯´´½¨Õâ¸öĿ¼¡£ÕâÑù´´½¨£º
- $ mkdir -p /data/db
Ä㻹¿ÉÒÔÔÚÆô¶¯mongodbµÄʱºò£¬Ê¹Óà --dbpath ²ÎÊý¸æËßËüʹÓÃÁíÍâÒ»¸öÊý¾ÝĿ¼¡£
ÔËÐв¢Á¬½Óµ½·þÎñÆ÷
Ê×ÏÈ£¬ÔÚÒ»¸öÖÕ¶ËÖÐÆô¶¯mongodb·þÎñÆ÷£º
- $ ./mongodb-xxxxxxx/bin/mongod
ÔÚÁíÍâÒ»¸öÖնˣ¬Æô¶¯shell£¬Ëü»áĬÈÏ×Ô¶¯Á¬½Óµ½±¾»ú£º
- $ ./mongodb-xxxxxxx/bin/mongo
- > db.foo.save( { a : 1 } )
- > db.foo.find()
¹§Ï²£¬Äã¸Õ¸ÕʹÓÃmongodb´æ´¢²¢¼ìË÷ÁËÄãµÄµÚÒ»¸öÎĵµ¡£
ÔÚlinux¿ìËÙÆô¶¯
ÏÂÔØ
ͨ¹ý°ü¹ÜÀíÆ÷
UbuntuºÍDebianÓû§£¬Çë²ÎÔÄ¡°Ubuntu and Debian packages¡±¡£
CentOSºÍFedoraÓû§£¬Çë²ÎÔÄ¡°CentOS and Fedora Packages¡±¡£
32λlinux¶þ½øÖÆÎļþ
×¢£ºÍƼöʹÓÃ64λ
- $ # replace "1.6.4" in the url below with the version you want
- $ curl http://downloads.mongodb.org/linux/mongodb-linux-i686-1.6.4.tgz > mongo.tgz
- $ tar xzf mongo.tgz
64λlinux¶þ½øÖÆÎļþ
- $ # replace "1.6.4" in the url below with the version you want
- $ curl http://downloads.mongodb.org/linux/mongodb-linux-x86_64-1.6.4.tgz > mongo.tgz
- $ tar xzf mongo.tgz
ÆäËûUnixes
´´½¨Êý¾ÝĿ¼
ĬÈÏÇé¿öÏÂmongodb»á½«Êý¾Ý´æ´¢ÔÚ/data/db£¬µ«ÊÇËü²»»á×Ô¶¯´´½¨Õâ¸öĿ¼¡£ÕâÑùÀ´´´½¨£º
- $ sudo mkdir -p /data/db/
- $ sudo chown `id -u` /data/db
Ä㻹¿ÉÒÔÔÚÆô¶¯mongodbµÄʱºò£¬Ê¹Óà --dbpath ²ÎÊý¸æËßËüʹÓÃÁíÍâÒ»¸öÊý¾ÝĿ¼¡£
ÔËÐв¢Á¬½Óµ½·þÎñÆ÷
Ê×ÏÈ£¬ÔÚÒ»¸öÖÕ¶ËÖÐÆô¶¯mongodb·þÎñÆ÷£º
- $ ./mongodb-xxxxxxx/bin/mongod
ÔÚÁíÍâÒ»¸öÖնˣ¬Æô¶¯shell£¬Ëü»áĬÈÏ×Ô¶¯Á¬½Óµ½±¾»ú£º
- $ ./mongodb-xxxxxxx/bin/mongo
- > db.foo.save( { a : 1 } )
- > db.foo.find()
¹§Ï²£¬Äã¸Õ¸ÕʹÓÃmongodb´æ´¢²¢¼ìË÷ÁËÄãµÄµÚÒ»¸öÎĵµ¡£
ÔÚWindows¿ìËÙÆô¶¯
ÏÂÔØ
×î¼òµ¥£¨ÍƼö£©µÄ°²×°mongodbµÄ·½·¨¾ÍÊÇʹÓÃÒѾÉú³ÉºÃµÄ¶þ½øÖÆÎļþ¡£×¢£ºÍƼö64룬µ±È»Ç°ÌáÄãµÃÓÐ64λ°æ±¾µÄwindows¡£
32λ¶þ½øÖÆÎļþ
ÏÂÔز¢½âѹ32λµÄѹËõ°ü£¬ÍƼö¡°Éú²ú¡±°æ±¾¡£
64λ¶þ½øÖÆÎļþ
ÏÂÔز¢½âѹ64λµÄѹËõ°ü¡£
½âѹ
½âѹÏÂÔصİüµ½±¾µØĿ¼¡£ÎªÁ˼ò±ã£¬ÄãÒ²¿ÉÒÔ½«mongo-xxxxxxÖØÃüÃûΪmongo¡£
´´½¨Êý¾ÝĿ¼
ĬÈÏÇé¿öÏÂmongodb½«Êý¾Ý´æ´¢µ½\data\db,µ«ÊÇËü²»»á×Ô¶¯´´½¨Õâ¸öÎļþ¼Ð£¬¿ÉÒÔÕâÑùÀ´´´½¨£º
- C:\> mkdir \data
- C:\> mkdir \data\db
µ±È»£¬ÄãÒ²¿ÉÒÔÔÚϵͳä¯ÀÀÆ÷Öд´½¨Õâ¸öĿ¼¡£
Ä㻹¿ÉÒÔÔÚÆô¶¯mongodbµÄʱºò£¬Ê¹Óà --dbpath ²ÎÊý¸æËßËüʹÓÃÁíÍâÒ»¸öÊý¾ÝĿ¼
ÔËÐв¢Á¬½Óµ½·þÎñÆ÷
ÖØÒªµÄ¶þ½øÖÆÎļþÊÇ£º
- mongod.exe - Êý¾Ý¿â·þÎñÆ÷¡£Ê¹Óà mongod --help ¿ÉÒÔ»ñÈ¡¸üÏêϸµÄÆô¶¯°ïÖú¡£
- mongo.exe - ¹ÜÀíshell¡£
ÔÚä¯ÀÀÆ÷ÖÐË«»÷mongod.exe»òÕßÔÚÃüÁîÐÐÆô¶¯£º
- C:\> cd \my_mongo_dir\bin
- C:\my_mongo_dir\bin> mongod
×¢£ºÒ²¿ÉÒÔ½«·þÎñÆ÷ÒÔ·þÎñµÄÐÎʽÆô¶¯¡£
ÏÖÔÚ£¬Í¨¹ýË«»÷mongo.exe»òÕßÃüÁîÐз½Ê½Æô¶¯¹ÜÀíshell¡£Ä¬ÈÏÇé¿öÏ£¬mongo.exe»áÁ¬½ÓÔËÐÐÔÚ±¾µØµÄ·þÎñÆ÷²¢Ê¹ÓÃÃûΪ¡°test¡±µÄÊý¾Ý¿â¡£ÔËÐÐmongo --help»ñÈ¡¸ü¶àÐÅÏ¢¡£
- C:\> cd \my_mongo_dir\bin
- C:\my_mongo_dir\bin> mongo
- > // the mongo shell is a javascript shell connected to the db
- > // by default it connects to database 'test' at localhost
- > 3+3
- 6
- > db
- test
- > // the first write will create the db:
- > db.foo.insert( { a : 1 } )
- > db.foo.find()
- { _id : ..., a : 1 }
- > show dbs
- ...
- > show collections
- ...
- > help
¹§Ï²£¬Äã¸Õ¸Õͨ¹ýmongod´æ´¢²¢¼ìË÷ÁËÄãµÄµÚÒ»¸öÎĵµ¡£
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ