StoryCode

'분류 전체보기'에 해당되는 글 563건

  1. MongoDB vs MySQL CRUD 비교
  2. 성능 최적화 전략
  3. 기초사용법
  4. 설치 ( Windows )
  5. Elastic Search 란
  6. 연습) Hello, World.
  7. 각종 설치 참조
  8. Atom 설치
  9. 설치 (Windows)
  10. GIT

MongoDB vs MySQL CRUD 비교

Database 관리/Mongo DB
반응형

- Scalability : Max ScaleUp vs Many ScaleOut

 

- Scale Up의 한계

  * 연결16개부터 성능향상 없음.

  * CPU Core 16 개부터 성능향상 없음.

 

- CAP 이론

  * MongoDB 는 C-P

 

- ACID 이론

 

 

- NoSQL(MongoDB) VS RDBMS(MySQL)

  * 동일한 데이터에 대해 CRUD 연산

  * 2개 이상의 클라이언트를 연결하여 연산 시도

  * MongoDB 는 싱글노드, 멀티노드를 구분하여 작업

  * 데이타 구하기 : https://www.data.gov/tools/123

  (https://www.data.gov/climate/ecosystem-vulnerability/ecosystem-vulnerability-tools/123)

 

 

[참고] https://www.slideshare.net/WooYeongChoe1/slidshare-mongodbmysqlcrud

반응형

'Database 관리 > Mongo DB' 카테고리의 다른 글

성능 최적화 전략  (0) 2019.04.21
기초사용법  (0) 2019.04.18
설치 ( Windows )  (0) 2019.04.18
용어  (0) 2019.04.16

성능 최적화 전략

Database 관리/Mongo DB
반응형

- 데이터 모델링.References

db.member_tbl.find({memberid:'abc'});  와 같이 find 하면,
   { "_id" : ObjectId("5cb82543ffd1c1ef601f0350"), "memberid" : "abc" }

위와 같이 _id 의 ObjectId 가 있으며, _id 로 검색도 가능함. 즉 _id 를 다른 Collection 에넣고 참고 하는 방법이 가능.

   db.member_tbl.find({_id:ObjectId('5cb82543ffd1c1ef601f0350')}); 

 

- 데이터 모델링.BSON

  Binary 는 최대 16MB.

 

- Index

  * 각 Index 는 8KB 의 데이타 공간 필요.

  * Index 는 system.indexes Collection 에 저장됨 : db.system.indexes.find() 로 Index 확인 가능.

  * Index 생성 : db.member_tbl.ensureIndex({"username":1, "hpno":-1}, {"name":"idx_member_tbl"}, {"unique":true},}{"dropDups":true}, {"background":true}) # 1은 오름차순. -1 이면 내림차순. background 는 백그라운드로 생성.

                  ensureIndex = createIndex

  * Index 확인 : db.member_tbl.getIndexes()

  * Index 삭제 : db.member_tbl.dropIndex("name_1")

db.runCommand({"dropIndexes":"user", "index":"*"})

 

- Spatial Index

  * db.map_tbl.ensureIndex({"gps":"2d"})

  * Ex> {"gps":[0,100]}, {"gps":{"x":30,"y":30}}, {"gps":{"lat":30,"long":30}}

  * db.map_tbl.ensureIndex({"gps2":"2d"}, {"min":-1000, "max":1000})

    이 경우오류 발생함 : db.map_tbl.insert({"gps2":{-1001, 0}})

  * 참고 : https://docs.mongodb.com/manual/core/geospatial-indexes/

- Multikey Index

  Array Field Index

 

- Text Index

  * String 컨텐츠에 대한 Index

  * 참고 : https://docs.mongodb.com/manual/core/index-text/

 

- Hashed Index

  db.member_tbl.createIndex({"a":"hashed"})

 

- PLAN 확인.explain

  db.member_tbl.find().sort({"$natural":-1}).explain("executionStats")

 

