1
2
3
4
|
# tar xf mongodb-linux-x86_64-rhel62-3.0.6.tgz
# mv mongodb-linux-x86_64-rhel62-3.0.6 /usr/local/mongodb3.0.6
# cd /usr/local/mongodb3.0.6
# mkdir {etc,logs}
|
dbpath = /disk1/mongo27018/data
port = 31111
pidfilepath = /usr/local/mongo27018/run/mongod.pid
fork = true
logpath = /disk1/mongo27018/log/mongodb.log
#unixSocketPrefix = /usr/local/mongo27018/run
logappend = true
journal = true
replSet = anav_push/10.218.145.189:31111,10.218.145.190:31111,10.218.145.191:31111
#replSet = anav_push
#keyFile = /usr/local/mongo27018/conf/keyfile27018.0
#auth = true
maxConns = 2000
oplogSize = 10240
storageEngine = wiredTiger
wiredTigerCacheSizeGB = 20
wiredTigerStatisticsLogDelaySecs = 0
wiredTigerJournalCompressor = snappy
wiredTigerDirectoryForIndexes = true
wiredTigerCollectionBlockCompressor = snappy
wiredTigerIndexPrefixCompression = 1
1
|
# /usr/local/mongodb3.0.6/bin/mongod -f /usr/local/mongodb3.0.6/etc/mongodb.conf
|
use admin
db.runCommand({"replSetInitiate" { "_id" : "anav_push" ,"members" :
[ {"_id" : 1, "host" : "10.218.145.189:31111"},
{"_id" : 2, "host" : "10.218.145.190:31111"},
{"_id" : 3, "host" : "10.218.145.191:31111"}]
}})
1
2
|
# /usr/local/mongodb3.0.6/bin/mongo 192.168.115.21:27017
> db.
test
.insert({
"a"
:1})
|
6.为数据库建立用户名密码
#建立用户名密码 http://www.cnblogs.com/zhoujinyi/p/4610050.html
use admin
db.createUser(
{
user: "pushmongodb",
pwd: "push",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
use gate2
db.createUser(
{
user: "pushmongodb",
pwd: "push",
roles: [ { role: "readWrite", db: "gate2" } ]
}
)
#mongo集群搭建
http://www.cnblogs.com/zhoujinyi/p/3554010.html
http://www.cnblogs.com/zhoujinyi/p/3554010.html
http://hnr520.blog.51cto.com/4484939/1698306
http://fredjiang.github.io/2015/02/28/mongo-Replica-Set-%E7%AC%94%E8%AE%B0/
http://fredjiang.github.io/2015/02/28/mongo-Replica-Set-%E7%AC%94%E8%AE%B0/