메뉴 건너뛰기

Cloudera, BigData, Semantic IoT, Hadoop, NoSQL

Cloudera CDH/CDP 및 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

번호 제목 날짜 조회 수
201 AIX 7.1에 Hadoop설치(정리중#2) 2016.09.20 307
200 바나나 파이의 /tmp폴더를 외장하드로 변경하기 2015.07.24 306
199 scala-eclipse 다운로드 2019.06.09 299
198 spark-sql실행시 ERROR log: Got exception: java.lang.NumberFormatException For input string: "2000ms" 오류발생시 조치사항 2016.06.09 299
197 CDH 5.4.4 버전에서 hive on tez (0.7.0)설치하기 2016.01.14 298
196 Cloudera Manager의 Java Heap Size변경하는 방법 2022.06.27 297
195 java quartz 시간 설정 참고사항 2015.12.16 297
194 scala application 샘플소스(SparkSession이용) 2018.03.07 296
193 cloudera의 hue에서 사용자가 사용한 쿼리 목록 2020.02.07 294
192 javax.net.ssl.SSLHanshakeException: SSLHandshakeException invoking https://mainCluster.gooper.com:7183/api/v1/users: sun.security.validator.ValidatorException: No trusted certificate found 2022.06.29 290
191 Cloudera설치중에 "Error, CM server guid updated"오류 발생시 조치방법 2018.03.29 289
190 windows7에서 lagom의 hello world를 빌드하여 실행하는 경우의 로그(mvn lagom:runAll -Dscala.binary.version=2.11) 2017.12.22 289
189 [CDP7.1.7]Hive Replication수행중 Specified catalog.database.table does not exist : hive.db명.table명 오류 발생시 조치방법 2024.04.05 288
188 하둡기반 데이타 모델링(6편) 2018.06.27 288
187 anaconda3(v5.4)를 이용하여 tensorflow설치후 ipython프로그램을 실행하여 import할때 오류발생시 조치 2018.07.27 286
186 Spark Streaming 코드레벨단에서의 성능개선 2016.10.31 284
185 spark2.0.0에서 hive 2.0.1 table을 읽어 출력하는 예제 소스(HiveContext, SparkSession, SQLContext) 2017.03.09 283
184 lagom의 online-auction-java프로젝트 실행시 "Could not find Cassandra contact points, due to: ServiceLocator is not bound" 경고 발생시 조치사항 2017.10.12 280
183 [TLS/SSL]Kudu Tablet Server설정 2022.05.13 276
182 oozie WF에서 참고할만한 내용 2019.07.18 276
위로