- Capped Collection ( 제한 컬렉션 )

  * 고정사이즈. Insert, Retrive 시 high-throughput.

  * Insert 순서 보장.

  * 정렬을 위한 인덱스 불필요. 오버헤드 없이 higher insertion throughput.

  * db.createCollection("log", { capped:true, size:100000}}

  * Document 개수 제한 : db.createCollection("log", { capped:true, size:100000, max:5000}}

  * Document 는 항상 입력순서대로 원형큐에 저장

  * 큐가 다 찼을 경우, 오래된 문서부터 대치됨.

  * 역순서 정렬 : db.user.find().sort({"$natural",-1})

 

 

 

 

 

 

 

 

 

[ 참조 ] https://www.slideshare.net/mrg7211/mongo-db-52216593

반응형

'Database 관리 > Mongo DB' 카테고리의 다른 글

MongoDB vs MySQL CRUD 비교  (0) 2019.04.21
기초사용법  (0) 2019.04.18
설치 ( Windows )  (0) 2019.04.18
용어  (0) 2019.04.16

기초사용법

Database 관리/Mongo DB
반응형

실행) "C:\Program Files\MongoDB\Server\4.0\bin\mongo.exe"

 

DDL) db.help() 참조

DB 생성 : use DB명. Collection 을 하나 생성해야 show dbs 에 보인다.

DB 선택 : use DB명. 이미 DB명이 있으면 선택. 없으면 생성됨.

DB 삭제 : use DB명 후 db.dropDatabase()

현재 DB 보기 : db 혹은 db.getName()

 

COLLECTION 생성 : db.createCollection("member_tbl") 혹은 insert cllection 시 자동 생성

                          생성시 옵션으로 db.createCollection("member_tbl", "{capped:true, autoIndex:true,size:6142800,max:10000}") 등을 줄 수 있다.

COLLECTION 삭제 : db.member_tbl.drop()

 

DML) 1 row = 1 Document

https://docs.mongodb.com/manual/tutorial/insert-documents/

https://docs.mongodb.com/manual/tutorial/query-documents/

https://docs.mongodb.com/manual/tutorial/update-documents/

https://docs.mongodb.com/manual/tutorial/remove-documents/

 

Ex> 사용 예제

> show dbs

admin    0.000GB

config    0.000GB

local      0.000GB

 

> use mydatabasename

> db.member_tbl.insert({memberid:'userid', memberpwd:1234, info:{membername:'hongildong', age:34}});

> show dbs

admin    0.000GB

config    0.000GB

local      0.000GB

mydatabasename 0.000GB

> show collections

member_tbl

db.member_tbl.find({memberid:'userid'})

> db.member_tbl.remove({memberid:'userid', justOne:false}); # 전체 삭제

 

[ 참조 ]

https://velopert.com/457

반응형

'Database 관리 > Mongo DB' 카테고리의 다른 글

MongoDB vs MySQL CRUD 비교  (0) 2019.04.21
성능 최적화 전략  (0) 2019.04.21
설치 ( Windows )  (0) 2019.04.18
용어  (0) 2019.04.16

설치 ( Windows )

Database 관리/Mongo DB
반응형

다운로드 후 설치시, Windows 7 에서는 진행이 안되는 경우가 발생할 수 있다.

Compas 문제인데, Windows 8 부터 지원한다.

이 경우에는 아래지시를 따른다.


1. Run the installer with a double-click.

2. Click next.

3. Accept the License Agreement

4. Select the Complete installation type and click Instal

