메뉴 건너뛰기

Bigdata, Semantic IoT, Hadoop, NoSQL

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


1. 다운로드   

    http://mirror.apache-kr.org/lucene/solr/5.5.0/


2. 압축풀기

   tar xvfz solr-5.5.0.tgz


3. 링크생성 

   ln -s solr-5.5.0 solr

 

4. solr.in.sh 파일 수정(HdfsDirectoryFactory를 추가하여 index data를 hdfs에 저장하도록 하고 몇가지 옵션 설정함)

vi bin/solr.in.sh


ZK_HOST="gsda1:2181,gsda2:2181,gsda3:2181"

ZK_CLIENT_TIMEOUT="15000"

SOLR_OPTS="$SOLR_OPTS -Dsolr.autoSoftCommit.maxTime=3000"

SOLR_OPTS="$SOLR_OPTS -Dsolr.autoCommit.maxTime=60000"

SOLR_OPTS="$SOLR_OPTS -Dsolr.clustering.enabled=true"


# Set HDFS DirectoryFactory & Settings(현재 solr6.2버젼에서 hadoop의 HA를 지원하지 않아서 solr.hdfs.home를 지정시

      hdfs://mycluster/user/root/solr와 같이 쓰지 말고 hdfs://sda1:9000/user/root/solr로 지정해줘야함)


SOLR_OPTS="$SOLR_OPTS -Dsolr.directoryFactory=HdfsDirectoryFactory"
SOLR_OPTS="$SOLR_OPTS -Dsolr.lock.type=hdfs"
SOLR_OPTS="$SOLR_OPTS -Dsolr.hdfs.home=hdfs://mycluster/user/root/solr"
SOLR_OPTS="$SOLR_OPTS -Dsolr.zookeeper=gsda1:2181"
#SOLR_OPTS="$SOLR_OPTS -Dsolr.data.dir=hdfs://mycluster/user/root/solr/data"
SOLR_OPTS="$SOLR_OPTS -Dsolr.updatelog=hdfs://mycluster/user/root/solr/log"
SOLR_OPTS="$SOLR_OPTS -Dsolr.hdfs.confdir=$HOME/hadoop/etc/hadoop"


==>위에 값을 지정하지 않고 실행했을때 아래의 오류가 발생하면서 collection생성이 되지 않는다.

("6-가"를 참조하여 solrconfig.xml 설정을 변경하여준다.)


bin/solr create -c  -shards 4 -replicationFactor 3 -d ./configs/gc

Connecting to ZooKeeper at sda1:2181,sda2:2181,so1:2181 ...

Uploading /home/hadoop/solr-5.5.0/./configs//conf for config gc to ZooKeeper at sda1:2181,sda2:2181,so1:2181


Creating new collection 'gc' using command:

http://localhost:8983/solr/admin/collections?action=CREATE&name=gc&numShards=4&replicationFactor=3&maxShardsPerNode=12&collection.configName=gc


ERROR: Failed to create collection 'gc' due to: org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://XXX.XXX.XXX.43:8983/solr: Error CREATEing SolrCore 'gc_shard2_replica3': Unable to create core [gc_shard2_replica3] Caused by: Unrecognized lockType: native


5. 각 서버에 scp로 복사하고, 링크생성

 가. 각 노드에 복사함
   scp -r -P 22 solr-5.5.0 root@gsda2:$HOME
   scp -r -P 22 solr-5.5.0 root@gsda3:$HOME
   scp -r -P 22 solr-5.5.0 root@gsda4:$HOME
   scp -r -P 22 solr-5.5.0 root@gsda5:$HOME

 나. 링크 생성 : ln -s solr-5.5.0 solr

6. solr서버 기동  (-s option은 solr.xml이 있는 폴더를 지정해준다)

가. 필요한 옵션을 지정하여 기동

./bin/solr start -z gsda1:2181,gsda2:2181,gsda3:2181 -p 8983 \

