메뉴 건너뛰기

Bigdata, Semantic IoT, Hadoop, NoSQL

Bigdata, Hadoop ecosystem, Semantic IoT등의 프로젝트를 진행중에 습득한 내용을 정리하는 곳입니다.
필요한 분을 위해서 공개하고 있습니다. 문의사항은 gooper@gooper.com로 메일을 보내주세요.


0. solr를 설치한다 : solrdf1.1과 호환되는 solr버젼은 5.3.1이므로 이것을 설치할것)

https://www.gooper.com/ss/bigdata/3108

1. /tmp로 이동하여 git로 소스를 다운받고 빌드한다.


cd /tmp

git clone https://github.com/agazzarini/SolRDF.git solrdf-download


빌드하기

cd solrdf-download/solrdf

mvn clean install


* 빌드하면 /tmp/solrdf-download/solrdf/solrdf-integration-tests/target/solrdf-integration-tests-1.1-dev/solrdf에 생성됨

* 참고사이트 : https://github.com/agazzarini/SolRDF


2. solrdf용 solrconfig.xml을 수정하여 HDFS에 저장할 수 있도록 함

*파일위치: 

/tmp/solrdf-download/solrdf/solrdf-integration-tests/target/solrdf-integration-tests-1.1-dev/solrdf/store/conf


<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/>

을 주석처리하고 아래의 내용을 추가한다.


<directoryFactory name="DirectoryFactory" class="solr.HdfsDirectoryFactory">

  <str name="solr.hdfs.home">${solr.hdfs.home:}</str>

  <str name="solr.hdfs.confdir">${solr.hdfs.confdir:}</str>

  <bool name="solr.hdfs.blockcache.enabled">true</bool>

  <int name="solr.hdfs.blockcache.slab.count">1</int>

  <bool name="solr.hdfs.blockcache.direct.memory.allocation">true</bool>

  <int name="solr.hdfs.blockcache.blocksperbank">16384</int>

  <bool name="solr.hdfs.blockcache.read.enabled">true</bool>

  <bool name="solr.hdfs.nrtcachingdirectory.enable">true</bool>

  <int name="solr.hdfs.nrtcachingdirectory.maxmergesizemb">16</int>

  <int name="solr.hdfs.nrtcachingdirectory.maxcachedmb">192</int>

</directoryFactory>


3. build결과 폴더를 실행디렉토리로 복사하고 링크를 생성한다.(solr cluster모든 서버에 복사하고 설정해야함)

cp -r /tmp/solrdf-download/solrdf/solrdf-integration-tests/target/solrdf-integration-tests-1.1-dev/solrdf $HOME

cd $HOME

mv solrdf solrdf-1.1

ln -s solrdf-1.1 solrdf

4. 환경변수를 설정한다.(solr cluster 모든 서버에 설정)

vi /etc/profile

export SOLRDF_HOME=$HOME/solrdf

를 추가한다.


* 환경변수 적용 : source /etc/profile


5. zookeeper에 새로운 solrdf용 config정보 upload(최초한번)

./hadoop/solr/server/scripts/cloud-scripts/zkcli.sh -zkhost gsda1:2181 -cmd upconfig -c store --confname store -confdir $HOME/solrdf/store/conf


