ラベル MAC の投稿を表示しています。 すべての投稿を表示
ラベル MAC の投稿を表示しています。 すべての投稿を表示

2011年12月20日火曜日

ローカル環境でCassandraマルチノード起動

From Evernote:

ローカル環境でCassandraマルチノード起動

OS : MacOSX Lion
Cassandra : 1.0.x

1. IP loopback alias 追加
sudo ifconfig lo0 alias 127.0.0.2
sudo ifconfig lo0 alias 127.0.0.3
$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
     options=3<RXCSUM,TXCSUM>
     inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
     inet 127.0.0.1 netmask 0xff000000
     inet6 ::1 prefixlen 128
     inet6 fd76:4a17:61aa:f7df:60c:ceff:fee2:adb2 prefixlen 128
     inet 127.0.0.2 netmask 0xff000000
     inet 127.0.0.3 netmask 0xff000000

2. Cassandraインスタンスを3つ作成

3. 1つ目の設定
  - conf/cassandra.yaml
cluster_name: 'BABUKUMA Cluster'

# directories where Cassandra should store data on disk.
data_file_directories:
    - /Users/babukuma/Public/tmp/1_cassandra/data

# commit log
commitlog_directory: /Users/babukuma/Public/tmp/1_cassandra/commitlog

# saved caches
saved_caches_directory: /Users/babukuma/Public/tmp/1_cassandra/saved_caches

seed_provider:
    # Addresses of hosts that are deemed contact points.
    # Cassandra nodes use this list of hosts to find each other and learn
    # the topology of the ring.  You must change this if you are running
    # multiple nodes!
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          # seeds is actually a comma-delimited list of addresses.
          # Ex: "<ip1>,<ip2>,<ip3>"
          - seeds: "127.0.0.1"


listen_address: 127.0.0.1

rpc_address: 127.0.0.1

  - conf/cassandra-env.sh
JMX_PORT="7199"

  - conf/log4j-server.properties
log4j.appender.R.File=/Users/babukuma/Public/tmp/1_cassandra/logs/system.log


4. 2つ目の設定
  - conf/cassandra.yaml
cluster_name: 'BABUKUMA Cluster'

# directories where Cassandra should store data on disk.
data_file_directories:
    - /Users/babukuma/Public/tmp/2_cassandra/data

# commit log
commitlog_directory: /Users/babukuma/Public/tmp/2_cassandra/commitlog

# saved caches
saved_caches_directory: /Users/babukuma/Public/tmp/2_cassandra/saved_caches

seed_provider:
    # Addresses of hosts that are deemed contact points.
    # Cassandra nodes use this list of hosts to find each other and learn
    # the topology of the ring.  You must change this if you are running
    # multiple nodes!
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          # seeds is actually a comma-delimited list of addresses.
          # Ex: "<ip1>,<ip2>,<ip3>"
          - seeds: "127.0.0.1"


listen_address: 127.0.0.2

rpc_address: 127.0.0.2

  - conf/cassandra-env.sh
JMX_PORT="7299"

  - conf/log4j-server.properties
log4j.appender.R.File=/Users/babukuma/Public/tmp/2_cassandra/logs/system.log


5. 3つ目の設定
  - conf/cassandra.yaml
cluster_name: 'BABUKUMA Cluster'

# directories where Cassandra should store data on disk.
data_file_directories:
    - /Users/babukuma/Public/tmp/3_cassandra/data

# commit log
commitlog_directory: /Users/babukuma/Public/tmp/3_cassandra/commitlog

# saved caches
saved_caches_directory: /Users/babukuma/Public/tmp/3_cassandra/saved_caches

seed_provider:
    # Addresses of hosts that are deemed contact points.
    # Cassandra nodes use this list of hosts to find each other and learn
    # the topology of the ring.  You must change this if you are running
    # multiple nodes!
    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
      parameters:
          # seeds is actually a comma-delimited list of addresses.
          # Ex: "<ip1>,<ip2>,<ip3>"
          - seeds: "127.0.0.1"


listen_address: 127.0.0.3

rpc_address: 127.0.0.3

  - conf/cassandra-env.sh
JMX_PORT="7399"

  - conf/log4j-server.properties
log4j.appender.R.File=/Users/babukuma/Public/tmp/3_cassandra/logs/system.log


6. ディレクトリ作成
data, commit log, saved cache, log用のディレクトリ

7. 起動して確認
$ ./1_apache-cassandra-1.0.0/bin/cassandra -f &
$ ./2_apache-cassandra-1.0.0/bin/cassandra -f &
$ ./3_apache-cassandra-1.0.0/bin/cassandra -f &
$ ./1_apache-cassandra-1.0.0/bin/nodetool -h 127.0.0.1 ring
Address         DC          Rack        Status State   Load            Owns    Token                                      
                                                                               136429484281177578003895070040300449254    
127.0.0.2       datacenter1 rack1       Up     Normal  10.93 KB        50.00%  51358892550942962138051418182358396390     
127.0.0.3       datacenter1 rack1       Up     Normal  15.22 KB        25.00%  93894188416060270070973244111329422822     
127.0.0.1       datacenter1 rack1       Up     Normal  6.66 KB         25.00%  136429484281177578003895070040300449254  

2011年2月15日火曜日

OpenCV2.2をインストールした。

From Evernote:

OpenCV2.2をインストールした。

MacPortsからOpenCV2.2をインストール

