메뉴 건너뛰기

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

번호 제목 날짜 조회 수
750 hue.axes_accessattempt테이블의 username컬럼에 NULL 혹은 space가 들어갈수도 있음. 2021.11.03 90865
749 bananapi 5대(ubuntu계열 리눅스)에 yarn(hadoop 2.6.0)설치하기-ResourceManager HA/HDFS HA포함, JobHistory포함 2015.04.24 22227
748 mapreduce appliction을 실행시 "is running beyond virtual memory limits" 오류 발생시 조치사항 2017.05.04 19794
747 org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /tmp/hadoop-root/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible. 2013.03.11 16996
746 Hive Query Examples from test code (2 of 2) 2014.03.26 13505
745 Resource temporarily unavailable(자원이 일시적으로 사용 불가능함) 오류조치 2015.11.19 11598
744 drop table로 삭제했으나 tablet server에는 여전히 존재하는 테이블 삭제방법 2021.07.09 10808
743 [Decommission]시 시간이 많이 걸리면서(수일) Decommission이 완료되지 않는 경우 조치 2018.01.03 10238
742 mysql 5.5.34-0ubuntu0.13.04용 설치/진행 화면 2014.09.10 9949
741 [DataNode]org.apache.hadoop.security.KerberosAuthException: failure to login: for principal: hdfs/datanode03@GOOPER.COM from keytab hdfs.keytab오류 2023.04.18 9822
740 insert hbase by hive ... error occured after 5 hours..HMaster가 뜨지 않는 장애에 대한 복구 방법 2014.04.29 9667
739 hive 2.0.1 설치및 mariadb로 metastore 설정 2016.06.03 9069
738 cumulusRDF 1.0.1설치및 "KeyspaceCumulus" keyspace확인하기 file 2016.04.15 8725
737 .git폴더를 삭제하고 다시 git에 추가하고 서버에 반영하는 방법 2017.06.19 8631
736 HBase shell로 작업하기 2013.03.15 8335
735 Ubuntu 16.04 LTS에서 sendmail설치및 설정(수신,발신 가능)및 메일서버 만들기 2017.05.23 7977
734 spark-sql실행시 The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH오류 발생시 조치사항 2016.06.09 7887
733 dr.who로 공격들어오는 경우 조치방법 file 2018.06.09 7850
732 Ubuntu 16.04LTS 설치후 초기에 주어야 하는 작업(php, apache, mariadb설치및 OS보안설정등) file 2017.05.23 7828
731 Spark에서 Serializable관련 오류및 조치사항 2017.04.21 7743
위로