5. Uncheck the Install Compass option (by default this checked and Compass requires the Microsoft .NET Framework version 4.5 or later

6. With in a minute time installation will get complete and you can see the exe files under C:\Program Files\MongoDB\Server\3.6\bin

 

[ 참조 ] https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/

반응형

'Database 관리 > Mongo DB' 카테고리의 다른 글

MongoDB vs MySQL CRUD 비교  (0) 2019.04.21
성능 최적화 전략  (0) 2019.04.21
기초사용법  (0) 2019.04.18
용어  (0) 2019.04.16

Elastic Search 란

Elastic Search
반응형

- 실시간 분산 검색엔진 서버

- 오픈 소스

- 아파치 Lucene 기반

- JSON 기반 비정형 데이타 분산 검색과 분석 지원

- 설치, 확장이 용이

- 실시간 검색 서비스 지원, 분산 및 병령 처리, 멀티태넌시 기능 지원

- 아마존 웹 서비스의 클라우드 서비스와 빅 데이터 처리를 위한 하듭 연동 지원

 

고가용성

 

Elasticsearch 는 동작중에 죽은 노드를 감지하고 삭제하며 사용자의 데이터가 안전하고 접근가능하도록 유지하기 때문에, 동작 중에 일부 노드에 문제가 생기더라도 문제없이 서비스를 제공합니다.

 

 멀티 테넌시

 

클러스터는 여러개의 인덱스들을 저장하고 관리할 수 있으며, 독립된 하나의 쿼리 혹은 그룹 쿼리로 여러 인덱스의 데이터를 검색할 수 있습니다.

 

 전문 검색(Full text search)

 

Elastic search는 강력한 full text search를 지원합니다.

 

 문서 중심(Document oriented)

 

복잡한 현실세계의 요소들을 구조화된 JSON 문서 형식으로 저장합니다. 모든 필드는 기본적으로 인덱싱되며, 모든 인덱스들은 단일 쿼리로 빠르게 사용할 수 있습니다.

 

 Schema free

 

JSON 문서 구조를 통해 데이터를 인덱싱하고 검색가능하게 합니다. (NoSQL과 같은 스키마가 개념이 없음) 그리고 사용자의 데이터가 어떻게 인덱싱 될 것인가에 대한 것은 사용자가 커스터마이징 할 수 있습니다.

 

 플러그인 형태 구현

 

검색엔진을 직접 수행하지 않고 필요한 기능에 대한 플러그인을 적용하여 기능을 확장할 수 있습니다. 예를 들어 외부에서 제공하는 형태소 분석기나 REST API를 구현하여 적용할 수 있습니다.

 

[ 참조 ]

반응형

연습) Hello, World.

Node.js
반응형

1. HTTP Methods(HTTP-Verbs) - GET, POST, PUT, PATCH, DELETE

HTTP Methods ( = HTTP Verbs)의 종류 : GET, POST, PUT, PATCH, DELETE

참고) resource 의 종류 : html, binary(image, sound), db (db, json, xml, flat)

 

GET : 조회

POST : 등록

PUT : 수정(없을시 등록). 한 컬럼만 업데이트시에도 모든 컬럼 업데이트.

PATCH : 수정. 한 컬럼만 업데이트시 한 컬럼만 업데이트.

DELETE : 삭제

 

2. Express로 서버 실행하기 (GIT : https://github.com/a-mean-blogger/hello-world/tree/eaa13c5356ebaa06bd14df80bee96edb085fac46)

 

$ git clone https://github.com/a-mean-blogger/hello-world.git
$ cd hello-world
$ git reset --hard eaa13c5
$ npm install
$ atom .

 

위 git clone 없이 직접 해보기

$ git init

$ npm init

$ touch index.js

$ npm install --save express

$ atom . ( 혹은 vi index.js )

   index.js 에 아래 내용 입력

   -----------------------------------------

var express = require('express')
var app = express();

app.get('/', function (req, res) // '/' 로 get 요청시
{
  res.send('Hello World!');
})

app.listen(3000, function()
{
  console.log('Server On!');
})

   -----------------------------------------

$ node index.js

   Server On!

그리고, Chrome> localhost:3000 으로 접속하면, Hello World! 가 보인다.


3. Static 폴더 추가하기

index.js 를 아래내용으로 변경

// index.js

var express = require('express');
var app = express();

 

// __dirname = 현재 실행 위치

// app.use : 브라우저에서, / 으로 접속하면 /public/ 에 변경접속, /css 으로 접속하면 /public/css 으로 변경접속

// css 나 html 같은 고정 파일 위치에 사용한다. 아래 "4. EJS로 Dynamic Website" 에서 <link> 태그에 public 이 없어도 public 을 참조하게 된다.
app.use(express.static(__dirname + '/public')); 

app.listen(3000, function(){
 console.log('Server On!');
});

 

 

$ node index.js #재실행

   Server On!

그리고, Chrome> localhost:3000 으로 접속하면, 주황색 Hello World! 가 보인다.

 


4. EJS로 Dynamic Website 만들기

* 용어.EJS) EJS는 Embedded Javascript의 약자로 Express에서 dynamic website를 만들기 위해 template으로 사용되는 파일(확장자 이름은 .ejs)입니다.

 

