mongo2.4.5

#!/bin/bash
cd /usr/local/src
tar fxvz mongodb-linux-x86_64-2.4.5.tgz
mkdir /usr/local/mongodb/
mkdir /home/mongologs/
mkdir /home/mongodb
mv mongodb-linux-x86_64-2.4.5/* /usr/local/mongodb/
rm -rf mongodb-linux-x86_64-2.4.5
cd /usr/local/mongodb/
mkdir conf
cat >> /usr/local/mongodb/conf/mongo.conf<<EOF
logpath=/home/mongologs/mongodb.log
dbpath=/home/mongodb
port = 27017
master = true
logappend = true
fork = true
rest = true
directoryperdb=true
#auth = true

#auth = true

maxConns = 20000
EOF
ln -s /usr/local/mongodb/bin/mongo /usr/bin
/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/mongo.conf
echo "/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/mongo.conf" >> /etc/rc.local
mongo <<EOF
use admin;
db.addUser('root','密码');
db.shutdownServer();
quit();
EOF
sed -i 's/#auth = true/auth = true/g' /usr/local/mongodb/conf/mongo.conf
/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/mongo.conf


/usr/local/mongodb/bin/mongodump -d opener -o /mnt/bak_mongodb/$D -u=root -p=xxxx --authenticationDatabase=admin

http://blog.csdn.net/sinat_30397435/article/details/50774175
.
/usr/local/mongodb/bin/mongodump -h 192.168.10.175 --port 27017 -d sina -c 201801 -o ./mongo_qianyi/ -uback -pback123

 


db.getCollection('201503').drop()

 

posted @ 2018-06-27 17:44  滴滴滴  阅读(257)  评论(0编辑  收藏  举报