MacPortsのport tree更新
$ sudo port selfupdate

OpenCVインストール
$ sudo port install opencv

OpenCVをPython2.6にバインディング(python使わないなら要らない)
$ sudo port -v install opencv +python26

インストール結果を確認すると
「/opt/local/bin」にユーティリティ
(opencv_createsamples,  opencv_haartraining, opencv_performance, opencv_traincascade)
「/opt/local/lib」にライブラリ
「/opt/local/include/opencv」にヘッダ
がインストールされている。


OpenCVの確認の為、あるサンプルをテストしてみる。
参照したサンプルは

この本のソースをOpenCV2.2用に修正したもの。


Command Line Tool プロジェクトを作成する。



有効なアーキテクチャを「i386」「x86_64」にする。



ヘッダ検索パスに「/opt/local/include」を追加

OpenCVグループを作って、「/opt/local/lib」のOpenCVライブラリを追加


「main.c」
#include <stdio.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>

int main (intargcconstchar * argv[]) {
char* szWndName="カメラ映像";
CvCapture* capture;
IplImage* img;
capture = cvCaptureFromCAM(0); // カメラ映像取得
if (capture==NULL) {
fprintf(stderr, "カメラが見つかりません。\n");
return -1;
}
cvNamedWindow(szWndName, CV_WINDOW_AUTOSIZE);
while (1) {
img=cvQueryFrame(capture); // フレーム取得
cvShowImage(szWndName, img); // フレーム表示
if(cvWaitKey(1)>=0) { // 何かキーを押したら終了
break;
}
}
cvDestroyWindow(szWndName);
cvReleaseCapture(&capture);
    return0;
}


実行するとMacのカメラで自分の顔が映る。




2010年3月15日月曜日

[SWT] SWT on 64bit Mac OS X

Mac OS X 10.6.2 Snow Leopardで
SWTアプリケーションがちゃんと動かない現象があって色々調べてみたら
どうやらオプションが必要のようだ。

「-d64」オプションと「-XstartOnFirstThread」オプション

「-d64」オプションは明確に64bit VMを指定するために使う。

「-XstartOnFirstThread」オプションはMacでSWTアプリケーションが正常に動けるため必要のようだ。SWTに限ったオプションではないらしい。

二つのオプションを付けると。。
java -d64 -XstartOnFirstThread -jar babukuma_swt_test.jar

実際テストしてみると問題なく動作した。

参照してサイト
http://www.eclipse.org/swt/macosx
http://www.eclipse.org/swt/faq.php

[SWT] SWT on 64bit Mac OS X

Mac OS X 10.6.2 Snow Leopard위에
SWT어플리케이션을 실행시키면 뭔가 제대로 실행이 안되는 현상이 있다.
그래서 이것저것 찾아보니 몇가지 옵션이 필요한 듯 하다.

「-d64」옵션과 「-XstartOnFirstThread」옵션

「-d64」옵션 : 명확하게 64bit VM에서 동작하도록 지정해준다.

「-XstartOnFirstThread」옵션 : Mac에서 SWT어플리케이션이 정상적으로 동작하는데 필요한 옵션인 듯 하다. SWT에 한정된 옵션은 아닌 듯.

두 옵션을 실제 사용해 보면
java -d64 -XstartOnFirstThread -jar babukuma_swt_test.jar

실제 테스트에서 문제없이 작동하였다.

참고한 사이트.
http://www.eclipse.org/swt/macosx
http://www.eclipse.org/swt/faq.php

2010年2月5日金曜日

Mac OS XにMySQLをインストールしてみる

環境
OS : Mac OS X 10.6.2
MySQL : 5.1.43

1. MySQLダウンロード
  - http://dev.mysql.com/downloads/mysql/ からダウンロード
  - mysql-5.1.43-osx10.6-x86_64.dmg

2. インストール
  - ダウンロードしたファイルをダブルクリック実行


  - 「mysql-XXXXXX.pkg」(ここでは「mysql-5.1.43-osx10.6-x86_64.pkg」)を実行

  - MySQL.prefPane設置(ダブルクリックで。。)



3. MySQLサーバ起動と停止
  - コマンドでもできるけど、システム環境設定画面から起動と停止ができる。



4. MySQLアンインストール
  - MySQL.prefPaneを削除


  - mysqlインストール先を削除
    デフォールトなら「/usr/local/mysql-5.1.43-osx10.6-x86_64」と「/usr/local/mysql」を削除すればいい。

Mac OS X에 MySQL 설치

환경
OS : Mac OS X 10.6.2
MySQL : 5.1.43

1. MySQL 다운로드
  - http://dev.mysql.com/downloads/mysql/ 에서 다운로드
  - mysql-5.1.43-osx10.6-x86_64.dmg

2. 인스톨
  - 다운로드한 파일을 실행


  - 「mysql-XXXXXX.pkg」(여기서는 「mysql-5.1.43-osx10.6-x86_64.pkg」)을 실행

  - MySQL.prefPane을 설치(더블클릭으로.)



3. MySQL서버 시작과 정지
  - 콘솔창에서 커맨드로도 가능하지만 시스템환경설정화면에서 간단하게 조작가능.



4. MySQL언인스톨
  - MySQL.prefPane제거


  - mysql이 설치된 디렉토리를 삭제
    디폴트면 「/usr/local/mysql-5.1.43-osx10.6-x86_64」와 「/usr/local/mysql」를 삭제하면 된다.