gradle에서 특정 라이브러리는 사용하고 싶지 않다면.


configuration-> compile.exclude를 사용한다.




주의할 점은 group, module이 분류되어 있다는 점이다.



configurations {
compile.exclude group: "org.slf4j", module : "slf4j-log4j12"
compile.exclude group: "javax.servlet", module : "servlet-api"
}


Posted by '김용환'
,




다음 hbase 커맨드는 다음 의사 자바 코드와 같다.


<hbase 커맨드>

scan 'table', { COLUMNS => 'colFam:colQualifier', LIMIT => 3 }



<java psudeo code>

    Scan scan = new Scan();

    scan.addFamily(Bytes.toBytes(familyName));

    filters.addFilter(pageFilter);

    scan.setFilter(filters);






다음 hbase 커맨드는 다음 의사 자바 코드와 같다.


<hbase 커맨드>
scan 'table', { COLUMNS => 'colFam:colQualifier', LIMIT => 3, FILTER => "ValueFilter( =, 'value1' )" }


<java psudeo code>
        Scan scan = new Scan();
        FilterList filters = new FilterList(FilterList.Operator.MUST_PASS_ALL);
        Filter pageFilter = new PageFilter(fetchSize);
        
        SingleColumnValueFilter qualifierFilter = new SingleColumnValueFilter(
                COLUMN_FAMILY,
                COLUMN_QUALIFIER,
                CompareFilter.CompareOp.EQUAL,
                new BinaryComparator(Bytes.toBytes("value1"))
        );

        filters.addFilter(pageFilter);
        filters.addFilter(qualifierFilter);

        scan.setFilter(filters);


Posted by '김용환'
,



Hbase Scan 결과에 대해 디버깅을 하려 했다.


예전 쿼리를 Result에 대해서 keyvalue를 얻어오는 부분을 날 쿼리를 이용해 사용했다.


                    for (KeyValue kv : result.raw()) {

                        System.out.printf("row: %d, qualifier: %s, value: %s\n",

                                Bytes.toLong(Bytes.padHead(kv.getRow(), 8)),

                                new String(kv.getQualifier()),

                                new String(kv.getValue()));

                    }




그러나, CellUtil을 사용하면 좀 고급스럽게 디버깅할 수 있다.




import org.apache.hadoop.hbase.Cell;

import org.apache.hadoop.hbase.CellUtil;



                    List<Cell> cells = result.listCells();

                    final String TABS = "\t";

                    for (Cell cell : cells) {

                        System.out.printf("%s%scolumn=%s:%s, timestamp=%d, value=%s\n",

                                Bytes.toStringBinary(CellUtil.cloneRow(cell)),

                                TABS,

                                Bytes.toString(CellUtil.cloneFamily(cell)),

                                Bytes.toString(CellUtil.cloneQualifier(cell)),

                                cell.getTimestamp(),

                                Bytes.toString(CellUtil.cloneValue(cell)));

                    }

                    



Posted by '김용환'
,



마라톤(marathon)에는 fault tolerance와 locality를 극복할 수 있는 방법으로 constraints를 제공한다. 동일한 기능을 하는 데몬을 한 장비에 두면, 한 장비가 죽으면 더 이상 서비스를 진행할 수 없다.


그래서 가상 장비(virutal machine)에서는 anti affinity 라는 단어를 사용해 동일한 기능을 가진 서비스를 여러 장비에 분산시키면 fault tolerance와 locality를 지원한다.



<fault tolerance와 locality 소개>

https://www.bayt.com/en/specialties/q/215179/what-is-affinity-and-anti-affinity-rule-in-vmware/


Affinity rule, ensure that multiple virtual machines are always running on the same host.  As such, if one of the virtual machines is vMotioned to a different host, the associated virtual machines must be moved as well.






http://mesosphere.github.io/marathon/docs/constraints.html


