메뉴 건너뛰기

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


번호 제목 날짜 조회 수
541 cloudera에서 spark-shell를 실행했을때 default master는 spark.master=yarn-client임 2018.06.20 429
540 dr.who로 공격들어오는 경우 조치방법 file 2018.06.09 5713
539 spark-shell을 실행하면 "Attempted to request executors before the AM has registered!"라는 오류가 발생하면 2018.06.08 704
538 SCM서비스를 추가하는 동안 Unexpected error. Unable to verify database connection. 오류발생시 확인 사항 2018.06.08 408
537 Cloudera Manager에서 "Mismatched CDH versions: host has NONE but role expects 5 Suppress..."와 같이 오류 발생시 확인사항 2018.06.06 444
536 JAVA_HOME을 명시적으로 지정하는 방법 2018.06.04 329
535 spark 시동중 applicationHistory 로그 디렉토리가 없다고 하면서 기동되지 않는 경우 2018.06.01 439
534 impala2를 Cloudera Manager가 아닌 수동으로 설치하는 방법 2018.05.30 468
533 MapReduce2.0(YARN)기반의 CDH5 설치시 생성되는 사용자및 권한 부여 2018.05.30 422
532 HUE를 사용할 사용자를 추가 하는 절차 2018.05.29 420
531 JobHistory 서버 기동시 HDFS상에 특정 폴더를 생성할 수 없어서 기동하지 못하는 경우 조치 2018.05.29 2967
530 DataNode를 기동할때 "Block pool ID needed, but service not yet registered with NN" 오류 발생에 따른 조치사항 2018.05.28 1147
529 Cloudera Manager설치및 Uninstall 방법(순서) 2018.05.28 1730
528 우분투 서버에 GUI로 접속하기 file 2018.05.27 518
527 Cloudera Manager재설치하는 동안 "Host is in bad health"오류가 발생하는 경우 확인/조치 사항 2018.05.24 427
526 "You are running Cloudera Manager in non-production mode.." warning메세지가 나타나지 않게 조치하는 방법 2018.05.23 441
525 oozie db변경후 재기동시 "Table 'oozie.VALIDATE_CONN' doesn't exist" 오류 발생시 조치방법 2018.05.23 444
524 Embedded PostgreSql설정을 외부의 MariaDB로변경하기 [1] 2018.05.22 422
523 CDH 5.14.2 설치중 agent설치에서 실패하는 경우 확인/조치 2018.05.22 593
522 Cluster Install -> Provide Login Credentials에서 root가 아닌 다른 사용자를 지정하는 경우 "Exhausted available authentication methods"오류 발생시 조치방법 2018.05.22 391
위로