메뉴 건너뛰기

Bigdata, Semantic IoT, Hadoop, NoSQL

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


1. 다운로드(Elastic Search)

 가.Elastic Search=>https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.0/elasticsearch-2.3.0.tar.gz


 나.ES-Hadoop=>https://www.elastic.co/thank-you?url=http://download.elastic.co/hadoop/elasticsearch-hadoop-2.2.0.zip


2. 압축풀기

   tar xvfz elasticsearch-2.3.0.tar.gz


3. 링크 생성

  ln -s elasticsearch-2.3.0 elasticsearch


4. config/elasticsearch.yml파일 수정

-bash-4.1# cat elasticsearch.yml 

# ======================== Elasticsearch Configuration =========================

#

# NOTE: Elasticsearch comes with reasonable defaults for most settings.

#       Before you set out to tweak and tune the configuration, make sure you

#       understand what are you trying to accomplish and the consequences.

#

# The primary way of configuring a node is via this file. This template lists

# the most important settings you may want to configure for a production cluster.

#

# Please see the documentation for further information on configuration options:

# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>

#

# ---------------------------------- Cluster -----------------------------------

#

# Use a descriptive name for your cluster:

#

# cluster.name: my-application

cluster.name: iot

#

# ------------------------------------ Node ------------------------------------

#

# Use a descriptive name for the node:

#

# node.name: node-1

node.name: node-1


node.master: true

node.data: false

#

# Add custom attributes to the node:

#

# node.rack: r1

#

# ----------------------------------- Paths ------------------------------------

#

# Path to directory where to store the data (separate multiple locations by comma):

#

# path.data: /path/to/data

path.data: /data/elasticsearch/data

#

# Path to log files:

#

# path.logs: /path/to/logs

path.logs: /logs/elasticsearch/logs

#


# ----------------------------------- Memory -----------------------------------

index.number_of_shareds: 5

index.number_of_replicas: 1



# ----------------------------------- Memory -----------------------------------

#

# Lock the memory on startup:

#

# bootstrap.mlockall: true

#

# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory

# available on the system and that the owner of the process is allowed to use this limit.

#

# Elasticsearch performs poorly when the system is swapping the memory.

#

# ---------------------------------- Network -----------------------------------

#

# Set the bind address to a specific IP (IPv4 or IPv6):

#

# network.host: 192.168.0.1

network.host: xxx.xxx.xxx.43 

#

# Set a custom port for HTTP:

#

# http.port: 9200

http.port: 9200

transport.tcp.port: 9300

transport.tcp.compress: true

http.enabled: true

#

# For more information, see the documentation at:

# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>

#

# --------------------------------- Discovery ----------------------------------

#

# Pass an initial list of hosts to perform discovery when new node is started:

# The default list of hosts is ["127.0.0.1", "[::1]"]

#

# discovery.zen.ping.unicast.hosts: ["host1", "host2"]

discovery.zen.ping.multicast.enabled: false

discovery.zen.ping.unicast.hosts: ["gsda1:9300", "gsda1:9301", "gsda1:9302"]

action.auto_create_index: true

index.mapper.dynamic: true

#

# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):

#

# discovery.zen.minimum_master_nodes: 3

#

# For more information, see the documentation at:

# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>

#

# ---------------------------------- Gateway -----------------------------------

#

# Block initial recovery after a full cluster restart until N nodes are started:

#

# gateway.recover_after_nodes: 3

#

# For more information, see the documentation at:

# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>

#

# ---------------------------------- Various -----------------------------------

#

# Disable starting multiple nodes on a single system:

#

# node.max_local_storage_nodes: 1

#

# Require explicit names when deleting indices:

#

# action.destructive_requires_name: true


# ---------------------------------- Marvel Exporter -----------------------------------

marvel.agent.exporter.es.hosts: ["gsda1:9200", "gsda2:9200", "gsda3:9200", "gsda4:9200", "gsda5:9200"]


5. 각 서버에 scp한다.

scp -r -P 22 elasticsearch-2.3.0 root@sda2:$HOME

scp -r -P 22 elasticsearch-2.3.0 root@gsda3:$HOME

