메뉴 건너뛰기

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


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

위로