메뉴 건너뛰기

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

번호 제목 글쓴이 날짜 조회 수
320 github에 있는 프로젝트와 로컬에서 작업한 프로젝트 합치기 총관리자 2016.11.22 40
319 특정 커밋 시점(commit id를 기준으로)으로 돌리기(reset) 총관리자 2016.11.21 75
318 Github를 이용하는 전체 흐름 이해하기 총관리자 2016.11.18 36
317 특정 단계의 commit상태로 만들기(이렇게 하면 중간에 반영된 모든 commit를 history가 삭제된다) 총관리자 2016.11.17 42
316 git 초기화(Windows에서 Git Bash사용) 총관리자 2016.11.17 197
315 spark notebook 0.7.0설치및 설정 총관리자 2016.11.14 160
314 참고할만한 spark예제를 설명하는 사이트 총관리자 2016.11.11 98
313 Kafka Offset Monitor로 kafka 상태 모니터링 하기 file 총관리자 2016.11.08 527
312 Eclipse실행시 Java was started but returned exit code=1이라는 오류가 발생할때 조치방법 총관리자 2016.11.07 397
311 [SparkR]SparkR 설치 사용기 1 - Installation Guide On Yarn Cluster & Mesos Cluster & Stand Alone Cluster file 총관리자 2016.11.04 106
310 데이타 분석및 머신러닝에 도움이 도움이 되는 사이트 총관리자 2016.11.04 64
309 java스레드 덤프 분석하기 file 총관리자 2016.11.03 111
308 centos 6에서 mariadb 5.1 to 10.0 으로 upgrade 총관리자 2016.11.01 106
307 Spark Streaming 코드레벨단에서의 성능개선 총관리자 2016.10.31 44
306 Flume과 Kafka를 사용한 초당 100만개 로그 수집 테스트 file 총관리자 2016.10.31 1021
305 Flume을 이용한 데이타 수집시 HBase write 성능 튜닝 file 총관리자 2016.10.31 621
304 How-to: Build a Complex Event Processing App on Apache Spark and Drools file 총관리자 2016.10.31 253
303 How-to: Tune Your Apache Spark Jobs (Part 2) file 총관리자 2016.10.31 77
302 mybatis와 spring을 org.apache.commons.dbcp2.BasicDataSource의 DataSource로 연동할때 DB설정(참고) 총관리자 2016.10.31 990
301 Caused by: java.sql.SQLNonTransientConnectionException: Could not read resultset: unexpected end of stream, read 0 bytes from 4 오류시 확인/조치할 내용 총관리자 2016.10.31 3763

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.

위로