메뉴 건너뛰기

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

   


번호 제목 날짜 조회 수
750 [Shellscript]Impala view의 실제 참조 테이블 추출용 shellscript파일 2025.03.22 1003
749 엑셀에서 K ,M, G ,T 단위를 숫자로 변환 하는 수식 2025.04.09 1264
748 beeline을 이용한 impala JDBC 테스트 방법(Kerberos 설정된 상태임) 2024.11.29 1541
747 외부에서 ImpalaJDBC42.jar를 통해서 Impala에 접속시 sessions정보 2024.11.26 1626
746 test333 2017.05.01 1834
745 http://blog.naver.com... 2017.06.23 1839
744 Failed to resolve 'acme-v02.api.letsencrypt.org' ([Errno -3] Temporary failure in name resolution)" 2024.11.27 1917
743 eclipse 3.1 단축키 정리파일 2017.01.02 2058
742 5건의 triple data를 이용하여 특정 작업 폴더에서 작업하는 방법/절차 2016.06.16 2079
741 [vi] test.nq파일에서 특정문자열(예, <>)을 찾아서 포함되는 라인을 삭제한 동일한 이름의 파일을 만드는 방법 2017.01.25 2079
740 Windows에서 sbt개발환경 구축 방법(링크) 2016.06.02 2087
739 [EncryptionZone]User:testuser not allowed to do "DECRYPT_EEK" on 'testkey' 2023.06.29 2097
738 외부 jar파일을 만들려고하는jar파일의 package로 포함하는 방법 2016.08.10 2105
737 java스레드 덤프 분석하기 file 2016.11.03 2114
736 restaurant-controller,에서 등록 예시 2022.04.30 2124
735 DataSetCreator.py 실행시 파일을 찾을 수 없는 오류 2016.05.27 2129
734 실시간 쿼리 변환 모니터링(팩트내 필드값의 변경사항을 실시간으로 추적함)하는 테스트 java 프로그램 file 2016.07.21 2129
733 [oracle]10자리 timestamp값을 날짜로 변환하는 방법 2022.04.14 2164
732 하둡기반 데이타 모델링(6편) 2018.06.27 2177
731 [메모리 덤프파일 분석] 2017.03.31 2242
위로