ubuntu t2.micro magnatic 8GB


$ sudo apt-get update

* LC_ALL 설정

/home/ubuntu/.bashrc 에 다음 추가

export LC_ALL="en_US.UTF-8"

* shell update

source .bash_profile



* mongoDB 설치

(http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/)


* mongoDB Setting

Now configure the following MongoDB parameters by editing the configuration file /etc/mongod.conf:

dbpath = /data
logpath = /log/mongod.log

* db path에 db폴더 만들고 권한 바꿔주기

$ sudo mkdir /data/db

$ sudo chown ubuntu /data/db


* 몽고 서비스 시작

$ sudo service mongod start


* For deployment

$ sudo apt-get install git

$ sudo apt-get install libxml2-dev libxslt1-dev python-dev

# $ sudo apt-get install python-pip

wget http://peak.telecommunity.com/dist/ez_setup.py

sudo python ez_setup.py

$ sudo easy_install requests==2.3.0

$ sudo easy_install -U pip


nginx

1
2
3
4
sudo aptitude install software-properties-common;
sudo add-apt-repository ppa:nginx/development;
sudo apt-get update;
sudo apt-get install nginx;

* 몇몇 mac과 별도로 설치한 module들

$ sudo pip install --no-use-wheel --upgrade distribute

$ sudo pip install cssselect

$ sudo apt-get install python-lxml

$ sudo pip install w3lib

$ sudo pip install tzlocal

$ sudo apt-get install nodejs (for javascript runtime)

$ sudo pip install futures


* server / job log file 생성

$ mkdir server/log

$ touch server/log/log.txt

$ touch server/log/job.txt

$sudo chown -R mongodb:mongodb /data /log /journal
* mongod 띄울때 기본적으로 localhost 만 붙을 수 있도록

bind_ip = 127.0.0.1

설정이 되어있다. remote에서 붙게 하려면 이걸 빼줄것!


'aws' 카테고리의 다른 글

kinesis firehose 삽질일기  (0) 2017.03.16
How to EC2 disk and memory usage monitoring  (0) 2015.03.27
elasticache dump to file  (1) 2015.03.23
HTTP 505: HTTP Version Not Supported  (0) 2014.07.09
boto s3 Broken pipe error  (0) 2014.04.25
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

1. install

brew install nginx


2. configuration

/user/local/etc/nginx/nginx.conf

보통 위 conf에서 server부분을 따로 따서 각 필요한 서버마다 만들어놓고 include 해서 쓴다고 한다.

따라서,

/user/local/etc/nginx/sites-available/mysite

를 만들고 아래와 같이 설정한다.

upstream frontends {

server 127.0.0.1:12000;

server 127.0.0.1:12001;

# fair no_rr;

}


server {

listen 15000;


# Allow file uploads

client_max_body_size 1M;


location / {

try_files $uri $uri/ @node;

}


location @node{

proxy_pass_header Server;

proxy_set_header Host $http_host;

proxy_redirect off;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Scheme $scheme;

proxy_pass http://frontends;

}


location ^~ /static {

alias /Users/ytkang/Development/webtoon/static;

}


# location /nginx_status {

# stub_status on;

# access_log off;

# allow 127.0.0.1;

# deny all;

# }

} 



그리고 /usr/local/etc/nginx/sites-enabled/에 사용할 것들을 넣어놓고 쓰는 형태로 많이들 쓴다고 한다.

따라서 위에서 만든 놈을 여기에 링크를 걸자

ln -s /usr/local/etc/nginx/sites-available/mysite /usr/local/etc/nginx/sites-enabled/mysite

그리고 sites-enabled에 있는놈을 config 파일에서 import

