MongoDB University 12/19 데이터 세트 가져오기

이 기록은 부가 달력 형식으로 몬godb University의 학습 과정을 기록한 19일째!
현재 진행 중인 노선: M103[1].목표는 12/25 이전에 Chapter 1 완성!
  • 추가 달력 / 1인 MongodB University 준비
  • Chapter 1: Lab: Importinga Dataset(연습 문제)


    Problem:
    Import a dataset into MongoDB using mongoimport:
    Mongoimport을 사용하여 MongoDB로 데이터 가져오기
  • connect to a mongod process running on port 27000
  • port 2700을 통해 시작
  • import the data from/dataset/products.json
  • /dataset/products.json 가져오기
  • import the data to applicationData.products
  • applicationData.제품 모음집에 데이터 가져오기
  • use m103-application-user to authenticate to the database - this user has already - been created for you on the admin database with password m103-application-pass
  • m103-application-user 사용(인증용db는admin, 비밀번호는m103-application-user)
  • 시험해 보다

  • 지정된 포트에서 mongod
  • 시작
  • 사용자가 생성되어야 하므로 이 인증 정보를 사용하여 연결
  • 인증 데이터베이스는 admin
  • user: m103-application-user/m103-application-pass
  • monngo 명령으로 연결하여 애플리케이션 Data
  • 확인
  • 명령줄에mongoimport 등록 데이터 사용
  • 설정 파일은 다음과 같습니다.
    storage:
      dbPath: /var/mongodb/db
    net:
      bindIp: localhost
      port: 27000
    security:
      authorization: enabled
    systemLog:
      destination: file
      path: /var/mongodb/logs/mongod.log
      logAppend: true
    processManagement:
      fork: true
    
    부팅 확인
    시동이 걸렸어요.
    bash-4.4# ps -elf | grep mongod
      159 root      0:01 mongod --port 27000 --dbpath /var/mongodb/db --auth --logpath /var/mongodb/logs/mongod.log --logappend --fork
      383 root      0:00 grep mongod
    
    접속 확인
    bash-4.4# mongo --port 27000 -u m103-application-user -p m103-application-pass
    MongoDB shell version v4.0.5
    connecting to: mongodb://127.0.0.1:27000/?gssapiServiceName=mongodb
    Implicit session: session { "id" : UUID("80d7435d-91f1-4725-a0d8-5fc4060a29a2") }
    MongoDB server version: 4.0.5
    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;
    >
    > use applicationData
    switched to db applicationData
    
    계좌가 이미 존재하는 것 같습니다.

    가져오기 시도


    데이터 파일을 확인합니다.는 json 파일(텍스트)입니다.
    bash-4.4# head /dataset/products.json
    {"_id":{"$oid":"573f7197f29313caab89b21b"},"sku":20000008,"name":"Come Into The World - CD","type":"Music","regularPrice":14.99,"salePrice":14.99,"shippingWeight":"0.25"}
    {"_id":{"$oid":"573f7197f29313caab89b21c"},"sku":20000017,"name":"Paragon of Animals - CD","type":"Music","regularPrice":14.99,"salePrice":14.99,"shippingWeight":"0.25"}
    {"_id":{"$oid":"573f7197f29313caab89b21d"},"sku":20000035,"name":"Hedgehog's Dilemma - CD","type":"Music","regularPrice":14.99,"salePrice":14.99,"shippingWeight":"0.25"}
    {"_id":{"$oid":"573f7197f29313caab89b21e"},"sku":20000026,"name":"Very Best of the Foundations [Pony Canyon] - CD","type":"Music","regularPrice":13.99,"salePrice":13.99,"shippingWeight":"0.25"}
    {"_id":{"$oid":"573f7197f29313caab89b21f"},"sku":20000053,"name":"Frontline of K-Pop - CD","type":"Music","regularPrice":22.99,"salePrice":22.99,"shippingWeight":"0.25"}
    {"_id":{"$oid":"573f7197f29313caab89b220"},"sku":20000044,"name":"Prototpye A [EP] - CD","type":"Music","regularPrice":8.99,"salePrice":8.99,"shippingWeight":"0.25"}
    {"_id":{"$oid":"573f7197f29313caab89b222"},"sku":20000062,"name":"New Year's Day [Single] - CD","type":"Music","regularPrice":20.99,"salePrice":20.99,"shippingWeight":"0.25"}
    {"_id":{"$oid":"573f7197f29313caab89b223"},"sku":20000071,"name":"What a Circus - CD","type":"Music","regularPrice":17.99,"salePrice":17.99,"shippingWeight":"0.25"}
    {"_id":{"$oid":"573f7197f29313caab89b224"},"sku":20000099,"name":"Summer Ends - CD","type":"Music","regularPrice":11.99,"salePrice":11.99,"shippingWeight":"0.25"}
    {"_id":{"$oid":"573f7197f29313caab89b225"},"sku":20000105,"name":"Dance Dance Revolution - CD","type":"Music","regularPrice":11.99,"salePrice":11.99,"shippingWeight":"0.25"}
    
    가져오기 옵션 확인
    bash-4.4# mongoimport --help
    Usage:
      mongoimport <options> <file>
    
    Import CSV, TSV or JSON data into MongoDB. If no file is provided, mongoimport reads from stdin.
    
    See http://docs.mongodb.org/manual/reference/program/mongoimport/ for more information.
    

  • https://docs.mongodb.com/database-tools/mongoimport/(새 버전용)
  • host는 localhost
  • port 지정
  • 필요
  • usename/password 지정
  • mongoimport --port 27000 -u m103-application-user -p m103-application-pass \
       --authenticationDatabase admin \
       --db applicationData --collection products \
       --file /dataset/products.json
    
    2020-12-19T12:33:31.575+0000    connected to: mongodb://localhost:27000/
    2020-12-19T12:33:31.970+0000    9966 document(s) imported successfully. 0 document(s) failed to import.
    
    잘 되고 있나 봐요.

    테스트 실행 시 확인!

    오늘의 진전


    Chapter 1 완성!
    다음이 드디어 발표된다.웹의 IDE에서는 도대체 어떻게 훈련을 진행합니까?
    그리고 다음은 30step...
    목표는 열흘 뒤, 29일쯤이죠.

    오늘의 젠.


    계속해서 같은 방법으로 진행되고 있다.
    각주
    M103: Basic Cluster Administration세트.수업을 시작하면 이수까지의 기한은 두 달 이내이다.↩︎

    좋은 웹페이지 즐겨찾기