$ npm install --save ejs # ejs 설치

 

> views 폴더와 views/hello.ejs 파일 추가

 

> index.js 내용 변경 -----------------------------------------

// index.js

var express = require('express');
var app = express();

app.set("view engine","ejs"); // ejs를 사용하기 위해서 express의 view engine에 ejs를 set하는 코드입니다.

 

// 이 라인을 없으면, 앞 views 옵션은 기본으로 views 폴더(뒤)를 가르키지면, 명시적으로 적어주자.

// 뒤의 views 는 사용자 마음대로 바꿀 수 있다.

// views 는 res.render 에서 사용된다.

app.set("views", "views"); 


app.use(express.static(__dirname + '/public'));

// 2
app.get("/hello", function(req,res){ //  http://localhost:3030/hello 호출시
 res.render("hello", {name:req.query.nameQuery}); // render 에는 hello.ejs의 파일명부분과  파라미터를 넘겨준다.
}); 

// 3
app.get("/hello/:nameParam", function(req,res){  //  http://localhost:3030/hello/이름 호출시
 res.render("hello", {name:req.params.nameParam});  // render 에는 hello.ejs의 파일명부분과  파라미터를 넘겨준다.
});

app.listen(3000, function(){
console.log('Server On!');
});

 

 

> views/hello.ejs 에는 아래 내용 추가

2

<!-- views/hello.ejs -->

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
  <title>Hello World!</title>
  <link rel="stylesheet" href="/css/master.css">
 </head>
 <body>
  <h1>Hello
   <% if(name){ %>
    <span class="name"><%= name %>!</span>
   <% } else { %>
    <span class="stranger">Stranger!</span>
   <% } %>
  </h1>
 </body>
</html>

 

> http://localhost:3000/hello 와 localhost:3000/hello/superman 으로 접속테스트 해보자.

 

[참조] https://www.a-mean-blog.com/ko/blog/Node-JS-%EC%B2%AB%EA%B1%B8%EC%9D%8C/Hello-World/HTTP-Methods-HTTP-Verbs-GET-POST-PUT-PATCH-DELETE

 

반응형

'Node.js' 카테고리의 다른 글

각종 설치 참조  (0) 2019.04.17
Atom 설치  (0) 2019.04.17
설치 (Windows)  (0) 2019.04.16
내장 모듈  (0) 2018.10.31
Process 객체, exports 객체  (0) 2018.10.31

각종 설치 참조

Node.js
반응형

GIT : https://storycode.tistory.com/194

 

Atom : https://storycode.tistory.com/196

반응형

'Node.js' 카테고리의 다른 글

연습) Hello, World.  (0) 2019.04.17
Atom 설치  (0) 2019.04.17
설치 (Windows)  (0) 2019.04.16
내장 모듈  (0) 2018.10.31
Process 객체, exports 객체  (0) 2018.10.31

Atom 설치

Node.js
반응형

1) https://atom.io설치

 

2) Atom Package 설치

File > Setting > Search packages 에서, 아래 패키지 각각 설치

 

highlight-selected

linter

linter-jshint

linter-csslint

file-icon-supplement

atom-runner

 

3) javasript 실행시 Alt + R

반응형

'Node.js' 카테고리의 다른 글

연습) Hello, World.  (0) 2019.04.17
각종 설치 참조  (0) 2019.04.17
설치 (Windows)  (0) 2019.04.16
내장 모듈  (0) 2018.10.31
Process 객체, exports 객체  (0) 2018.10.31

설치 (Windows)

Node.js
반응형

1) https://nodejs.org에  > INSTALL

 

2) LTS 나 최신 버전 다운로드후 설치

 

3) Bash 에서 확인

$ node -v

$ npm -v

 