scp -r -P 22 elasticsearch-2.3.0 root@gsda4:$HOME

scp -r -P 22 elasticsearch-2.3.0 root@gsda5:$HOME


6.각 서버(5개)에 들어가서 링크를 생성한다.

ln -s elasticsearch-2.3.0 elasticsearch


7. master로 1개, 나머지 4개는 data용 node로 구성한다.

cluster.name=iot(각서버 모두 동일하게 설정한다.)

network.host=XXX.XXX.XXX.XXX(각각의 ip를 설정한다.)

node.name: node1(각각의 서버에 고유한 값을 설정한다.)


*master 서버에는

node.master: true

node.data: false

로 설정하고 

나머지(data node)는 

node.master: false

node.data: true

로 설정한다.


8. elastic서버 기동(서버 마다 각각 기동시켜준다, root도 실행)

 ==> bin/elasticsearch -d  : daemon으로 띄운다. console에 띄우려면 -d를 빼고 실행한다.

 ==> 헐.. root로 실행하니 아래와 같은 오류가 뜬다..

   이럴때는 "elasticsearch -d -Des.insecure.allow.root=true"명령을 주면 해결된다.


--------------오류내용------------------------------

-bash-4.1# ./elasticsearch -d

-bash-4.1# Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.

        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)

        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)

        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)

        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)

Refer to the log for complete error details.


9. 클러스터/노드 정보를 확인한다.

  가. node정보 확인(각 노드별 확인 가능함) : http://gsda1:9200/

  나. cluster 정보 확인(master노드에서만 확인 가능함) : http://gsda1:9200/_cluster/health?pretty=true

  다. 노드정보 확인(각 노드별 확인 가능함) : http://gsda1:9200/_nodes?pretty=true

  라. 노드정보 확인(각 노드별 확인 가능함) : http://gsda1:9200/_nodes/settings?pretty=true


10. TEST

  가. 인덱스 생성 : -bash-4.1# curl -XPUT 'http://gsda1:9200/blog' ==> {"acknowledged":true}

  나. 인덱스 생성 정보확인 : 

-bash-4.1# curl -XGET 'http://gsda1:9200/blog/_settings?pretty=true'

{

  "blog" : {

    "settings" : {

      "index" : {

        "creation_date" : "1459833926158",

        "number_of_shards" : "5",

        "number_of_replicas" : "1",

        "uuid" : "XoppVt7VQPGgYHP_J4y3fQ",

        "version" : {

          "created" : "2030099"

        }

      }

    }

  }

}

  다. 인덱스 삭제 : -bash-4.1# curl -XDELETE 'http://gsda1:9200/blog'     ==> {"acknowledged":true}

     * 삭제시 물리적으로 바로 삭제되어 복구할 수 없음


11. document 자동색인 (elasticsearch.yml의 index.mapper.dynamic: true가 기본으로 설정되어어함)

 . document추가1(json형식으로 작성하여 등록함)

curl -XPOST 'http://gsda1:9200/blog/article/2' -d '{

"article_id" : 2,

"title" : "This is a Title2",

"content" : "This is a Content2"

}'

===> {"_index":"blog","_type":"article","_id":"2","_version":1,"_shards":{"total":2,"successful":2,"failed":0},"created":true}


* document추가2
curl -XPOST 'http://gsda1:9200/blog/article/1' -d '{
"article_id" : 1,
"title" : "This is a Title1",
"content" : "This is a Content1"
}'
===> {"_index":"blog","_type":"article","_id":"1","_version":1,"_shards":{"total":2,"successful":2,"failed":0},"created":true}

curl -XPOST 'http://gsda1:9200/blog/article/2' -d '{

"article_id" : 2,

"title" : "This is a Title2",

"content" : "This is a Content2"

}'

===> {"_index":"blog","_type":"article","_id":"2","_version":1,"created":true}


 . document 가져오기(id를 지정하여 가져오기)

curl -XGET 'http://gsda1:9200/blog/article/1'

====>