CLUSTER allows you to run all of your app’s tasks on agent nodes that share a certain attribute. This is useful for example if you have apps with special hardware needs, or if you want to run them on the same rack for low latency.

A field of "hostname" tells Marathon that launched tasks of the app/pod have affinity for each other and should be launched together on the same agent:

....




하나의 장비에 동일한 서비스(데몬)을 실행시키지 않으려면 

marathon json에 다음을 추가한다.



 "constraints": [["hostname", "UNIQUE"]]



Posted by '김용환'
,

소스 트리에서 다음과 같은 에러가 계속 난다.. 


remote: Invalid username or password. fatal: Authentication failed


아마도 예전에 저장한 패스워드에 문제가 있었나 보다.



아래 설정을 진행하니 문제가 없다.



Sourcetree > Preferences > Git > Use System Git




Posted by '김용환'
,


스파크 MLlib은 K-평균, 이분법 K-평균, 가우스 혼합 외에 PIC, LDA, 스트리밍 K-평균과 같은 세 개의 클러스터링 알고리즘의 구현을 제공한다. 


한 가지 분명한 것은 클러스터링 분석을 미세하게 튜닝하려면 종종 비정상 데이터(outlier 또는  anomaly)이라고 불리는 원치 않는 데이터 오브젝트를 제거해야 한다.


스파크 MLlib으로 비정상 데이터를 찾는데 공부하기 위한 좋은 자료


https://github.com/keiraqz/anomaly-detection


https://mapr.com/ebooks/spark/08-unsupervised-anomaly-detection-apache-spark.html




Posted by '김용환'
,


간단한 스파크 잡 실행하기 예제는 다음과 같다. 



# 8코어에서 독립 실행 형 모드로 애플리케이션을 실행한다

SPARK_HOME/bin/spark-submit \  

--class org.apache.spark.examples.Demo \  

--master local[8] \  

Demo-0.1-SNAPSHOT-jar-with-dependencies.jar


# YARN 클러스터에서 실행한다

export HADOOP_CONF_DIR=XXX

SPARK_HOME/bin/spark-submit \  

--class org.apache.spark.examples.Demo \  

--master yarn \  

--deploy-mode cluster \  # 클러스터 모드로 클라이언트가 될 수 있다

--executor-memory 20G \  

--num-executors 50 \  

Demo-0.1-SNAPSHOT-jar-with-dependencies.jar


# supervise 플래그를 포함해 클러스터 배포 모드의 메소스(Mesos) 클러스터에서 실행한다

SPARK_HOME/bin/spark-submit \

--class org.apache.spark.examples.Demo \

--master mesos://207.184.161.138:7077 \ # IP 주소를 사용한다

--deploy-mode cluster \  

--supervise \  

--executor-memory 20G \  

--total-executor-cores 100 \  

Demo-0.1-SNAPSHOT-jar-with-dependencies.jar



supervise는 스탠드 얼론 모드에서 0이외의 값을 리턴, 비정상적인 종료일 때는 다시 실행하라는 의미를 가진다.






예제

https://spark.apache.org/docs/2.1.1/submitting-applications.html


# Run application locally on 8 cores
./bin/spark-submit \
  --class org.apache.spark.examples.SparkPi \
  --master local[8] \
  /path/to/examples.jar \
  100

# Run on a Spark standalone cluster in client deploy mode
./bin/spark-submit \
  --class org.apache.spark.examples.SparkPi \
  --master spark://207.184.161.138:7077 \
  --executor-memory 20G \
  --total-executor-cores 100 \
  /path/to/examples.jar \
  1000

# Run on a Spark standalone cluster in cluster deploy mode with supervise
./bin/spark-submit \
  --class org.apache.spark.examples.SparkPi \
  --master spark://207.184.161.138:7077 \
  --deploy-mode cluster \
  --supervise \
  --executor-memory 20G \
  --total-executor-cores 100 \
  /path/to/examples.jar \
  1000

