Mongo導入ノート

3089 ワード

1. MongoDB   
   Chrome  :https://www.mongodb.com/download-center/community
   ( :Edge      )

       :https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.17.tgz
   ( :src       ,    )

【hadoop     】
2.     Linux   ,         /opt    
  $ cd /opt
  $ tar -zxvf mongodb-linux-x86_64-4.0.17.tgz

3.    mongo    ,       data
  $ cd mongodb-linux-x86_64-4.0.17
  $ mkdir data

4.               log     ,  deamon     
  $ mkdir log
  $ vi mongodb.conf
  
  port=27017 #   
  dbpath=data #       
  logpath=log/mongodb.log #     ,   deamon       log     
  logappend=true
  fork=true #    deamon     
  auth=true #       

【root     】
5.         
  $ vi /etc/profile
    
  export MONGO_HOME=/opt/mongodb-linux-x86_64-4.0.17
  export PATH=$PATH:$MONGO_HOME/bin
  
        
  $ source /etc/profile

【hadoop     】
6.    mongo
  $ cd /opt/mongodb-linux-x86_64-4.0.17
  $ mongod -f mongodb.conf
  about to fork child process, waiting until server is ready for connections.
  forked process: 6409
  child process started successfully, parent exiting
  

      mongo
  $ mongod shutdown -f mongodb.conf

7.    mongo shell    ,   help     
  $ mongo
  MongoDB shell version v4.0.17
  connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
  Implicit session: session { "id" : UUID("bb014d97-41e3-4e34-af00-24dd324f4f93") }
  MongoDB server version: 4.0.17
  
  > help
        db.help()                    help on db methods
        db.mycoll.help()             help on collection methods
        sh.help()                    sharding helpers
        rs.help()                    replica set helpers
        help admin                   administrative help
        help connect                 connecting to a db help
        help keys                    key shortcuts
        help misc                    misc things to know
        help mr                      mapreduce

        show dbs                     show database names
        show collections             show collections in current database
        show users                   show users in current database
        show profile                 show most recent system.profile entries with time >= 1ms
        show logs                    show the accessible logger names
        show log [name]              prints out the last segment of log in memory, 'global' is default
        use                 set current database
        db.foo.find()                list objects in collection foo
        db.foo.find( { a : 1 } )     list objects in foo where a == 1
        it                           result of the last line evaluated; use to further iterate
        DBQuery.shellBatchSize = x   set default number of items to display on shell
        exit                         quit the mongo shell

       
  > show dbs
  admin   0.000GB
  config  0.000GB
  local   0.000GB
  >                                                                                                                       

参考ブログ:Mongodbバックグラウンドdaemon方式起動