메뉴 건너뛰기

Cloudera, BigData, Semantic IoT, Hadoop, NoSQL

Cloudera CDH/CDP 및 Hadoop EcoSystem, Semantic IoT등의 개발/운영 기술을 정리합니다. gooper@gooper.com로 문의 주세요.


0. hadoop, hbase, tomcat등이 이미 서버에 설치되어 있어야 한다.


1. eclipse에서 https://github.com/Merck/Halyard를 import한다.

  가. File->Import->Projects from Git를 선택한다.

  나. Select Repository Source를 Clone URI를 선택한다.

  다. URI에 https://github.com/Merck/Halyard를 입력한다.

  라. Branch Selection에서 master를 선택한다.

  마. Local Destination의 Directory를 디폴트로 선택한다

  바. Finish를 선택하면 github에서 소스를 받아 로컬 리포지토리에 저장하고 eclipse 프로젝트를 생성해준다.


* verion up등으로 git pull했을때 충돌이 발생하면 git stash -> git pull -> git pop순서데로 처리해서 로컬에 반영해준다.

           (참조 : http://vezi95.blogspot.kr/2016/05/git-pull.html)


2. halyard를 eclipse에서 build 한다.

  가. halyard폴더의 pom.xml을 선택하고 -> Run As -> Maven Build..-> goal에 package를 입력및 Skip Tests선택후 Run한다.

  나. 이때 몇가지 오류가 발생하는데 Windows RegCreateKeyEx(...) returned error code 5. 가 발생하면 아래를 참조한다.

  다. halyard-sail, halyard-tools 프로젝트에서 halyard-common.jar관련 dependency오류가 발생하면 아래처럼 주석처리한다.

        <!--  dependency>

            <groupId>${project.groupId}</groupId>

            <artifactId>halyard-common</artifactId>

            <version>${project.version}</version>

            <type>test-jar</type>

            <scope>test</scope>

        </dependency -->


3. web모듈을 tomcat서버에 deploy한다.

 가. Halyard/webapps/target에 생성된 rdf4j-server.war, rdf4j-workbench.war를 tomcat webapps에 복사하여 디플로이한다.

     (halyard-webapps-1.1-SNAPSHOT.zip파일에도 동일한 파일이 압축되어있다)

 나. http://sda1/rdf4j-server/, http://sda1/rdf4j-workbench/로 웹에서 접근가능하나 rdf4j-server는 workbench에서 사용되므로 외부에 노출시켜서는 안된다.

 다. tomcat의 bin 폴더에 setenv.sh파일을 생성하고 아래의 내용을 추가한후 tomcat를 재기동한다.(이것을 설정하지 않으면 rdf4j-workbench를 브라우저에서 조회시 Hbase class관련 오류를 방지할 수 있다)

export CLASSPATH=$CLASSPATH:"$JAVA_HOME/jre/lib/ext/servlet-api.jar:"`$HOME/hadoop/bin/hadoop classpath`:`$HOME/hbase/bin/hbase classpath`


4. Halyard SDK를 서버에 복사/압축해제한다.

  가. RDF4J에서 제공하는 기능에 Hbase를 추가한 버젼이며 repository를 생성하고 삭제하는 등의 작업을 command라인에서 수행할 수 있다.

    (http://sda1/rdf4j-workbench/를 이용하면 web에서 동일한 작업을 할 수 있다)

  나. 서버의 특정 위치에 폴더(예, halyard-sdk)를 만들고 Halyard/sdk/target/halyard-sdk-1.1-SNAPSHOT.zip를 업로드 한후 압축을 푼다.(unzip halyard-sdk-1.1-SNAPSHOT.zip)

  다. 압축을 풀면 폴더내에 아래와 같은 실행파일등이 생성된다.

LICENSE  LICENSES_THIRD_PARTY  bulkload  bulkupdate  console  export  halyard-sdk-1.1-SNAPSHOT.zip  hiveload  img  index.html  lib  pexport  update


  라.RDF4J console 실행(테스트)

     - ./console

   * console실행시 오류가 발생하면 아래를 참조하여 정확한 경로를 지정해준다.

 

-bash-4.1$ cat console
#!/bin/sh
lib="$(dirname "${0}")/lib"
#java -Xmx2G -cp "$lib/halyard-tools-1.1-SNAPSHOT.jar:"`hadoop classpath`":"`hbase classpath` org.eclipse.rdf4j.console.Console "$@"
java -Xmx2G -cp "$lib/halyard-tools-1.1-SNAPSHOT.jar:"`hadoop classpath`":"`$HOME/hbase/bin/hbase classpath` org.eclipse.rdf4j.console.Console "$@"

5. console작업(예시)

  가. Repository생성 (query timeout : 604800(60*60*24*7), defualt: 180초)

    

> create hbase   
Please specify values for the following variables:
Repository ID: testRepo
Repository title: 
HBase Table Name: 
Create HBase Table if missing (true|false) [true]: 
HBase Table presplit bits [0]: 
Use Halyard Push Evaluation Strategy (true|false) [true]: 
Query Evaluation Timeout [180]: 604800
Repository created


  나. 생성된 Repository에 접속

> open testRepo
Opened repository 'testRepo'


  다. sparql실행(등록된 데이타 없는 상태)(여러줄을 입력할 수 있고 마지막 줄에 '.'을 입력하면 쿼리가 수행된다.)

testRepo> sparql
enter multi-line SPARQL query (terminate with line containing single '.')
select * where {?s ?p ?o} limit 10
.
Evaluating SPARQL query...
+------------------------+------------------------+------------------------+
| s                      | p                      | o                      |
+------------------------+------------------------+------------------------+
+------------------------+------------------------+------------------------+
0 result(s) (27 ms)

  라. data파일 로드(약 905336건)

testRepo> load /home/gooper/aa/test.nq
Loading data...
Data has been added to the repository (83878 ms)


  마. sparql 실행(등록된 데이타 있음)

testRepo> sparql
enter multi-line SPARQL query (terminate with line containing single '.')
select * where {?s ?p ?o} limit 10
.
Evaluating SPARQL query...
+------------------------+------------------------+------------------------+
| s                      | p                      | o                      |
+------------------------+------------------------+------------------------+
| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data/CONTENT_INST_167822>| <http://www.w3.org/2000/01/rdf-schema#label>| ","                    |
| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data/CONTENT_INST_167822>| <http://purl.org/dc/elements/1.1/creator>| "TAS"                  |
| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data/CONTENT_INST_167822>| <http://www.gooper.com/m2m/hasLastModifiedDate>| "2015-12-23T19:34:08"^^<http://www.w3.org/2001/XMLSchema#dateTime>|
| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data/CONTENT_INST_167822>| <http://www.gooper.com/m2m/isContentInstanceOf>| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data>|
| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data/CONTENT_INST_167822>| <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>| <http://www.gooper.com/m2m/ContentInstance>|
| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data/CONTENT_INST_167822>| <http://www.gooper.com/m2m/hasContentValue>| "26.3"^^<http://www.w3.org/2001/XMLSchema#double>|
| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data/CONTENT_INST_167822>| <http://www.gooper.com/m2m/resourceName>| "CONTENT_INST_167822"  |
| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data/CONTENT_INST_167822>| <http://www.gooper.com/m2m/hasCreateDate>| "2015-12-23T19:34:08"^^<http://www.w3.org/2001/XMLSchema#dateTime>|
| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data/CONTENT_INST_167822>| <http://www.gooper.com/m2m/hasParentResource>| <http://www.gooper.com/herit-in/herit-cse/TempSensor_LR0001TS0004/status/Data>|
| <http://www.gooper.com/herit-in/herit-cse/UserInOutInfo_u00002/status/Data/CONTENT_INST_158789>| <http://www.w3.org/2000/01/rdf-schema#label>| ","                    |
+------------------------+------------------------+------------------------+
10 result(s) (102 ms)


* 쿼리결과가 특정시간내에 산출되지 않으면 exception이 발생한다.(Query evaluation error: Query evaluation exceeded specified timeout 180s)

* 개수 카운트

testRepo> sparql
enter multi-line SPARQL query (terminate with line containing single '.')
select (count(*) as ?cnt) where {?s ?p ?o}
.
Evaluating SPARQL query...
+-----------------------------------------------------------------------------+
| cnt                                                                           |
+-----------------------------------------------------------------------------+
| "919049"^^<http://www.w3.org/2001/XMLSchema#integer>                        |
+-----------------------------------------------------------------------------+
1 result(s) (8468 ms)


   바. console명령어

List of all commands:
help        Displays this help message
info        Shows info about the console
connect     Connects to a (local or remote) set of repositories
disconnect  Disconnects from the current set of repositories
create      Creates a new repository
federate    Federate existing repositories.
drop        Drops a repository
open        Opens a repository to work on, takes a repository ID as argument
close       Closes the current repository
show        Displays an overview of various resources
load        Loads a data file into a repository, takes a file path or URL as argument
verify      Verifies the syntax of an RDF data file, takes a file path or URL as argument
clear       Removes data from a repository
sparql      Evaluate a SPARQL query
serql       Evaluate a SeRQL query
set         Allows various console parameters to be set
exit, quit  Exit the console


6. bulkload쉘 사용(예시)

  가. bulkload파일을 현재 상황에 맞게 패스등을 변경한다.

-bash-4.1$ cat bulkload 
#!/bin/sh
lib="$(dirname "${0}")/lib"
libjars="$(echo "$lib"/*.jar | tr ' ' ',')"
export HADOOP_CLASSPATH=`$HOME/hadoop/bin/hadoop classpath`:`$HOME/hbase/bin/hbase classpath`
#hadoop jar lib/halyard-tools-1.1-SNAPSHOT.jar com.msd.gin.halyard.tools.HalyardBulkLoad -conf /etc/hbase/conf/hbase-site.xml -libjars $libjars "$@"
hadoop jar lib/halyard-tools-1.1-SNAPSHOT.jar com.msd.gin.halyard.tools.HalyardBulkLoad -conf $HOME/hbase/conf/hbase-site.xml -libjars $libjars "$@"

  나. bulkload 실행(데이타 파일은 test.nq.gz파일을 이용함)

    - halyard 작업디렉토리 생성 : hdfs dfs -mkdir halyard

    - data저장 디렉토리 생성 : hdfs dfs -mkdir halyard/input

    - data upload : hdfs dfs -put test.nq.gz halyard/input

    - bulkload실행(오류가 발생하면 Exception발생) : ./bulkload halyard/input halyard/temp testRepo

    - bulkload실행(오류가 있어도 Exception발생하지 않고 진행함) : ./bulkload -Dhalyard.parser.skipinvalid=true halyard/input halyard/temp testRepo

   


번호 제목 날짜 조회 수
230 Collections.sort를 이용한 List<Map<String, String>>형태의 데이타 정렬 소스 2016.12.15 3471
229 mybais #과 $의 차이점 2015.11.10 3465
228 Spark Streaming으로 유실 없는 스트림 처리 인프라 구축하기 2016.03.11 3462
227 How-to: Tune Your Apache Spark Jobs (Part 2) file 2016.10.31 3457
226 sendmail + dovecot(pop3) + saslauthd 설치 2017.06.11 3453
225 oracle 접속 방식에 따른 --connect 지정 방법 2022.02.11 3452
224 compile할때와 exclude할때 대상을 표현하는 명칭이 다르므로 주의할것 2016.08.10 3451
223 부팅을 외장하드에서 하도록 변경하는 방법 2015.07.28 3451
222 collection생성혹은 collection조회시 Plugin init failure for [schema.xml] fieldType "pdate": Error loading class 'solr.IntField' 오류 조치사항 2022.04.07 3441
221 oozie 에서 sqoop action실행 에러 - 컬럼개수 차이 2014.07.17 3441
220 schema.xml vs managed-schema 지정 사용하기 - 두개를 동시에 사용할 수는 없음 2017.07.09 3436
219 Components of the Impala Server 2018.03.21 3433
218 Caused by: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D오류발생시 조치사항 2016.06.03 3429
217 2개 data를 join하고 마지막으로 code정보를 join하여 결과를 얻는 mr 프로그램 2014.06.30 3425
216 solr명령 실행시 "Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect" 오류발생 2017.06.30 3418
215 참고할만한 spark예제를 설명하는 사이트 2016.11.11 3411
214 /etc/logrotate.d 을 이용한 catalina.out 나누기 file 2017.01.19 3409
213 Permission denied: user=hadoop, access=EXECUTE, inode="/tmp":root:supergroup:drwxrwx--- 오류해결방법 2015.05.17 3409
212 동시에 많은 요청이 endpoint로 몰려서java.net.NoRouteToHostException가 발생하는 경우의 처리방법 2016.10.17 3408
211 [Oracle 11g]Kudu table의 meta정보를 담고 있는 table_params의 백업본을 이용하여 특정 컬럼값을 update하는 Oracle SQL문 2023.09.04 3393
위로