ITPub博客

首页 > 数据库 > NoSQL > mongodb副本集集群搭建

mongodb副本集集群搭建

原创 NoSQL 作者:celestezhang 时间:2015-08-20 17:08:51 0 删除 编辑
root@QA-5-44 ~]# mkdir -p /data/mongodb
[root@QA-5-44 ~]# cd /usr/local
[root@QA-5-44 local]# ls
bin  etc  games  include  lib  lib64  libexec  mongodb-linux-x86_64-rhel62-3.0.5.tgz  sbin  share  src
[root@QA-5-44 local]# tar -zxvf mongodb-linux-x86_64-rhel62-3.0.5.tgz -C /data/mongodb/
mongodb-linux-x86_64-rhel62-3.0.5/README
mongodb-linux-x86_64-rhel62-3.0.5/THIRD-PARTY-NOTICES
mongodb-linux-x86_64-rhel62-3.0.5/GNU-AGPL-3.0
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongodump
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongorestore
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongoexport
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongoimport
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongostat
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongotop
mongodb-linux-x86_64-rhel62-3.0.5/bin/bsondump
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongofiles
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongooplog
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongoperf
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongod
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongos
mongodb-linux-x86_64-rhel62-3.0.5/bin/mongo
[root@QA-5-44 local]# cd /data/mongodb
[root@QA-5-44 mongodb]# ls
mongodb-linux-x86_64-rhel62-3.0.5
[root@QA-5-44 mongodb]# mv mongodb-linux-x86_64-rhel62-3.0.5/ mongodb/
[root@QA-5-44 mongodb]# mkdir -p /data/mongodb/data
[root@QA-5-44 mongodb]# mkdir -p /data/mongodb/log
[root@QA-5-44 bin]# cat mongodb.conf
port=27017
dbpath=/data/mongodb/data
logpath=/data/mongodb/log/mongodb.log
logappend=true
fork=true
maxConns=5000
replSet=shared1
[root@QA-5-49 bin]#  numactl --interleave=all /data/mongodb/mongodb/bin/mongod --config /data/mongodb/mongodb/bin/mongodb.conf
/data/mongodb/mongodb/bin/mongod: /usr/lib64/libssl.so.10: no version information available (required by /data/mongodb/mongodb/bin/mongod)
/data/mongodb/mongodb/bin/mongod: /usr/lib64/libcrypto.so.10: no version information available (required by /data/mongodb/mongodb/bin/mongod)
/data/mongodb/mongodb/bin/mongod: /usr/lib64/libcrypto.so.10: no version information available (required by /data/mongodb/mongodb/bin/mongod)
about to fork child process, waiting until server is ready for connections.
forked process: 1639
child process started successfully, parent exiting
[root@QA-5-44 bin]# ./mongo
MongoDB shell version: 3.0.5
connecting to: test
Server has startup warnings: 
2015-08-20T04:49:54.841-0400 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2015-08-20T04:49:54.841-0400 I CONTROL  [initandlisten] 
> config = { _id:"shared1", members:[config = { _id:"shared1", members:[
... ... {_id:0,host:"172.17.5.44:27017"},... {_id:0,host:"172.17.5.44:27017"},
... ... {_id:1,host:"172.17.5.45:27017"},... {_id:1,host:"172.17.5.45:27017"},
... ... {_id:2,host:"172.17.5.59:27017"}]... {_id:2,host:"172.17.5.59:27017"}]
... ... }... }
{
        "_id" : "shared1",
        "members" : [
                {
                        "_id" : 0,
                        "host" : "172.17.5.44:27017"
                },
                {
                        "_id" : 1,
                        "host" : "172.17.5.45:27017"
                },
                {
                        "_id" : 2,
                        "host" : "172.17.5.59:27017"
                }
        ]
}> rs.initiate(config);rs.initiate(config);
{ "ok" : 1 }
shared1:OTHER> 
>
 shared1:OTHER> 
> shared1:PRIMARY> 
shared1:PRIMARY> 
shared1:PRIMARY> 
shared1:PRIMARY> use test;use test;
switched to db test
shared1:PRIMARY> db.test.insert({"test1":"testval1"})db.test.insert({"test1":"testval1"})
WriteResult({ "nInserted" : 1 })
shared1:PRIMARY>
 shared1:SECONDARY> use test;use test;
switched to db test
shared1:SECONDARY> show tables show tables;show tables;
2015-08-20T05:13:18.083-0400 E QUERY    Error: listCollections failed: { "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" }
    at Error (<anonymous>)
    at DB._getCollectionInfosCommand (src/mongo/shell/db.js:646:15)
    at DB.getCollectionInfos (src/mongo/shell/db.js:658:20)
    at DB.getCollectionNames (src/mongo/shell/db.js:669:17)
    at shellHelper.show (src/mongo/shell/utils.js:625:12)
    at shellHelper (src/mongo/shell/utils.js:524:36)
    at (shellhelp2):1:1 at src/mongo/shell/db.js:646
shared1:SECONDARY> show tavvshow tavv
2015-08-20T05:13:31.347-0400 E QUERY    Error: don't know how to show [tavv]
    at Error (<anonymous>)
    at shellHelper.show (src/mongo/shell/utils.js:733:11)
    at shellHelper (src/mongo/shell/utils.js:524:36)
    at (shellhelp2):1:1 at src/mongo/shell/utils.js:733
shared1:SECONDARY> 
shared1:SECONDARY> show tables;show tables;
2015-08-20T05:13:36.290-0400 E QUERY    Error: listCollections failed: { "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" }
    at Error (<anonymous>)
    at DB._getCollectionInfosCommand (src/mongo/shell/db.js:646:15)
    at DB.getCollectionInfos (src/mongo/shell/db.js:658:20)
    at DB.getCollectionNames (src/mongo/shell/db.js:669:17)
    at shellHelper.show (src/mongo/shell/utils.js:625:12)
    at shellHelper (src/mongo/shell/utils.js:524:36)
    at (shellhelp2):1:1 at src/mongo/shell/db.js:646
shared1:SECONDARY> db.getMongo().setSlaveOk();db.getMongo().setSlaveOk();
shared1:SECONDARY> db.testdb.find();db.testdb.find();
shared1:SECONDARY> db.testdb.find();db.testdb.find();
shared1:SECONDARY> show tables;show tables;
system.indexes
test
shared1:SECONDARY> user testuser test
2015-08-20T05:15:10.872-0400 E QUERY    SyntaxError: Unexpected identifier
shared1:SECONDARY> show tables;show tables;
system.indexes
test
shared1:SECONDARY> 





来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29898569/viewspace-1777773/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: mongodb集群搭建
请登录后发表评论 登录
全部评论

注册时间:2014-09-19

  • 博文量
    39
  • 访问量
    125985