백엔드 서비스 개발
MongoDB
MongoDB가 뭐지?
몽고 디비는 JSON기반의 데이터베이스이다. 대학교에서 죽어라고 배웠던 MySQL 데이터베이스는 Relational Database로 테이블 간의 관계로 저장할 데이터의 구조를 설정하는 형태이다. 반면 몽고 디비는 특정한 구조 없이 JSON Object를 모아놓은 저장소라고 생각하면 된다.
학부때 진행했던 숙제를 제외하고 만드는 대부분의 어플리케이션들은 사실 엄청나게 큰 규모의 프로젝트들이 아니다. 당신은 이러한 소규모 프로젝트를 진행할 때 MySQL을 선택할 것인가 아니면 MongoDB를 선택할 것인가? 나라면 당연히 MongoDB를 선택할 것이다. 왜? 데이터의 구조화가 필요 없으니까! Normalization, Primary Key, Foreign Key 설정 등 디비 디자인이 거의 필요 없기 때문에 훨씬 더 빠른 속도로 프로젝트를 진행할 수 있게 된다.
MongoDB 설치부터 실행까지
- Mac 환경
- DigitalOcean 환경
MongoDB 설치되면 무슨 파일이 생기는 거야?
몽고 디비가 설치되면서 생기는 파일들에 대해서 알고 싶고
- 몽고 디비가 설치가 되어있는지 확인을 하고 싶은 것 => 만약에 로컬에 설치를 했다면 HTTP로 접속을 해보면 쉽게 알 수 있을 것이다.
- 그리고 몽고 디비를 어떻게 하면 백그라운드에서 돌릴 지 확인하는 방법 => sudo service mongod restart (애초에 mongod라는 녀석은 deamon으로 백그라운드에서 돌리는걸 가정하고 만든놈인듯) export LC_ALL=C mongo => BadValue Invalid
MongoDB에 Monitoring Client로 연결하려면?
그리고 몽고디비를 외부에서 접속하는 방법 등에 대해서 알고 싶다. (DigitalOcean) => 로컬에서는 아이디와 비번으로 접속하면 되지만, 디지털 오션의 경우에는 SSH로 접속하면 쉽게 접속할 수 있는 장점이 있다.
=> Admin 만드는 것 정리가 필요
몽고 디비의 Bind IP는 ... -> Bind IP is a MongoDB option that restricts connections to specifies IPs.
References
- https://www.youtube.com/watch?v=B7DHXF7WhMU&list=PLGOsbT2r-igmVfPljx7VXI8XX7hyS6vmP&index=2
- https://university.mongodb.com/courses/M102/about
- https://docs.mongodb.org/manual/tutorial/enable-authentication/
- http://www.mkyong.com/mongodb/mongodb-allow-remote-access/
- https://docs.mongodb.org/manual/reference/configuration-options/#configuration-file
Memcached
멤캐쉬드 정리
- http://code.tutsplus.com/tutorials/improve-your-apps-performance-with-memcached--net-26768 좋은 시작 article When you installed it, it put a file named homebrew.mxcl.memcached.plist in /usr/local/Cellar/memcached/$version/; you copy that file into ~/Library/LaunchAgentsand then tell launchd to start it with launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist. If you were watching the console carefully during the brew install command, it should have said something about doing these exact steps. If you run brew info it'll re-print this information, e.g. brew info memcached.
apt-get 으로 설치하면 memcache 6584 0.0 0.0 327448 3004 ? Sl 14:07 0:00 /usr/bin/memcached /usr/bin/memcached 에 설치됨
echo "stats settings" | nc localhost 11211
brew info memcached service memcached status (동작하는 것 확인)
NodeJS
nodejs - listen on port 0 in a cluster https://coderwall.com/p/jr7big/nodejs-listen-on-port-0-in-a-cluster
- Node.js 서버가 동작중인데, 이 서버 동작을 죽이지 않고 새로 업데이트한 파일을 반영하는 것이 가능할까? => 현재는 critical 하지 않지만 나중에는 고려해야하는 이슈이다.