메뉴 건너뛰기

Cloudera, BigData, Semantic IoT, Hadoop, NoSQL

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


번호 제목 날짜 조회 수
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 286
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
위로