-s $HOME/solr/server/solr -cloud \

-a "-Dsolr.lock.type=hdfs \

-Dsolr.directoryFactory=HdfsDirectoryFactory \

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

-Dsolr.hdfs.confdir=$HOME/hadoop/etc/hadoop \

"

   * -z 옵션을 주지 않으면 내부의 zookeeper가 기동되므로 반드시 지정해야함(bin/solr.in.sh에 외부 zookeeper정보를 설정하면 생략가능함)


   ==>결과메세지

   Waiting up to 30 seconds to see Solr running on port 8983 [/]  

   Started Solr server on port 8983 (pid=134699). Happy searching!


나. 간략한 기동(solr.in.sh에 필요한 설정을 하고 기동하는 경우임)

  ./bin/solr start


* cloud구성확인 : bin/solr staus에서 liveNodes항목을 확인한다.

* 서버 기동확인(cluster로 구성된 모든 노드에서 가능함) : http://gsda1:8983/ or http://gsda2:8983/ ... http://gsda4:8983

* 서버 기동중지 : bin/solr stop -p 8983


*참고: collection만들기(collection 명칭 gc, shard수 4개, replica수 3개로 구성하는 경우)

가. 사용할 conf정보를 복사하여 수정함.($HOME/solr-5.5.0/server/solr/configsets/data_driven_schema_configs/conf에 있는 파일을 복사하여 사용함)

가. mkdir /home/hadoop/solr/configs/gc/conf

나. cd /home/hadoop/solr/configs/gc

