ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

mongodb¸±±¾¼¯×Ô¶¯Çл»ÐÞ¸´½Úµã½â¾ö·½°¸(Ò»)
2014-11-24 00:12:31 À´Ô´: ×÷Õß: ¡¾´ó ÖРС¡¿ ä¯ÀÀ:51´Î
Tags£ºmongodb ¸±±¾ ×Ô¶¯ Çл» ÐÞ¸´ ½Úµã ½â¾ö·½°¸
mongodb¸±±¾¼¯×Ô¶¯Çл»ÐÞ¸´½Úµã½â¾ö·½°¸
¸±±¾¼¯²¿Êð
1.Æô¶¯mongod
ÔÚÿ̨ÔËÐÐmongod·þÎñµÄ»úÆ÷ÉÏÔö¼ÓÅäÖÃÎļþ/etc/mongodb-rs.conf£¬ÄÚÈÝΪ£º
[root@MongodbF-A etc]# vi /etc/mongodb-rs.conf
port = 27017
dbpath = /data/db
logpath = /log/log.log
fork = true
replSet = test
ͨ¹ýÏÂÃæÃüÁîÆô¶¯mongod:
[root@MongodbF-A etc]# /App/mongo/bin/mongod -f /etc/mongodb-rs.conf
about to fork child process, waiting until server is ready for connections.
all output going to: /log/log.log
log file [/log/log.log] exists; copied to temporary file [/log/log.log.2013-07-18T10-00-56]
forked process: 8513
child process started successfully, parent exiting
[root@MongodbF-A etc]#
[root@MongodbF-B App]# /App/mongo/bin/mongod -f /etc/mongodb-rs.conf
about to fork child process, waiting until server is ready for connections.
all output going to: /log/log.log
log file [/log/log.log] exists; copied to temporary file [/log/log.log.2013-07-18T10-00-06]
forked process: 8314
child process started successfully, parent exiting
[root@MongodbF-B App]#
[root@MongodbF-C App]# /App/mongo/bin/mongod -f /etc/mongodb-rs.conf
about to fork child process, waiting until server is ready for connections.
all output going to: /log/log.log
log file [/log/log.log] exists; copied to temporary file [/log/log.log.2013-07-18T10-06-38]
forked process: 8083
[Achild process started successfully, parent exiting
[root@MongodbF-C App]#
2. ÐÞ¸Äÿ¸ö»úÆ÷µÄ/etc/hosts
[root@MongodbF-A etc]# vim /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 MongodbF-A localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.155.224 mongodb1.example.net
192.168.155.225 mongodb2.example.net
192.168.155.226 mongodb3.example.net
~
2. ʹÓÃmongo shellÁ¬½Ómongod£¬½øÐÐÅäÖÃ:
[root@MongodbF-A etc]# /App/mongo/bin/mongo 192.168.155.224
MongoDB shell version: 2.4.5
connecting to: 192.168.155.224/test
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
> config = {_id:'test',members:[
... _id:0,host:'mongodb1.example.net'},
... _id:1,host:'mongodb2.example.net'},
Thu Jul 18 18:10:52.802 JavaScript execution failed: SyntaxError: Unexpected token :
> config = {_id:'test',members:[ _id:0,host:'mongodb1.example.net'}, _id:1,host:'mongodb2.example.net'},{_id:2,host:'mongodb3.example.net'}]}
Thu Jul 18 18:11:54.575 java script execution failed: SyntaxError: Unexpected token :
> config_test={"_id":"test",members:[ --------------¶¨ÒåÅäÖÃÐÅÏ¢
... {_id:0,host:"mongodb1.example.net"},
... {_id:1,host:"mongodb2.example.net"},
... {_id:2,host:"mongodb3.example.net"}]
... }
{
"_id" : "test",
"members" : [
{
"_id" : 0,
"host" : "mongodb1.example.net"
},
{
"_id" : 1,
"host" : "mongodb2.example.net"
},
{
"_id" : 2,
"host" : "mongodb3.example.net"
}
]
}
>
> rs.initiate(config_test) ----
Ê×Ò³ ÉÏÒ»Ò³ 1 2 3 4 5 ÏÂÒ»Ò³ βҳ 1/5/5
¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
·ÖÏíµ½: 
ÉÏһƪ£ºmongo¹¹½¨¸±±¾¼¯ ÏÂһƪ£ºSQLµãµÎ9¨DSQL ServerÖеÄÊÂÎñ´¦À..

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡¡¡Çé:
ÄÚ¡¡¡¡ÈÝ: