메뉴 건너뛰기

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

번호 제목 글쓴이 날짜 조회 수
740 bananapi 5대(ubuntu계열 리눅스)에 yarn(hadoop 2.6.0)설치하기-ResourceManager HA/HDFS HA포함, JobHistory포함 총관리자 2015.04.24 19143
739 mapreduce appliction을 실행시 "is running beyond virtual memory limits" 오류 발생시 조치사항 총관리자 2017.05.04 16896
738 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 14781
737 drop table로 삭제했으나 tablet server에는 여전히 존재하는 테이블 삭제방법 총관리자 2021.07.09 7550
736 insert hbase by hive ... error occured after 5 hours..HMaster가 뜨지 않는 장애에 대한 복구 방법 총관리자 2014.04.29 7129
735 Resource temporarily unavailable(자원이 일시적으로 사용 불가능함) 오류조치 총관리자 2015.11.19 6823
734 HBase shell로 작업하기 구퍼 2013.03.15 5834
733 dr.who로 공격들어오는 경우 조치방법 file 총관리자 2018.06.09 5603
732 하둡 분산 파일 시스템을 기반으로 색인하고 검색하기 구퍼 2013.03.15 5573
731 [Decommission]시 시간이 많이 걸리면서(수일) Decommission이 완료되지 않는 경우 조치 총관리자 2018.01.03 5297
730 Ubuntu 16.04LTS 설치후 초기에 주어야 하는 작업(php, apache, mariadb설치및 OS보안설정등) file 총관리자 2017.05.23 5268
729 hive 2.0.1 설치및 mariadb로 metastore 설정 총관리자 2016.06.03 5184
728 Hive Query Examples from test code (2 of 2) 총관리자 2014.03.26 5002
727 Spark에서 Serializable관련 오류및 조치사항 총관리자 2017.04.21 4901
726 [gson]mongodb의 api를 이용하여 데이타를 가져올때 "com.google.gson.stream.MalformedJsonException: Unterminated object at line..." 오류발생시 조치사항 총관리자 2017.12.11 4397
725 import 혹은 export할때 hive파일의 default 구분자는 --input-fields-terminated-by "x01"와 같이 지정해야함 총관리자 2014.05.20 4244
724 checking for termcap functions library... configure: error: No curses/termcap library found 구퍼 2013.03.08 4120
723 sqoop작업시 hdfs의 개수보다 더많은 값이 중복되어 oracle에 입력되는 경우가 있음 총관리자 2014.09.02 4093
722 다수의 로그 에이전트로 부터 로그를 받아 각각의 파일로 저장하는 방법(interceptor및 multiplexing) 총관리자 2014.04.04 4089
721 .git폴더를 삭제하고 다시 git에 추가하고 서버에 반영하는 방법 총관리자 2017.06.19 4077

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.

위로