다. cp -r $HOME/solr/server/solr/configsets/data_driven_schema_configs/conf/* .


* solrconfig.xml파일을 수정함

<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>


<lockType>${solr.lock.type:native}</lockType>을

<lockType>${solr.lock.type:hdfs}</lockType> 로 변경한다.


나. colleciton을 zookeeper의 configs znode에 upload


$HOME/solr/server/scripts/cloud-scripts/zkcli.sh -z gsda1:2181 -cmd upconfig -c gc -n gc -d $HOME/solr/server/solr/configsets/gc/conf/


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

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


다. collection생성 


방법1. conf위치를 지정하지 않고 collection 생성(zookeeper에 upload한 정보가 있다면 그것을 사용하여 생성함, SolrCloud에서는 이방법을 사용해야함)

  ==> bin/solr create -c gc -shards 4 -replicationFactor 2

(명령 참고 : solr create [-c name] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port])


Connecting to ZooKeeper at sda1:2181,sda2:2181,so1:2181 ...

Uploading /home/hadoop/solr/server/solr/configsets/data_driven_schema_configs/conf for config gc to ZooKeeper at sda1:2181,sda2:2181,so1:2181


Creating new collection 'gc' using command:

http://localhost:8983/solr/admin/collections?action=CREATE&name=gc&numShards=4&replicationFactor=3&maxShardsPerNode=12&collection.configName=gc


* hadoop conf파일디렉토리를 지정하여도 collection생성시 solr가 HA를 인식하지 못하여 아래와 같은 오류가 발생하므로 cluster명칭을 지정하지 말고 gsda1:9000과 같이 NameNode를 지정해 줘야 오류가 발생하지 않음)

    (solr기동할때 -Dsolr.hdfs.confdir=/svc/apps/sda/bin/hadoop/hadoop/etc/hadoop 를 지정하여줌)

ERROR: Failed to create collection 'gc' due to: org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://XXX.XXX.XXX.43:8983/solr: Error CREATEing SolrCore 'gc_shard4_replica3': Unable to create core [gc_shard4_replica3] Caused by: mycluster


*collection의 conf위치를 지정하지 않으면 zookeeper에 config정보를 확인하고 등록된것이 없으면 디폴트로 "$HOME/solr/server/solr/configsets/data_driven_schema_configs/conf"에 있는 conf정보를 zookeeper에 업로드 하고 이것을 사용함.



방법2.  conf위치를 지정하여 collection 생성(로컬 파일에 위치한 정보를 이용하여 생성하는 경우)

===>-bash-4.1# bin/solr create -c gc -shards 4 -replicationFactor 3 -d $HOME/solr/server/solr/configsets/gc


Copying configuration to new core instance directory:

/svc/apps/sda/bin/hadoop/solr/server/solr/gc


Creating new core 'gc' using command:

http://localhost:8983/solr/admin/cores?action=CREATE&name=gc&instanceDir=gc


{

  "responseHeader":{

    "status":0,

    "QTime":743},

  "core":"gc"}


7. colleciton 변경

가. colleciton삭제

   bin/solr delete -c gc


나. 변경된 config정보를 zookeeper에 upload

./server/scripts/cloud-scripts/zkcli.sh -zkhost gsda1:2181,gsda2:2181,gsda3:2181 -cmd upconfig --confname gc -confdir $HOME/solr/server/solr/configsets/gc/conf


다. colleciton생성(create or create_collction 모두 가능함)

bin/solr create_collection -c gc -shards 4 -replicationFactor 3


8. collection healthcheck

   bin/solr healthcheck -c gc -z gsda1:2181,gsda2:2181,gsda3:2181


* 데몬 확인 : jps -m

17895 jar --module=http


번호 제목 글쓴이 날짜 조회 수
241 Cannot create /var/run/oozie/oozie.pid: Directory nonexistent오류 총관리자 2014.06.03 479
240 DataSetCreator실행시 "Illegal character in fragment at index"오류가 나는 경우 조치방안 총관리자 2016.06.17 480
239 시스템날짜를 현재 정보로 동기화 하는 방법(rdate, ntpdate이용) 총관리자 2014.08.24 481
238 [dovecot]dovecot restart할때 root@gsda4:/usr/lib/dovecot# service dovecot restart 오류 발생시 조치사항 총관리자 2017.06.12 492
237 Incompatible clusterIDs오류 원인및 해결방법 총관리자 2016.04.01 493
236 원격지에서 zio공유기를 통해서 노트북의 mysql접속을 허용하는 방법 총관리자 2014.09.07 495
235 hive기동시 Caused by: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D 오류 발생시 조치사항 총관리자 2016.09.25 496
234 compile할때와 exclude할때 대상을 표현하는 명칭이 다르므로 주의할것 총관리자 2016.08.10 503
233 CDH에서 Sentry 개념및 설정 file 총관리자 2018.06.21 504
232 데이타 제공 사이트 링크 총관리자 2014.08.03 508
231 동시에 많은 요청이 endpoint로 몰려서java.net.NoRouteToHostException가 발생하는 경우의 처리방법 총관리자 2016.10.17 510
230 anaconda3 (v5.2) 설치및 머신러닝 관련 라이브러리 설치 절차 총관리자 2018.07.27 513
229 spark-submit 실행시 "java.lang.OutOfMemoryError: Java heap space"발생시 조치사항 총관리자 2018.02.01 517
228 Ubuntu 16.04 LTS에 4대에 Hadoop 2.8.0설치 총관리자 2017.05.01 521
227 Kafka Offset Monitor로 kafka 상태 모니터링 하기 file 총관리자 2016.11.08 529
226 hadoop의 data디렉토리를 변경하는 방법 총관리자 2014.08.24 536
225 [Kudu]ERROR: Unable to advance iterator for node with id '2' for Kudu table 'impala::core.pm0_abdasubjct': Network error: recv error from unknown peer: Transport endpoint is not connected (error 107) gooper 2023.03.16 536
224 spark client프로그램 기동시 "Error initializing SparkContext"오류 발생할때 조치사항 총관리자 2016.05.27 539
223 spark-shell을 실행하면 "Attempted to request executors before the AM has registered!"라는 오류가 발생하면 총관리자 2018.06.08 545
222 외부 기기(usb, 하드)등 mount(연결)하기 총관리자 2014.08.03 546

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.

위로