$ vim /usr/local/etc/nginx/nginx.conf

 include       /usr/local/etc/nginx/sites-enabled/*;

* 주의할 점은 이미 nginx.conf에 있는 설정중 mysite에 있는 설정과 겹치는 부분은 지워줘야! 또한 sites-enabled/default도 지워줘야!


3. start / restart

서버 시작: $ sudo nginx

서버 재시작: $ sudo nginx -s reload


* 만약 위 설정중 "fair no_rr"을 사용하려고 한다면

nginx: [emerg] unknown directive "fair"

이런 에러를 직면할 것이다. 이는 fair를 사용하려면 따로 깔아야하기 때문!

여기서 설치: http://wiki.nginx.org/HttpUpstreamFairModule


'nginx' 카테고리의 다른 글

Loadbalancer를 통해서 올때 client ip가 전달되도록하는 방법  (0) 2018.01.12
nginx log ratation  (0) 2015.04.06
ssl setting  (0) 2015.03.12
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

5rocks 고찰

mornitoring 2014. 9. 11. 16:59

Case. 이전 10일동안 들어오지 않은 유저에게 보상을 보내서 들어오게 하고싶다.

1. 이 유저들에게 푸시를 보내야 한다.

2. 이 유저들이 들어왔을때 보상을 주는 팝업을 띄운후 그 팝업을 본 유저들에게 보상을 줘야 한다.

문제점: 

 - 푸시는 특정 시간 이전에 계산된 지표로 보내진다. 따라서 2번 조건(실시간 캠패인. 캠패인 은 푸시와 다르게 실시간으로 조건이 맞는 유저에게 보내진다.)에 오늘까지가 들어간다면 상이한 결과가 나타날 수 있다. (푸시를 받았는데 보상은 없는등..) 

 - 유저 분류가 디바이스 기준이다. 따라서 두개의 디바이스를 사용한적이 있는 유저고 앱이 둘다 깔려있다면, 하나의 디바이스에서 조건이 맞으면 푸시와 보상을 챙길수 있다. (한명의 유저가 두개의 다른 데이터를 가지고 있게되는 현상)

블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

Shallow copy VS Deep copy

python 2014. 8. 27. 13:22

shallow copy란 object는 새로 생성하되 그안에 있는 값들은 참조 한다는 소리고, 

deep copy란 안에있는 값을 참조하지 않고 복사해온다는 소리.


참조.

1. https://docs.python.org/2/library/copy.html

2. http://kkoseul.tistory.com/m/post/53

'python' 카테고리의 다른 글

gunicorn vs uwsgi  (0) 2017.01.20
flask async response  (0) 2017.01.04
functools.wraps에 대해  (0) 2015.04.15
Apple Push Notification Service(APNs) python modules  (0) 2015.04.07
Getting specific timezone timestamp from time string  (0) 2015.01.20
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

프로젝트 간단 설명: 테이블에 있는 NFC에 휴대폰을 테깅하여 웹브라우져 메뉴를 띄워 원격 주문.


*목차

1. 주문화면 스크린샷

2. 주문 시연 동영상

(아래 나오는 꾼노리 및 꾼노리 안산점 지점과는 무관한 데모 프로젝트 입니다.)


1. 주문화면 스크린샷





2. 주문 시연 동영상






'Released, Demo' 카테고리의 다른 글

랜덤 라이프 보이스 채팅  (0) 2019.11.06
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

s3 upload 하다가 발생한 에런데 문제는 파일이름에 특문이 들어가 있어서 였다.

'aws' 카테고리의 다른 글

kinesis firehose 삽질일기  (0) 2017.03.16
How to EC2 disk and memory usage monitoring  (0) 2015.03.27
elasticache dump to file  (1) 2015.03.23
[ubuntu server instance] mytoon setting  (0) 2014.10.24
boto s3 Broken pipe error  (0) 2014.04.25
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

Official Tutorial

기본적으로 이걸 따르는데, 하나가 빠졌다.

일단, OpenCV Tutorial 1 - Camera Preview를 가지고 테스트 했는데,

public void onResume()

{

    super.onResume();

    // OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);

    mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);

} 

onResume에서 onManagerConnected를 호출해 줘야 한다.


Check list

1. Project Properties에 C/C++ 메뉴가 없다

프로젝트 폴더에 마우스 오른쪽 버튼을 클릭 -> Android Tools -> Add Native Support.. -> 공백 없는 마음에 드는 이름으로 쓰고 finish.

끝.


2. Project마다 맨처음에 ndk-build를 못찾아서 에러가 날수 있는데, NDKROOT variable설정을 해줘야 ${NDKROOT}를 인식할 수 있다. 

(환경설정(Preference)에서 Android->NDK에 NDK Location은 설정 해놨다고 가정)

환경설정(Preference) -> C/C++ -> Build -> Build Variables -> Add

Name: NDKROOT

Type: Directory

Value: ndk folder를 browse 해서 넣어줌.

만약, 에러가 사라지지 않는다면 -> 프로젝트 오른쪽버튼 클릭 -> Android Tools -> Fix Project Properties 클릭 -> clean build -> Build project.

끝.


3. 위 튜토리얼의 두가지 방법중 llibs 폴더 추가하고 복사하면 끝나는 간단한 과정이 있는 반면, 두번째 꺼는 약간 복잡해 보인다. 하지만 c++코드를 쓴다면 반드시 해줘야 하는것. 그리고 복잡하지도 않다.
일단, 1번을 따라해서 프로젝트 폴더에 jni폴더가 생기게 한뒤 튜토리얼에 나와있는데로 하면되고, 만약에 안된다면, 여기를 참고해서 Application.mk를 추가로 만든다.

끝.


블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

MMS

mongoDB/MMS 2014. 7. 3. 10:57

MongoDB Management Service)


* 이점

- Serviced by MongoDB Guys

- Super easy setup and Fancy features (Monitoring + Backup)

- Clear and Clean Dashboard

- Group Alerts (Pager, Email, Hipchat..)

- API Supported


* 유의사항
하나의 MongoDB 세트는 독립된 그룹으로 관리하도록하고 Agent가 사용하는 ApiKey는 각 그룹마다 하나씩 발급된다.
즉, 1개의 MongoDB 세트 = 1개의 그룹 = 1개의 ApiKey = 1개의 Agent (복제 목적으로 여러개 가능, 그러나 한개면 됨)


'mongoDB > MMS' 카테고리의 다른 글

Setting Backup  (0) 2014.07.03
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

Setting Backup

mongoDB/MMS 2014. 7. 3. 10:57

일단, Backup을 셋팅하기 위해서는 Backup을 저장할 instance가 하나 필요하고 이곳에는 mongod가 실행되어있어야 한다. type은 sharded 또는 replica-set으로 되어있어야 하며 standalone으로 되어있으면 mms에서 Backup용으로 감지가 안된다. 또한 MMS에서 Backup용으로 감지되기위해서는 monitoring agent와 backup agent가 설치되어있어야 한다.


정리하자면 Backup용 instance에 아래 1,2,3번이 설치되어있고 4번이 설정되어있으면됨.

1. mongod

2. monitoring agent

3. backup agent

4. db sharding or replica set 설정

(sharded 된 벡업 db를 쓴다면 각 디비 instance에 2,3번을 설치할 필요는 없고 config서버에만 설치하면된다. sharding이 안되어있고, replica set하나인 경우는 primary에만 설치되면 된다)


요 설정이 끝나면, MMS에서 Backup 탭을 눌렀을때 자동으로 감지가 된다. 이후 부터는 설정된 주기에 따라 자동으로 Backup된다.


* MMS Monitoring Agent 설치
에이전트는 MMS 서버로 주기적으로 Optlog 를 보내는 프로세스이며 하나만 설치해놓으면 모든 Mongo 관련 호스트들을 알아서 파악한다. 또한, 에이전트는 어느정도 네트워크 리소스를 먹기때문에 Mongod가 실행 중인 머신에는 설치하지 말고 Mongos나 Dedicated 서버에 띄우길 권장한다. Mongod가 5개 이하면 EC2 Micro에 띄워도 된다고 함. 그리고 복제 목적으로 에이전트를 두개를 띄울 수도 있겠으나 별로 그럴일은 없을거다라고 함.

 

1. Download the 32-bit or 64-bit deb package.

$ curl -OL https://mms.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_2.1.0.35-1_amd64.deb

2. Install the package
$ sudo dpkg -i mongodb-mms-monitoring-agent_2.1.0.35-1_amd64.deb

3. Edit /etc/mongodb-mms/monitoring-agent.config and enter your API key, as shown below
$ mmsApiKey=6d2f19515939c45d6905ef9f0d584e1c

4. Start the agent
$ sudo start mongodb-mms-monitoring-agent

5. Continue to setup @ mms console


* 호스트 추가시 팁

에이전트는 기본적으로 모든 정보를 알아서 MMS에 전송하는데(Outbound only) MMS 콘솔에서 호스트에 대한 자세한 정보를 맵핑시켜놓기 위해 호스트를 추가하는 메뉴가 있다. 그런데 이때 묻는 정보들에 당황하지 않고, 다음의 팁들을 염두하고 입력하면 수월할지어다.

- 호스트 타입은 Standalone / Shard Cluster / Replica Set / Master Slave 가 있다.

- Standalone 은 Config 서버 입력할때 쓰면 좋다.

- Shard Cluster 는 Mongos 서버 입력할떄 쓰면 좋다. (보통 이거 하면 알아서 Replica Set 다 찾아줌)

- Replica Set / Master Slave 로 구성했다면 요걸로 고르면 됨.

- 그리고 호스트네임은 수집된 정보에서 호스트 식별해내기 위한 것으로 Public IP / Private IP 구분 없다. (울 서버에 Inbound 요청하려고 하는것이 아님)


* MMS Backup Agent 설치

The Backup Agent requires network access. To avoid contention for network and CPU resources, we recommend running the Backup Agent on a separate host from your mongod instances. Performance impact on the cluster is similar to adding an additional secondary node. The Backup agent has the same performance profile impact as a secondary. For the initial backup, the load scales with the size of your data set. Once an initial backup exists, the load scales with oplog gigabytes used per hour. Within the US, MMS Backup sends snapshots at 50-100Mbps. Assuming a compression factor of 4x and transmission speeds of 50Mbps, a 250 GB snapshot will take 2.5 hours.  

 

1. Download the 32-bit or 64-bit deb package.

curl -OL https://mms.mongodb.com/download/agent/backup/mongodb-mms-backup-agent_1.4.6.43-1_amd64.deb

 

2. Install the package

sudo dpkg -i mongodb-mms-backup-agent_1.4.6.43-1_amd64.deb

 

3. Edit /etc/mongodb-mms/backup-agent.config and enter your API key, as shown below

apiKey=6d2f19515939c45d6905ef9f0d584e1c

 

4. Start the agent 

$ sudo start mongodb-mms-backup-agent



* References

https://jira.mongodb.org/secure/attachment/34148/backup-manual.txt 

'mongoDB > MMS' 카테고리의 다른 글

MMS  (0) 2014.07.03
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,

boto s3 Broken pipe error

aws 2014. 4. 25. 21:44

Problematic Code

1
2
conn = S3Connection(settings.AWS_ACCESS_KEY,
                    settings.AWS_ACCESS_SECRET)

Code with no problem

1
2
3
conn = S3Connection(settings.AWS_ACCESS_KEY,
                    settings.AWS_ACCESS_SECRET,
                    host="s3-ap-southeast-1.amazonaws.com") # Specify


'aws' 카테고리의 다른 글

kinesis firehose 삽질일기  (0) 2017.03.16
How to EC2 disk and memory usage monitoring  (0) 2015.03.27
elasticache dump to file  (1) 2015.03.23
[ubuntu server instance] mytoon setting  (0) 2014.10.24
HTTP 505: HTTP Version Not Supported  (0) 2014.07.09
블로그 이미지

시간을 거스르는자

ytkang86@gmail.com

,