메뉴 건너뛰기

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

위로