|
Elastic/Elasticsearch 2020. 4. 2. 07:49
Elasticsearch 를 Single Node 로 구성 하기 위한 docker-compose.yml 내용을 살펴 봅니다.
참고문서)
https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
docker-compose.yml)
version: '2.2'
services:
${ES-SERVICE-NAME}:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
container_name: ${ES-SERVICE-NAME}
environment:
- node.name=${NODE-NAME}
- cluster.name=${CLUSTER-NAME}
- discovery.type=single-node
- discovery.seed_hosts=${NODE-NAME}
- path.data=/usr/share/elasticsearch/data
- path.logs=/usr/share/elasticsearch/logs
- bootstrap.memory_lock=true
- http.port=9200
- transport.port=9300
- transport.compress=true
- network.host=0.0.0.0
- http.cors.enabled=false
- http.cors.allow-origin=/https?:\/\/localhost(:[0-9]+)?/
- gateway.expected_master_nodes=1
- gateway.expected_data_nodes=1
- gateway.recover_after_master_nodes=1
- gateway.recover_after_data_nodes=1
- action.auto_create_index=true
- action.destructive_requires_name=true
- cluster.routing.use_adaptive_replica_selection=true
- xpack.monitoring.enabled=false
- xpack.ml.enabled=false
- http.compression=true
- http.compression_level=3
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
nproc:
soft: 1024000
hard: 1024000
nofile:
soft: 1024000
hard: 1024000
sysctls:
net.core.somaxconn: 65000
healthcheck:
test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cat/health || exit 1"]
interval: 30s
timeout: 30s
retries: 3
restart: always
volumes:
- ${NAMED-VOLUME-DATA}:/usr/share/elasticsearch/data:rw
- ${NAMED-VOLUME-LOG}:/usr/share/elasticsearch/logs:rw
# - ${FULL-PATH-DATA}:/usr/share/elasticsearch/data:rw
# - ${FULL-PATH-LOG}:/usr/share/elasticsearch/logs:rw
ports:
- 9200:9200
- 9300:9300
expose:
- 9200
- 9300
networks:
- ${NETWORK-NAME}
volumes:
${NAMED-VOLUME-DATA}:
driver: local
${NAMED-VOLUME-LOG}:
driver: local
networks:
${NETWORK-NAME}:
driver: bridge
Single Node 로 구성 하기 위해 중요한 설정은
- environment: 섹션에서 discovery.type=single-node
입니다.
만약, Clustering 구성을 하고 싶다면 위 설정을 제거 하고 아래 세개 설정을 작성 하시면 됩니다.
- cluster.initial_master_nodes=# node 들의 private ip 를 등록 합니다. - discovery.seed_hosts=# node 들의 private ip 를 등록 합니다.
- network.publish_host=# 컨테이너가 떠 있는 host 의 private ip 를 등록 합니다.
path.data 에 대한 구성을 복수로 하고 싶으실 경우
- volumes: 섹션에서 named volume 을 여러개 설정 하시거나
- bind mount 설정을 구성 하셔서
적용 하시면 됩니다.
위 docker-compose.yml 을 기준으로 single node 구성과 cluster 구성을 모두 하실 수 있습니다.
- ${....} 는 변수명 입니다.
- 본인의 환경에 맞춰 작명(?) 하셔서 변경 하시면 됩니다.
Elastic/Elasticsearch 2020. 3. 27. 16:05
Elasticsearch 버전이 올라 가면서 master node 를 최소 쿼럼 구성으로 해야 하는데요.
아마 잘 아시겠지만 Single node 구성을 원하시는 분은 아래 설정을 통해서 실행 하시면 됩니다.
[Single node 설정]
discovery.type=single-node
이 설정은 아래 설정이 포함되어 있을 경우 충돌이 납니다.
cluster.initial_master_nodes
본 설정을 주석 처리 하거나 삭제 하신 후 실행 시키면 정상 동작 합니다.
Elastic 공식 문서에 자세한 설명이 나와 있으니 참고 하시면 좋습니다.
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery-settings.html#modules-discovery-settings
Elastic/Elasticsearch 2019. 8. 28. 10:54
사용성에서 정확한 정의가 없어서 많이들 헷갈려 하셨던 Node 가 정리가 된 것 같아 기록해 봅니다.
원문 링크)
https://www.elastic.co/guide/en/elasticsearch/reference/7.3/modules-node.html
Master Eligible Node
- node.master
마스터 노드는 전용으로 구성 하는 것을 추천 하며, 최소한의 작업을 수행 하도록 하는 것이 좋습니다.
Data Node
- node.data
CPU-, Memory-, I/O 성능 영향을 많이 받기 때문에 좋은 장비로 구성 하시길 추천 드립니다.
또한 Network 사용량에 대한 고려도 해야 합니다.
Ingest Node
- node.ingest
Machine Learning Node (x-pack)
- node.ml
Coordinating Node
node.master: false
node.data: false
node.ingest: false
node.ml: false
이 노드의 수를 너무 많이 늘리지 않도록 주의 하는게 좋습니다.
이유는 마스터 노드가 선출 되었을 때 모든 노드의 승인을 기다리게 되어 오히려 성능적으로 손해를 볼 수도 있습니다.
Voting Only Node (x-pack)
- node.voting_only
ITWeb/개발일반 2016. 3. 31. 11:23
imac osx에 node.js 를 이용한 웹서비스 구성 테스트 입니다. 기존에 잘 작성된 문서들이 많아서 그냥 참고해서 그대로 따라해 보았습니다. 다만, 구성 하면서 springmvc 와 비교를 해보면서 전통적인 웹 개발 방법보다 어떤 장점을 갖는지 이해하고자 하였습니다.
- Node.js
- Express
- Express Generator
- EJS 템플릿
- 설치하기
- $ sudo npm install -g express-generator
- 샘플코드 참고 사이트
ejs 템플릿 생성하기 $ express --ejs
create : .
create : ./package.json
create : ./app.js
create : ./public
create : ./public/images
create : ./public/stylesheets
create : ./public/stylesheets/style.css
create : ./routes
create : ./routes/index.js
create : ./routes/users.js
create : ./views
create : ./views/index.ejs
create : ./views/error.ejs
create : ./bin
create : ./bin/www
install dependencies:
$ cd . && npm install
run the app:
$ DEBUG=ExampleEJS:* npm start
create : ./public/javascripts
|
- package.json
- 본 서비스에서 사용 또는 설치 되어야 할 모듈을 모두 정의해 둡니다.
- maven 으로 비교 하면 dependency 기능과 비슷합니다.
- 정의가 끝나면 $ npm install 을 통해 설치를 합니다.
- app.js
- 본 서비스 또는 어플리케이션에 대한 global 설정을 하게 됩니다.
- 여기서 URI 등록 작업이 이루어 지며, SpringMVC 에서 @Controller 내 @RequestMapping 과 같은 기능을 처리 합니다.
- routes 를 등록하여 사용이 가능 하며, routes/*.js 에서 MVC 구성을 하면 됩니다.
- bin/www
- http server를 생성 하며 설정 정보를 기록 합니다.
- views/*.ejs
- jsp 나 jstl 과 같은 역할을 하는 view 파일들이 위치 합니다.
- 실시간 수정이 가능 합니다.
- routes/*.js
- spring mvc 에서 controller, bo, dao 와 같은 역할의 파일들이 위치 합니다.
- 수정 내용 반영을 위해서는 재시작을 해야 합니다.
- public/*
ExampleEJS <!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel= 'stylesheet' href= '/stylesheets/style.css' />
</head>
<body>
<h1><%= title %></h1>
<% for ( var i = 0; i < 5; i++) { %>
<p>Welcome to <%= title %></p>
<% } %>
</body>
</html>
var express = require( 'express' );
var router = express.Router();
router.get( '/' , function (req, res) {
res.render( 'index' , { title: 'Express' });
});
module.exports = router;
|
- PM2
- 참조사이트
- 설치
- $ sudo npm install -g pm2
- 실행
- 기존에 $ node app.js 로 실행을 했다면, $ pm2 start app.js 로 실행이 가능 합니다.
Elastic/Elasticsearch 2015. 12. 11. 15:56
bulk indexing 을 하다 보면 색인 하는 과정에서 느려지는 현상을 경험 할 수 있습니다. 여러가지 원인이 있을 수 있지만 간단하게 설정을 통해서 성능 향상을 시킬수 있는 방법을 소개해 드립니다.
기본적인 정보는 이미 Elasticsearch Reference 에서 제공하고 있기 때문에 관련 내용을 찾아 보시면 이해 하시는데 도움이 됩니다.
참고문서)
Elasticsearch 역시 lucene 기반의 검색 엔진이기 때문에 과거부터 전해져 오는 segment merge 시 발생 하는 성능 저하 문제는 피해 갈 수가 없습니다. 이를 좀 더 효율적으로 사용하기 위해 아래 설정을 활용 하시면 됩니다.
Merge throttle 은 두 가지 방법을 제공해 주고 있습니다.
1. Node level throttle 이것은 merge 동작은 shard 단위로 발생을 하기 때문에 같은 node 에 있는 shard 들은 동일한 자원을 사용하게 됩니다. 즉, disk i/o 에 대한 경합을 할 수 밖에 없는 것인데요. 이런 이유로 node level 설정을 사용하게 됩니다.
indices.store.throttle.type: “merge” ## all, none indices.store.throttle.max_bytes_per_sec: “20mb"
※ 여기서 수정이 필요한 부분은 색인 데이터의 크기를 감안해서 max_bytes_per_sec 을 적합한 크기로 설정해 주시면 됩니다.
2. Index level throttle 특정 index 에 대해서 관리를 하고 싶을 때 node level throttle 설정을 무시 하고 설정을 하도록 해주는 것입니다. 설정 방법은 index update settings 를 통해서 할 수 있습니다.
index.store.throttle.type: “node" index.store.throttle.max_bytes_per_sec: “20mb"
※ 여기서 수정이 필요한 부분은 색인 데이터의 크기를 감안해서 max_bytes_per_sec 을 적합한 크기로 설정해 주시면 됩니다. ※ throttle type을 none 으로 할 경우 disable merge 설정이 됩니다.
Elastic/Elasticsearch 2015. 12. 9. 12:05
tribe node는 서로 다른 cluster로 구성된 elasticsearch의 데이터에 대해서 질의 또는 색인이 가능 하도록 제공하는 기능 입니다. RDBMS의 view 와 비슷한 개념이라고 생각 하시면 쉽습니다.
참고문서) https://www.elastic.co/guide/en/elasticsearch/reference/2.1/modules-tribe.html https://www.elastic.co/blog/clustering_across_multiple_data_centers https://www.elastic.co/blog/tribe-node
이제 부터 간단하게 구성하는 방법을 살펴 보겠습니다. elasticsearch 다운로드와 설치 과정은 아래 링크 참고하세요. - https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html - https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html
1. 노드구성 위에서 이야기 한 것과 같이 서로 다른 Cluster라고 했습니다. 그렇기 때문에 standalone 구성의 cluster 두 개를 준비 하겠습니다. 더불어 tribe node 도 하나 구성을 합니다. - 총 3개의 노드
2. 노드설정 - Cluster 1 [elasticsearch.yml] cluster.name: t1-cluster node.name: t1-node http.port: 9201 transport.tcp.port: 9301 index.number_of_shards: 1 index.number_of_replicas: 0
- Cluster 2 [elasticsearch.yml] cluster.name: t2-cluster node.name: t2-node http.port: 9202 transport.tcp.port: 9302 index.number_of_shards: 1 index.number_of_replicas: 0
- Tribe Node(cluster) [elasticsearch.yml] tribe.t1.cluster.name: "t1-cluster" tribe.t1.discovery.zen.ping.multicast.enabled: false tribe.t1.discovery.zen.ping.unicast.hosts: ["localhost:9301"] tribe.t2.cluster.name: "t2-cluster" tribe.t2.discovery.zen.ping.multicast.enabled: false tribe.t2.discovery.zen.ping.unicast.hosts: ["localhost:9302"] tribe.blocks.write: true tribe.blocks.metadata: true cluster.name: "tribe-cluster" node.name: "tribe-node" http.port: 9200
3. 클러스터실행 생성한 3개의 클러스터를 실행 합니다.
4. Cluste 1과 Cluster 2에 Index 생성 및 색인 그냥 구성 샘플이라 문서 하나씩만 색인 하겠습니다.
Cluster 1) - sample1.json {"index":{"_index":"db", "_type":"tbl"}} {"number":"1","name":"MALICE MIZER","url":"http://www.last.fm/music/MALICE+MIZER","picture":"http://userserve-ak.last.fm/serve/252/10808.jpg","@timestamp":"2000-10-06T19:20:25.000Z"}
$ curl -XPOST http://localhost:9201/db/tbl/_bulk --data-binary @sample1.json
Cluster 2) - sample2.json {"index":{"_index":"db2", "_type":"tbl"}} {"number":"2","name":"Diary of Dreams","url":"http://www.last.fm/music/Diary+of+Dreams","picture":"http://userserve-ak.last.fm/serve/252/3052066.jpg","@timestamp":"2001-10-06T19:20:25.000Z"}
$ curl -XPOST http://localhost:9202/db2/tbl/_bulk --data-binary @sample2.json
5. Tribe Node(Cluster)를 이용한 질의 질의) Cluster 1 $ curl -XGET "http://localhost:9200/db/_search" -d' { "query": { "match_all": {} } }'
결과) { "took": 24, "timed_out": false, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "hits": { "total": 1, "max_score": 1, "hits": [ { "_index": "db", "_type": "tbl", "_id": "AVFhPAntBw75btupmZWX", "_score": 1, "_source": { "number": "1", "name": "MALICE MIZER", "url": "http://www.last.fm/music/MALICE+MIZER", "picture": "http://userserve-ak.last.fm/serve/252/10808.jpg", "@timestamp": "2000-10-06T19:20:25.000Z" } } ] } }
질의) Cluster 2 $ curl -XGET "http://localhost:9200/db2/_search" -d' { "query": { "match_all": {} } }'
결과) { "took": 16, "timed_out": false, "_shards": { "total": 1, "successful": 1, "failed": 0 }, "hits": { "total": 1, "max_score": 1, "hits": [ { "_index": "db2", "_type": "tbl", "_id": "AVFha2Vz4YXacqLkqH0V", "_score": 1, "_source": { "number": "2", "name": "Diary of Dreams", "url": "http://www.last.fm/music/Diary+of+Dreams", "picture": "http://userserve-ak.last.fm/serve/252/3052066.jpg", "@timestamp": "2001-10-06T19:20:25.000Z" } } ] } }
View 질의) Tribe Node(Cluster) $ curl -XGET "http://localhost:9200/_search" -d' { "query": { "match_all": {} } }'
결과) { "took": 12, "timed_out": false, "_shards": { "total": 2, "successful": 2, "failed": 0 }, "hits": { "total": 2, "max_score": 1, "hits": [ { "_index": "db", "_type": "tbl", "_id": "AVFhPAntBw75btupmZWX", "_score": 1, "_source": { "number": "1", "name": "MALICE MIZER", "url": "http://www.last.fm/music/MALICE+MIZER", "picture": "http://userserve-ak.last.fm/serve/252/10808.jpg", "@timestamp": "2000-10-06T19:20:25.000Z" } }, { "_index": "db2", "_type": "tbl", "_id": "AVFha2Vz4YXacqLkqH0V", "_score": 1, "_source": { "number": "2", "name": "Diary of Dreams", "url": "http://www.last.fm/music/Diary+of+Dreams", "picture": "http://userserve-ak.last.fm/serve/252/3052066.jpg", "@timestamp": "2001-10-06T19:20:25.000Z" } } ] } }
※ 부가적으로 alias 기능과 함께 활용하시면 아주 유용하게 사용하실 수 있습니다.
Elastic/TheDefinitiveGuide 2015. 11. 24. 17:04
원본링크) https://www.elastic.co/guide/en/elasticsearch/guide/current/_an_empty_cluster.html
Elasitcsearch에가 이야기 하는 master node 의 역할 과 주의 사항이랄까요? 아래는 원문에 대한 Snippet 입니다.
One node in the cluster is elected to be the master node, which is in charge of managing cluster-wide changes like creating or deleting an index, or adding or removing a node from the cluster. The master node does not need to be involved in document-level changes or searches, which means that having just one master node will not become a bottleneck as traffic grows. Any node can become the master. Our example cluster has only one node, so it performs the master role.
[마스터 노드가 하는 일?]
[마스터 노드에서 하면 안되는 일?]
하면 안될 일은 트래픽 증가 시 병목 현상이 마스터 노드에서 발생 하면 안되기 때문 입니다. (장애 납니다. ^^;)
Elastic/Elasticsearch 2014. 1. 14. 17:34
참고글 : http://stackoverflow.com/questions/15019821/what-differents-between-master-node-gateway-and-other-node-gateway-in-elasticsea 참고 하시라고 올려 봅니다.
[원문]
The master node is the same as any other node in the cluster, except that it has been elected to be the master. It is responsible for coordinating any cluster-wide changes, such as
as the addition or removal of a node, creation, deletion or change of
state (ie open/close) of an index, and the allocation of shards to
nodes. When any of these changes occur, the "cluster state" is updated
by the master and published to all other nodes in the cluster. It is the
only node that may publish a new cluster state. The tasks that a master performs are lightweight. Any tasks that deal
with data (eg indexing, searching etc) do not need to involve the
master. If you choose to run the master as a non-data node (ie a node
that acts as master and as a router, but doesn't contain any data) then
the master can run happily on a smallish box. A node is allowed to become a master if it is marked as "master
eligible" (which all nodes are by default). If the current master goes
down, a new master will be elected by the cluster. An important configuration option in your cluster is minimum_master_nodes .
This specifies the number of "master eligible" nodes that a node must
be able to see in order to be part of a cluster. Its purpose is to
avoid "split brain" ie having the cluster separate into two clusters,
both of which think that they are functioning correctly. For instance, if you have 3 nodes, all of which are master eligible, and set minimum_master_nodes
to 1, then if the third node is separated from the other two it, it
still sees one master-eligible node (itself) and thinks that it can form
a cluster by itself. Instead, set minimum_master_nodes to 2 in this case
(number of nodes / 2 + 1), then if the third node separates, it won't
see enough master nodes, and thus won't form a cluster by itself. It
will keep trying to join the original cluster. While Elasticsearch tries very hard to choose the correct defaults, minimum_master_nodes
is impossible to guess, as it has no way of knowing how many nodes you
intend to run. This is something you must configure yourself.
[구글 번역] 마스터 노드 는마스터로 선출 되었음을 제외하고 ,클러스터의 다른 노드 와 동일하다.
ITWeb/개발일반 2007. 12. 6. 14:41
dynamic 하게 dom 객체를 생성하거나 해서 삽입하고 할때 알고 있어야 하는 코드들이라서 올려 봅니다. 뭐 저 한테 필요한 거라 이곳에 기록해 두기는 하는 거지만 DOM 을 공부 하시는 분들은 필요한 정보 같아 공유해 봅니다. ref. http://www.w3schools.com/dom/dom_nodetype.asp
Node Types
The following table lists the different W3C node types, and which node types they may have as children:
Node type |
Description |
Children |
Document |
Represents the entire document (the root-node of the DOM tree) |
Element (max. one), ProcessingInstruction, Comment, DocumentType |
DocumentFragment |
Represents a "lightweight" Document object, which can hold a portion of a document |
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference |
DocumentType |
Provides an interface to the entities defined for the document |
None |
ProcessingInstruction |
Represents a processing instruction |
None |
EntityReference |
Represents an entity reference |
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference |
Element |
Represents an element |
Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference |
Attr |
Represents an attribute |
Text, EntityReference |
Text |
Represents textual content in an element or attribute |
None |
CDATASection |
Represents a CDATA section in a document (text that will NOT be parsed by a parser) |
None |
Comment |
Represents a comment |
None |
Entity |
Represents an entity |
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference |
Notation |
Represents a notation declared in the DTD |
None |
Node Types - Return Values
The following table lists what the nodeName and the nodeValue properties will return for each node type:
Node type |
nodeName returns |
nodeValue returns |
Document |
#document |
null |
DocumentFragment |
#document fragment |
null |
DocumentType |
doctype name |
null |
EntityReference |
entity reference name |
null |
Element |
element name |
null |
Attr |
attribute name |
attribute value |
ProcessingInstruction |
target |
content of node |
Comment |
#comment |
comment text |
Text |
#text |
content of node |
CDATASection |
#cdata-section |
content of node |
Entity |
entity name |
null |
Notation |
notation name |
null |
NodeTypes - Named Constants
NodeType |
Named Constant |
1 |
ELEMENT_NODE |
2 |
ATTRIBUTE_NODE |
3 |
TEXT_NODE |
4 |
CDATA_SECTION_NODE |
5 |
ENTITY_REFERENCE_NODE |
6 |
ENTITY_NODE |
7 |
PROCESSING_INSTRUCTION_NODE |
8 |
COMMENT_NODE |
9 |
DOCUMENT_NODE |
10 |
DOCUMENT_TYPE_NODE |
11 |
DOCUMENT_FRAGMENT_NODE |
12 |
NOTATION_NODE |
|