zoukankan      html  css  js  c++  java
  • Mongodb 安装迁移

    <pre name="code" class="python">1、下载MongoDB(64位)
    
    http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tgz
    
    或
    
    http://pan.baidu.com/s/1mgyRB8c
    
    2、安装MongoDB(安装到/usr/local)
    
    复制代码
    tar zxvf mongodb-linux-x86_64-2.4.9.tgz
    mv mongodb-linux-x86_64-2.4.9 mongodb
    cd mongodb
    mkdir db
    mkdir logs
    cd bin
    vi mongodb.conf
    复制代码
    dbpath=/data01/mongodb/db
    logpath=/data01/mongodb/logs/mongodb.log
    port=27017
    fork=true
    nohttpinterface=true
    
    
    3.启动monggodb 设置密码:
    
    [root@wx03 bin]# /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf
    about to fork child process, waiting until server is ready for connections.
    forked process: 2569
    all output going to: /data01/mongodb/logs/mongodb.log
    
    
    child process started successfully, parent exiting
    
    
    [root@wx03 ~]# mongofiles list  -db pics 
    connected to: 127.0.0.1
    
    
    
    4.创建用户:
    [root@wx03 ~]# mongo
    MongoDB shell version: 2.4.9
    connecting to: 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
    > show databases
    local	0.078125GB
    pics	0.203125GB
    > use pics;
    switched to db pics
    >  db.addUser('pics','1234567');
    {
    	"user" : "pics",
    	"readOnly" : false,
    	"pwd" : "ef0dc53a2cae7b91e97e17759a4a9fb6",
    	"_id" : ObjectId("57a93f5aad9b35eacaaa901e")
    }
    
    启动认证:
    启用的时候需要加--auth   
    
    /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf --auth  
    
    
    [root@wx03 ~]#  /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf --auth
    about to fork child process, waiting until server is ready for connections.
    forked process: 2820
    all output going to: /data01/mongodb/logs/mongodb.log
    log file [/data01/mongodb/logs/mongodb.log] exists; copied to temporary file [/data01/mongodb/logs/mongodb.log.2016-08-09T02-40-55]
    child process started successfully, parent exiting
    [root@wx03 ~]# mongo
    mongo         mongod        mongodump     mongoexport   mongofiles    mongoimport   mongooplog    mongoperf     mongorestore  mongos        mongosniff    mongostat     mongotop      
    [root@wx03 ~]# mongo
    MongoDB shell version: 2.4.9
    connecting to: test
    > show databases;
    admin	(empty)
    local	0.078125GB
    pics	0.203125GB
    > use pics;
    switched to db pics
    > show databases;
    admin	(empty)
    local	0.078125GB
    pics	0.203125GB
    
    可以看到 单独的设置pics数据库的用户名,密码还不够,需要设置admin数据库的
    
    
    
    
    
    
    线上导出数据:
    
    [root@hy-mrz01 ~]# mongodump -d pics -o /tmp/
    connected to: 127.0.0.1
    Tue Aug  9 10:31:54.308 DATABASE: pics	 to 	/tmp/pics
    assertion: 13106 nextSafe(): { $err: "not authorized for query on pics.system.indexes", code: 16550 }
    
    
    备份数据库:
    
    [root@hy-mrz01 ~]# mongodump  -u "pics" -p "xxx" -d pics -o /tmp/
    connected to: 127.0.0.1
    Tue Aug  9 10:32:26.817 DATABASE: pics	 to 	/tmp/pics
    Tue Aug  9 10:32:26.817 	pics.system.indexes to /tmp/pics/system.indexes.bson
    Tue Aug  9 10:32:26.817 		 7 objects
    Tue Aug  9 10:32:26.817 	pics.system.users to /tmp/pics/system.users.bson
    Tue Aug  9 10:32:26.818 		 1 objects
    Tue Aug  9 10:32:26.818 	Metadata for pics.system.users to /tmp/pics/system.users.metadata.json
    Tue Aug  9 10:32:26.818 	pics.fs.files to /tmp/pics/fs.files.bson
    Tue Aug  9 10:32:26.819 		 991 objects
    Tue Aug  9 10:32:26.819 	Metadata for pics.fs.files to /tmp/pics/fs.files.metadata.json
    Tue Aug  9 10:32:26.820 	pics.fs.chunks to /tmp/pics/fs.chunks.bson
    Tue Aug  9 10:32:28.069 		 4520 objects
    Tue Aug  9 10:32:28.069 	Metadata for pics.fs.chunks to /tmp/pics/fs.chunks.metadata.json
    
    
    
    导入数据库:
    
    [root@wx03 tmp]# mongorestore -u pics -p '1234567' -d pics /tmp/pics/
    
    
    
    
    查看图片:
    [root@wx03 tmp]# mongofiles list -u pics -p '1234567' -db pics 
    

  • 相关阅读:
    Windows Media Player Audio normalize wmp音量规格化
    IE6、IE7、IE8不支持XHTML,不过没关系
    w3.org出现HTML语法错误
    主板bios修改、刷新
    HTML原则:内容放在HTML中,不要依赖CSS
    textarea应使用cols和rows来控制width和height,而不应只使用css
    sata AHCI驱动下载(AMD Intel Nvidia)
    咬文嚼字:中国文字、中国话
    详解W3C标准:html 4.01中的lang属性——实际上它是一个刮胡刀
    热烈欢呼:cnblogs.com博客园首页通过W3C验证
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350423.html
Copyright © 2011-2022 走看看