# Run on a YARN cluster
export HADOOP_CONF_DIR=XXX
./bin/spark-submit \
  --class org.apache.spark.examples.SparkPi \
  --master yarn \
  --deploy-mode cluster \  # can be client for client mode
  --executor-memory 20G \
  --num-executors 50 \
  /path/to/examples.jar \
  1000

# Run a Python application on a Spark standalone cluster
./bin/spark-submit \
  --master spark://207.184.161.138:7077 \
  examples/src/main/python/pi.py \
  1000

# Run on a Mesos cluster in cluster deploy mode with supervise
./bin/spark-submit \
  --class org.apache.spark.examples.SparkPi \
  --master mesos://207.184.161.138:7077 \
  --deploy-mode cluster \
  --supervise \
  --executor-memory 20G \
  --total-executor-cores 100 \
  http://path/to/examples.jar \
  1000


Posted by '김용환'
,



opentsdb의 hbase 스키마는 다음 url에서 확인할 수 있다.

특이한 점은 데이터는 역순(증분)으로 되어 있고 마지막 uid 정보를 0x00에 저장한다는 점이다. 

따라서 scanning할 때 무척 편하게 할 수 있다. 


http://opentsdb.net/docs/build/html/user_guide/backends/hbase.html


UID Table Schema

A separate, smaller table called tsdb-uid stores UID mappings, both forward and reverse. Two columns exist, one named name that maps a UID to a string and another id mapping strings to UIDs. Each row in the column family will have at least one of three columns with mapping values. The standard column qualifiers are:

  • metrics for mapping metric names to UIDs
  • tagk for mapping tag names to UIDs
  • tagv for mapping tag values to UIDs.

The name family may also contain additional meta-data columns if configured.

id Column Family

Row Key - This will be the string assigned to the UID. E.g. for a metric we may have a value of sys.cpu.user or for a tag value it may be 42.

Column Qualifiers - One of the standard column types above.

Column Value - An unsigned integer encoded on 3 bytes by default reflecting the UID assigned to the string for the column type. If the UID length has been changed in the source code, the width may vary.

name Column Family

Row Key - The unsigned integer UID encoded on 3 bytes by default. If the UID length has been changed in the source code, the width may be different.

Column Qualifiers - One of the standard column types above OR one of metrics_metatagk_meta or tagv_meta.

Column Value - For the standard qualifiers above, the string assigned to the UID. For a *_meta column, the value will be a UTF-8 encoded, JSON formatted UIDMeta Object as a string. Do not modify the column value outside of OpenTSDB. The order of the fields is important, affecting CAS calls.

UID Assignment Row

Within the id column family is a row with a single byte key of \x00. This is the UID row that is incremented for the proper column type (metrics, tagk or tagv) when a new UID is assigned. The column values are 8 byte signed integers and reflect the maximum UID assigned for each type. On assignment, OpenTSDB calls HBase's atomic increment command on the proper column to fetch a new UID.


Posted by '김용환'
,



Kafka에 zookeeper를 사용할 때. zookeeper 기본 설정 사용하다가 주키퍼에서 메모리 부족하고 난리도 아니다.


메모리 설정과 jmx 설정을 해주는 것이 좋다.




conf/java.env파일을 추가해 메모리 설정도 gc 로그 파일을 생성한다. 아래는 대략 기본 설정으로 보는게 좋다.


export JVMFLAGS="-Xmx3g -Xms3g -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:CompileThreshold=200 -verbosegc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/var/lib/zookeeper/gc.log -XX:+UseGCLogFileRotation -XX:GCLogFileSize=10m -XX:NumberOfGCLogFiles=10"



zkServer.sh에 다음을 추가해 jmx 모니터링을 진행한다.


-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=8989 -Djava.rmi.server.hostname=my.remoteconsole.org





Posted by '김용환'
,


Jetbrains에서 query editor를 사용하려면.


File -> New -> Console을 이용한다.


아니면.


Database -> + -> console을 이용한다.





Posted by '김용환'
,