[참조] https://www.a-mean-blog.com/ko/blog/MEAN-Stack/%EA%B0%9C%EB%B0%9C-%ED%99%98%EA%B2%BD-%EA%B5%AC%EC%B6%95/Node-JS-NPM-%EC%84%A4%EC%B9%98

반응형

'Node.js' 카테고리의 다른 글

각종 설치 참조  (0) 2019.04.17
Atom 설치  (0) 2019.04.17
내장 모듈  (0) 2018.10.31
Process 객체, exports 객체  (0) 2018.10.31
API  (0) 2018.10.31

GIT

SCM(Software Configuration Management)
반응형

1) 설치

https://git-scm.com

git bash 는 포함되게 설치

 

GUI Tool : https://git-scm.com/downloads/guis

 

 

2) GitHub 가입

https://github.com

 

[ 참조 ] https://www.a-mean-blog.com/ko/blog/MEAN-Stack/%EA%B0%9C%EB%B0%9C-%ED%99%98%EA%B2%BD-%EA%B5%AC%EC%B6%95/Git-%EC%84%A4%EC%B9%98%EB%B0%8F-GitHub-%EA%B0%80%EC%9E%85

 

3) Bash 사용법

Windows 시작바 > Git bash 실행

cd, make, touch, ls 등 사용가능

 

Ex>

bash> mkdir workspace

bash> cd workspace

bash> mkdir myapp

bash> cd myapp

bash> touch app.js

 

4) Git 기본 사용법

4-1) use.email 과 user.name 등록

$ git config --global user.email "[이메일주소]" #email을 등록

$ git config --global user.name "[이름]" #name을 등록

 

4-2) 저장소 생성 및 commit 생성

$ git init # 해당 퐁더에 git 를 사용할 것을 알림. master bransh 가 생성됨. 현재 폴더명에 branch 이름(master) 추가 됨

            # .git 숨길 폼더는 절대 노 터치

 

$ git add . or git add -A # 현재 폴더의 파일들과 하위 폴더의 파일 모두를 저장할 대상으로 지정합니다. = cvs add

 

$ git commit -m "message"

 

$ git log --oneline # 현재 저장된 commit list 를 요약해서 (--online) 보여줍니다. 7 자리commit id 로 명령 수행가능

 

5) Git 추가 사용법

5-1) 이전 commit 으로 돌아가기

text.txt 등록 + commit 후, commit 이전으로 돌리기

 

touch text.txt

git add .

git commit -m "text.txt added"

git log --oneline

#여기에 7자리 commit id 보임

git reset --hard commit id or git reset --soft commit id # hard 는 text.txt 파일도 삭제, soft 는 파일은 보존.

 

 

5) 생성한 프로젝트를 GitHub 에 올리기

1) 우측 상단 + 아이콘 > New Repository

 

2) 정보 입력 후 Create Repository 클릭

  • Repository Name 저장소 이름을 입력합니다. 한 유저 계정안에서 중복될 수 없으며 URL주소로 사용되기 때문에 URL주소로서 유요한 문자만 사용가능합니다.
  • Description 저장소에 대한 간략한 설명을 적는 곳인데 안적어도 됩니다.
  • Public 저장소를 공개로 설정합니다. 공개설정된 저장소는 누구나 볼 수 있습니다.
  • Private 무료사용자는 비공개로 설정할 수 없습니다.
  • Initialize this repository with a README 저장소를 README 파일과 함께 생성합니다. 일단 체크하지 말고 진행합시다.
  • Add .gitignore .gitignore파일을 생성합니다. 일단 None으로 둡시다.
  • Add a lincense license를 추가합니다. 일단 None으로 둡시다.

3) 올리기

$ git remote add origin https://github.com/a-mean-blogger/test-repo.git # git 주소는 GitHub Project 클릭하면 나옴.

   # origin에 온라인(remote) 저장소 주소를 등록(add)합니다.

$ git push origin master # origin에 master branch를 업로드합니다.

 

6) 내려받기

$ cd workspace

$ git clone https://github.com/a-mea-nblogger/test-repo.git 

$ cd test-repo

$ git log --oneline

 

반응형