* zookeeper의 configs/store에 업로드된다.

 (http://gsda1:8080/solr/#/~cloud?view=tree로 확인 가능함, configs폴더밑에 store폴더가 있고 그 밑에 설정파일이 있음)

* znode 삭제 : ../server/scripts/cloud-scripts/zkcli.sh -zkhost gsda1:2181 -c store -cmd clear /configs/store


6. solrdf 기동(8080포트로 새로운 solr인스턴스를 기동하게된다)(모든 solr cluster서버에서 실행)

solr가 설치된 위치의 bin폴더 밑으로 가서 아래 명령을 준다.

./solr start -p 8080 -s $SOLRDF_HOME -cloud -z gsda1:2181,gsda2:2181,gsda3:2181

-a "-Dsolr.data.dir=hdfs://mycluster/user/root/solr/solrdf

-Dsolr.lock.type=hdfs

-Dsolr.directoryFactory=HdfsDirectoryFactory

-Dsolr.updatelog=hdfs://mycluster/user/root/solr/solrdf 

-Dsolr.hdfs.confdir=/svc/apps/sda/bin/hadoop/hadoop/etc/hadoop

"


* HDFS의 hdfs://mycluster/user/root/solr/solrdf에 data를 저장하도록 8080포트로 인스턴스가 기동됨
* solr.hdfs.confdir은 hadoop의 conf파일이 있는 위치를 지정해줌

* HDFS가 아닌 File로 data로 등록기록 하는 경우의 실행방법
./solr start -p 8080 -s $SOLRDF_HOME -cloud -z gsda1:2181,gsda2:2181,gsda3:2181
-a "-Dsolr.data.dir=/data/solr/solrdf
-Dsolr.updatelog=/data/solr/solrdf
"

* SolRDF 에서 data저장서로 HDFS로 지정하는 경우 아래와 같은 오류가 발생되어 HDFS에 data를 저장할 수 없음
SolrCore Initialization Failures
store: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Index locked for write for core 'store'. Solr now longer supports forceful unlocking via 'unlockOnStartup'. Please verify locks manually!
Please check your logs for more information
Log4j (org.slf4j.impl.Log4jLoggerFactory)

Time (Local) Level Core Logger Message
2016. 4. 27. 오후 4:39:45 WARN null NativeCodeLoader Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2016. 4. 27. 오후 4:39:45 ERROR null SolrCore [store] Solr index directory 'hdfs://mycluster/user/root/solr/solrdf/store/data/index/' is locked. Throwing exception.
2016. 4. 27. 오후 4:39:46 ERROR null CoreContainer Error creating core [store]: Index locked for write for core 'store'. Solr now longer supports forceful unlocking via 'unlockOnStartup'. Please verify locks manually!
2016. 4. 27. 오후 4:39:46 ERROR null CoreContainer Error waiting for SolrCore to be created



7. "store"라는 collection생성하기(최초 한번) - ZK에 있는 configs/store에 있는 config정보를 활용함

./solr create -p 8080 -c store -shards 1 -replicationFactor 1 -n store


* 파일로 data를 저장하는 경우(5개 서버가 있으며 3개의 복사본을 유지함) - ZK에 있는 configs/store에 있는 config정보를 활용함

./solr create -p 8080 -c store -shards 5 -replicationFactor 3 -n store


* zookeeper의 collections/store에 생성된다.

 (http://gsda1:8080/solr/#/~cloud?view=tree로 확인 가능함, collections밑에 store폴더가 있고 그 밑에 설정파일이 있음)


* HDFS에 연동하는 경우에는 collection생성시 -shards, -repliationFactor값을 1로 주어야 "lock"관련 오류가 발생하지 않는다.

  (물론 data를 파일에 저장하도록 설정하는 경우에는 서버 마다의 HDD를 가지고 있으므로 shard개수를 2이상 지정하는것이 맞다.)

* 이렇게 되면 replication은 HDFS가 제공하는 복제기능으로 커버가능할거 같은데.. sharding은 지원하지 못하는 건가??

* 여러 서버에서 solr 인스턴스를 각각 실행하면 query의 패더레이션과 분산은 가능하겠지??

8. sample data 등록하기

http://localhost:8080/solr/store/update/bulk?commit=true

&update.contentType=application/n-triples

&stream.file=/tmp/solrdf-download/solrdf/solrdf-integration-tests/src/test/resources/sample_data/bsbm-generated-dataset.nt


9. sparql로 data확인하기

curl "http://127.0.0.1:8080/solr/store/sparql"

  --data-urlencode "q=SELECT (count(?s) as ?cnt) WHERE { ?s ?p ?o }"

  -H "Accept: application/sparql-results+json"


* 참고 : 8080포트에 작동중인 인스턴스 stop : bin/solr stop -p 8080 


---------오류내용(collection생성시 shard를 2이상 지정하고 solr인스턴스 기동시 아래와 같은 오류가 발생됨)----------------------
SolrCore Initialization Failures
store: org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Index locked for write for core 'store'. Solr now longer supports forceful unlocking via 'unlockOnStartup'. Please verify locks manually!
Please check your logs for more information
Log4j (org.slf4j.impl.Log4jLoggerFactory)

Time (Local) Level Core Logger Message
2016. 4. 27. 오후 4:39:45 WARN null NativeCodeLoader Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2016. 4. 27. 오후 4:39:45 ERROR null SolrCore [store] Solr index directory 'hdfs://mycluster/user/root/solr/solrdf/store/data/index/' is locked. Throwing exception.
2016. 4. 27. 오후 4:39:46 ERROR null CoreContainer Error creating core [store]: Index locked for write for core 'store'. Solr now longer supports forceful unlocking via 'unlockOnStartup'. Please verify locks manually!
2016. 4. 27. 오후 4:39:46 ERROR null CoreContainer Error waiting for SolrCore to be created

번호 제목 글쓴이 날짜 조회 수
259 로컬의 라이브러리파일들을 dependency에 포함시키는 방법 총관리자 2016.08.09 49
258 gradle을 이용하여 jar파일 생성시 provided속성을 지정할 수 있게 설정하는 방법 총관리자 2016.08.09 75
257 [SBT] assembly시 "[error] deduplicate: different file contents found in the following:"오류 발생시 조치사항 총관리자 2016.08.04 578
256 [SBT] SBT 사용법 정리(링크) 총관리자 2016.08.04 839
255 [SBT] project.sbt에 libraryDependencies에 필요한 jar를 지정했으나 sbt compile할때 클래스를 못찾는 오류가 발생했을때 조치사항 총관리자 2016.08.03 74
254 build할때 unmappable character for encoding MS949 에러 발생시 조치사항 총관리자 2016.08.03 178
253 kafkaWordCount.scala의 producer와 consumer 클래스를 이용하여 kafka를 이용한 word count 테스트 하기 총관리자 2016.08.02 97
252 bin/start-hbase.sh실행시 org.apache.hadoop.hbase.util.FileSystemVersionException: HBase file layout needs to be upgraded오류가 발생하면 조치사항 총관리자 2016.08.01 205
251 start-all.sh로 spark데몬 기동시 "JAVA_HOME is not set"오류 발생시 조치사항 총관리자 2016.08.01 126
250 hadoop클러스터를 구성하던 서버중 HA를 담당하는 서버의 hostname등이 변경되어 문제가 발생했을때 조치사항 총관리자 2016.07.29 362
249 Journal Storage Directory /data/hadoop/journal/data/mycluster not formatted 오류시 조치사항 총관리자 2016.07.29 1518
248 슬라이딩 윈도우 예제 총관리자 2016.07.28 67
247 거침없이 배우는 Drools 책의 샘플소스 file 총관리자 2016.07.22 1232
246 drools를 이용한 로그,rule matching등의 테스트 java프로그램 file 총관리자 2016.07.21 181
245 ServerInfo객체파일 총관리자 2016.07.21 35
244 drools에서 drl관련 로그를 기록하기 위한 클래스 파일 총관리자 2016.07.21 74
243 워킹 메모리에 대한 정보를 처리하는 클래스 파일 총관리자 2016.07.21 49
242 커리 변경 이벤트를 처리하기 위한 구현클래스 총관리자 2016.07.21 41
241 룰에 매칭되면 발생되는 엑티베이션 객체에 대한 작업(이전값 혹은 현재값)을 처리하는 클래스 파일 총관리자 2016.07.21 285
240 실시간 쿼리 변환 모니터링(팩트내 필드값의 변경사항을 실시간으로 추적함)하는 테스트 java 프로그램 file 총관리자 2016.07.21 67

A personal place to organize information learned during the development of such Hadoop, Hive, Hbase, Semantic IoT, etc.
We are open to the required minutes. Please send inquiries to gooper@gooper.com.

위로