{"_index":"blog","_type":"article","_id":"1","_version":1,"found":true,"_source":{

"article_id" : 1,

"title" : "This is a Title1",

"content" : "This is a Content1"


 . Index, Type Mapping 정보확인

 curl -XGET 'http://gsda1:9200/blog/_mapping?pretty=true'

==>

{

  "blog" : {

    "mappings" : {

      "article" : {

        "properties" : {

          "article_id" : {

            "type" : "long"

          },

          "content" : {

            "type" : "string"

          },

          "title" : {

            "type" : "string"

          }

        }

      }

    }

  }

}

  


*참고: http://gsda1:9200/_cluster/health?pretty=true하면 number_of_nodes와 number_of_data_nodes의 값이 0인 경우가 있는데
이때는 elasticsearch.yml에 
discovery.zen.ping.multicast.enabled: false

discovery.zen.ping.unicast.hosts: ["gsda1:9300", "gsda1:9301", "gsda1:9302"]    #(master서버의 위치를 지정한다)

를 지정하여 명시적으로 master위치를 알려주어야 한다(모든 서버에 반영해야함)


------------------------------discovery.zen.ping.unicast.hosts로 하고 

서버를 모두 기동했는데 했어도 number_of_nodes와 number_of_data_nodes값이 0인 경우의 메세지 내용-------------------------

{
  "cluster_name" : "iot",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 0,
  "number_of_data_nodes" : 0,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}
번호 제목 글쓴이 날짜 조회 수
500 Cannot create /var/run/oozie/oozie.pid: Directory nonexistent오류 총관리자 2014.06.03 479
499 java.util.NoSuchElementException발생시 조치 총관리자 2014.08.27 476
498 Ubuntu 16.04 LTS에 Hive 2.1.1설치하면서 "Version information not found in metastore"발생하는 오류원인및 조치사항 총관리자 2017.05.03 469
497 java.lang.OutOfMemoryError: unable to create new native thread오류 발생지 조치사항 총관리자 2016.10.17 466
496 Spark 1.6.1 설치후 HA구성 총관리자 2016.05.24 455
495 CDH 5.14.2 설치중 agent설치에서 실패하는 경우 확인/조치 총관리자 2018.05.22 450
494 java.lang.IllegalArgumentException: Does not contain a valid host:port authority: master 오류해결방법 총관리자 2015.05.06 449
» Elastic Search For Hadoop 2.2.0설치하기(5대 클러스터링) 총관리자 2016.04.04 447
492 servlet-api를 jar형태로 build할때 포함하지 말고 java 설치 위치의 jre/lib/ext에 복사하여 사용하는것이 좋다. 총관리자 2016.08.10 446
491 spark-sql실행시 The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH오류 발생시 조치사항 총관리자 2016.06.09 441
490 [번역] solr 검색 엔진 튜토리얼 총관리자 2014.10.07 441
489 Drools 6.0 - 비즈니스 룰 기반으로 간단한 룰 애플리케이션 만들기 file 총관리자 2016.07.18 440
488 Could not configure server becase SASL configuration did not allow the Zookeeper server to authenticate itself properly: javax.security.auth.login.LoginException: Checksum failed 총관리자 2019.05.18 434
487 Java 8에서 pom.xml에 JavaDoc 관련 태그가 설정되어 있으나 오류등으로 실패하면 나머지 Maven작업이 종료되는 문제 해결 방법 총관리자 2017.01.24 432
486 elasticsearch 기동시 permission denied on key 'vm.max_map_count' 오류발생시 조치사항 총관리자 2017.06.23 431
485 db를 통째로 새로운 이름의 db로 복사하는 방법/절차 총관리자 2017.11.14 428
484 ontology, jena, sparql등 전반에 대한 설명및 예제를 제공하는 사이트 총관리자 2015.12.08 427
483 Hadoop - 클러스터 세팅및 기동 총관리자 2015.04.28 427
482 Error: Could not find or load main class nodemnager 가 발생할때 해결하는 방법 총관리자 2015.06.05 426
481 Tracking URL = N/A 가발생하는 경우 - 환경설정값을 잘못설정하는 경우에 발생함 총관리자 2015.06.17 423

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.

위로