각 카산드라 노드에는 특정 토큰 범위가 지정되며 모든 데이터의 부분 집합을 담당한다. 

파티션 키 해시 생성을 담당하는 컴포넌트를 파티셔녀(partitioner)라 한다. 따라서 파티셔너는 주어진 파티션 키의 해시를 계산할 때 사용되며 데이터가 어느 노드에 위치해야 하는지 결정하는 해시 함수이다. 카산드라는 3개의 파티셔너를 제공한다.




1. Murmur3Partitioner : 카산드라 1.2이후의 기본 파티션이다. 해당 파티셔너는 머머(Murmur) 해시 값을 계산하여 클러스터 전체에 데이터를 균일하게 분배한다. 머머 해시 값의 범위는 -263에서 -263-1이다. 해당 파티셔너는 해싱 알고리즘이 빠르고 다른 파티셔너보다 성능이 뛰어나기 때문에 선호된다.



2. RandomPartitioner : 해당 파티셔너는 파티션 키의 MD5 해시 값을 계산해 데이터를 균일하게 분산한다. 해당 파티셔너는 카산드라 초기 버전의 기본 파티셔너였다. 해시 값의 범위는 0에서 2127-1 범위이다.



3. ByteOrderedPartitioner : 해당 파티셔너는 키 바이트 단위로 정렬된 데이터 분포를 어휘적으로 유지한다. 해당 파티셔너는 카산드라의 최신 버전(2.x)에서 사용되지 않고 앞으로 사라질 예정이다. 하지만 예전부터 사용해왔기 때문에 삭제는 되지 않은 상태이다. 해당 파티셔너는 일반적으로 핫스팟(hotspot)과 고르지 않은 로드 밸런싱을 유발시킬 수 있어서 사용하지 않는 것이 좋다.

Posted by '김용환'
,



https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-threadpool.html



Thread pool typesedit

The following are the types of thread pools and their respective parameters:

fixededit

The fixed thread pool holds a fixed size of threads to handle the requests with a queue (optionally bounded) for pending requests that have no threads to service them.

The size parameter controls the number of threads, and defaults to the number of cores times 5.

The queue_size allows to control the size of the queue of pending requests that have no threads to execute them. By default, it is set to -1 which means its unbounded. When a request comes in and the queue is full, it will abort the request.

thread_pool:
    index:
        size: 30
        queue_size: 1000

scalingedit

The scaling thread pool holds a dynamic number of threads. This number is proportional to the workload and varies between the value of the core and max parameters.

The keep_alive parameter determines how long a thread should be kept around in the thread pool without it doing any work.

thread_pool:
    warmer:
        core: 1
        max: 8
        keep_alive: 2m


Posted by '김용환'
,

[펌] fluentd 성능

Cloud 2017. 8. 21. 18:46

https://github.com/fluent/fluentd-benchmark/tree/master/one_forward



CPU	Xeon E5-2670 2.60GHz x 2 (32 Cores)
Memory	24G
Disk	300G(10000rpm) x 2 [SAS-HDD]
OS CentOS release 6.2 (Final)

Result

Agent
rate of writing (lines/sec)reading (lines/sec)CPU (%)Memory (kB)Remarks
10100.229304
1001000.335812
100010001.337864
10000100006.639912
1000001000006239912
200000157148100.436280MAX
300000N/A
400000N/A
5247047N/AMAX of dummer tool


'Cloud' 카테고리의 다른 글

[etcd] etcd 설치와 간단 예제  (0) 2017.08.23
fluent-plugin-extract_query_params  (0) 2017.08.23
[td-agent] td-agent 설치 및 테스트  (0) 2017.08.18
fluentd 공부  (0) 2017.08.16
[펌] 한국 오픈 스택 2017 자료 올라옴  (0) 2017.08.16
Posted by '김용환'
,


elasticsearch에 실수로 long time 쿼리를 실행했지만... 요청을 더 이상 실행하고 싶지 않다면, 재시작을 하는 것이 좋다. 다. 





만약 elasticsearch 2.x 이상의 버전을 사용하고 있다면..다음을 참조한다. 


https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html



GET _tasks 호출 후, 해당 task_id를 찾은 후 POST _tasks/node_id:task_id/_cancel를 호출한다..


Posted by '김용환'
,


td-agent 설치하는 예제이다. td-agent는 fluentd의 래퍼 프로그램이다. 



rpm은 다음 링크로 설치한다. 


http://docs.fluentd.org/articles/install-by-rpm




$ sudo usermod -a -G adm td-agent

$ sudo -E /usr/sbin/td-agent-gem install fluent-plugin-record-reformer -v 0.8.2

$ sudo -E /usr/sbin/td-agent-gem install fluent-plugin-grep -v 0.3.4

$ sudo -E /usr/sbin/td-agent-gem install fluent-plugin-fields-parser -v 0.1.1




설치가 제대로 되었는지 확인한다. 


$ td-agent --version

td-agent 0.12.12





설정 파일을 생성한다.


$ sudo vi /etc/td-agent/td-agent.conf



 <source>

    type tail

    path /tmp/test.log

    pos_file /var/run/td-agent/test.log.pos

    tag public.test-service1.raw

    format /^(?<time>\S+ \S+) - \[(?<level>\S+)\] (?<msg>.+)/

    time_format %Y-%m-%d %H:%M:%S,%L

  </source>

  <match public.test-service1.raw>

    type record_reformer

    enable_ruby false

    tag public.test-service1

    <record>

      hostname ${hostname}

      phase alpha

    </record>

  </match>

  <match public.test-service1>

    type stdout

  </match>
</source>

  


문법을 확인한다.


sudo td-agent -c /etc/td-agent/td-agent.conf



데몬 실행 후 /tmp/test.log 로그를 확인한다.



2017-08-18 19:39:39,000 - [WARN] time over

2017-08-18 19:39:39 +0900 public.test-service1: {"level":"WARN","msg":"time over","hostname":"aaaaa.google.com","phase":"alpha"}



잘 동작하면 td-agent가 계속 동작하도록 한다.


sudo /sbin/chkconfig td-agent on

'Cloud' 카테고리의 다른 글

fluent-plugin-extract_query_params  (0) 2017.08.23
[펌] fluentd 성능  (0) 2017.08.21
fluentd 공부  (0) 2017.08.16
[펌] 한국 오픈 스택 2017 자료 올라옴  (0) 2017.08.16
[펌] fluentd 사용 사례  (0) 2017.08.15
Posted by '김용환'
,



elasticsearch의 쓰레드 상태를 보려면 다음과 같은 _cat/thread_pool 를 본다. 


$ curl -s http://abc.google.com:9200/_cat/thread_pool


abc.google.com           bulk                 7  0  784202

abc.google.com           fetch_shard_started  0  0       0

abc.google.com           fetch_shard_store    0  0       0

abc.google.com           flush                0  0       0

abc.google.com           force_merge          0  0       0

abc.google.com           generic              0  0       0

abc.google.com           get                  0  0       0





3,4,5번째 컬럼은 active, queue, rejected를 의미한다. 


bulk api thread가 더이상 요청을 받지 못해 rejected 된 현황을 보여준다. 

Posted by '김용환'
,



* master 브랜치 기반의 PR(pull request) 



먼저 github 원격 저장소를 내 저장소로 fork한다. 


내 github 저장소를 origin, 원격 githubub 저장소를 real이라고 지정한다. 




# git clone https://github.com/samuel-kim/optools.git


# git remote add real https://github.com/cassandra/optools.git


# git remote -v


origin https://github.com/samuel-kim/optools.git (fetch)

origin https://github.com/samuel-kim/optools.git (push)

real https://github.com/cassandra/optools.git (fetch)

real https://github.com/cassandra/optools.git (push)




내 저장소의 master 브랜치를 기반으로 새로운 브랜치를 만든다. 


git checkout -b fix_errata


코드 수정하고 푸시한다. 


git add .

git commit -m 'fix errata'

git push origin




원격 github 웹 페이지에 접속하면 "Compare & pull reqeust"이 보인다.

어느 브랜치에 PR할지 결정한다. 


PR이 완료되면, master 브랜치로 이동한다.


git checkout master


기존 브랜치를 삭제한다. 


git branch -d fix_errata


리모트 브랜치를 삭제한다. 


git push origin --delete fix_errata



real의 master를 origin의 master에 merge한다. 즉 원격 github 저장소의 master에 머징된 내용(새로워짐)을 내 저장소의 master(구버전)로 병합한다. 


현재 origin master로 되어 있다. origin master(내꺼)를 기준으로 원본 real의 master(기준)의 내용을 rebase한다. 


$ git branch -l

* master


$ git rebase real/master



origin master에 push한다. 


git push origin origin/master





이미 origin 저장소의 브랜치로 checkout된 상태에서 

저 멀리 real 은 코드 푸시가 다량으로 일어날  있고, 시간이 지나면서 내 저장소인 origin과의 소스 커밋 차이가 발생한다.


그 때는 브랜치에서 다음 커맨드를 실행해 브랜치 상황을 살펴 본다.


git pull real



만약 master만 real 브랜치의 새로운 버전으로 다운받고 싶다면 다음 커맨드를 실행한다.


git pull real master


그리고 push하면 동일하게 맞춰진다. 


git push 





Posted by '김용환'
,




https://jekyllrb-ko.github.io/ 를 참고..



먼저 jekull을 설치한다.



git clone ...

cd ...

gem install jekyll

jekyll serve --host 0.0.0.0


index.md 페이지는 http://localhost:4000/index으로 접근할 수 있다.

op.md 페이지는 http://localhost:4000/op로 접근할 수 있다. 






Posted by '김용환'
,

fluentd 공부

Cloud 2017. 8. 16. 16:22


기존에 ruby 2.1.0이 설치되어 있고, fluentd 0.14를 사용해서 fluentd를 테스트해본다.



설치 방법은 다음과 같다. 


$ gem install fluentd -v "~> 0.12.0" --no-ri --no-rdoc

Fetching: string-scrub-0.0.5.gem (100%)

Building native extensions.  This could take a while...

Successfully installed string-scrub-0.0.5

Fetching: fluentd-0.12.39.gem (100%)

Successfully installed fluentd-0.14.20

2 gems installed



버전을 확인한다. 


$ fluentd --version

fluentd 0.14.20




설정 파일을 생성하고 fluentd를 실행한다. 설정 파일과 플러그인 파일을 읽는 로그를 확인할 수 있다.


$ fluentd --setup ./fluent

Installed ./fluent/fluent.conf.



$ fluentd -c ./fluent/fluent.conf -vv

2017-08-16 16:18:25 +0900 [info]: fluent/log.rb:316:call: parsing config file is succeeded path="./fluent/fluent.conf"

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered output plugin 'stdout'

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered buffer plugin 'memory'

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered formatter plugin 'stdout'

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered formatter plugin 'json'

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered output plugin 'forward'

2017-08-16 16:18:25 +0900 [info]: fluent/log.rb:316:call: adding forwarding server '192.168.0.12:24224' host="192.168.0.12" port=24224 weight=60 plugin_id="object:3ff3daa51474"

2017-08-16 16:18:25 +0900 [info]: [forward_output] adding forwarding server '192.168.0.11:24224' host="192.168.0.11" port=24224 weight=60 plugin_id="forward_output"

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered input plugin 'forward'

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered parser plugin 'in_http'

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered input plugin 'http'

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered parser plugin 'msgpack'

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered parser plugin 'json'

2017-08-16 16:18:25 +0900 [info]: [http_input] Oj is not installed, and failing back to Yajl for json parser

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered input plugin 'monitor_agent'

2017-08-16 16:18:25 +0900 [trace]: fluent/log.rb:275:call: registered input plugin 'debug_agent'

2017-08-16 16:18:25 +0900 [info]: fluent/log.rb:316:call: using configuration file: <ROOT>

  <source>

    @type forward

    @id forward_input

  </source>

  <source>

    @type http

    @id http_input

    port 8888

  </source>

  <source>

    @type monitor_agent

    @id monitor_agent_input

    port 24220

  </source>

  <source>

    @type debug_agent

    @id debug_agent_input

    bind "127.0.0.1"

    port 24230

  </source>

  <match debug.**>

    @type stdout

    @id stdout_output

  </match>

  <match system.**>

    @type forward

    @id forward_output

    <server>

      host "192.168.0.11"

    </server>

    <secondary>

      <server>

        host "192.168.0.12"

      </server>

    </secondary>

  </match>

</ROOT>

2017-08-16 16:18:25 +0900 [info]: fluent/log.rb:316:call: starting fluentd-0.14.20 pid=11375

2017-08-16 16:18:25 +0900 [info]: fluent/log.rb:316:call: spawn command to main:  cmdline=["/Users/samuel.kim/.story-spec/opt/ruby/bin/ruby", "-Eascii-8bit:ascii-8bit", "/Users/samuel.kim/.story-spec/opt/ruby/bin/fluentd", "-c", "./fluent/fluent.conf", "-vv", "--under-supervisor"]

2017-08-16 16:18:26 +0900 [info]: fluent/log.rb:316:call: gem 'fluentd' version '0.14.20'

2017-08-16 16:18:26 +0900 [info]: fluent/log.rb:316:call: gem 'fluentd' version '0.12.39'

2017-08-16 16:18:26 +0900 [info]: fluent/log.rb:316:call: adding match pattern="debug.**" type="stdout"

2017-08-16 16:18:26 +0900 [trace]: #0 fluent/log.rb:275:call: registered output plugin 'stdout'

2017-08-16 16:18:26 +0900 [trace]: #0 fluent/log.rb:275:call: registered buffer plugin 'memory'

2017-08-16 16:18:26 +0900 [trace]: #0 fluent/log.rb:275:call: registered formatter plugin 'stdout'

2017-08-16 16:18:26 +0900 [trace]: #0 fluent/log.rb:275:call: registered formatter plugin 'json'

2017-08-16 16:18:26 +0900 [info]: fluent/log.rb:316:call: adding match pattern="system.**" type="forward"

2017-08-16 16:18:26 +0900 [trace]: #0 fluent/log.rb:275:call: registered output plugin 'forward'

2017-08-16 16:18:26 +0900 [info]: #0 fluent/log.rb:316:call: adding forwarding server '192.168.0.12:24224' host="192.168.0.12" port=24224 weight=60 plugin_id="object:3fe29618a3b8"

2017-08-16 16:18:26 +0900 [info]: #0 [forward_output] adding forwarding server '192.168.0.11:24224' host="192.168.0.11" port=24224 weight=60 plugin_id="forward_output"

2017-08-16 16:18:26 +0900 [info]: fluent/log.rb:316:call: adding source type="forward"

2017-08-16 16:18:26 +0900 [trace]: #0 fluent/log.rb:275:call: registered input plugin 'forward'

2017-08-16 16:18:26 +0900 [info]: fluent/log.rb:316:call: adding source type="http"

2017-08-16 16:18:26 +0900 [trace]: #0 fluent/log.rb:275:call: registered parser plugin 'in_http'




로그는 fluent/fluent.conf에 있다. 로그의 내용과 동일하다. 


$ cat fluent/fluent.conf

# In v1 configuration, type and id are @ prefix parameters.

# @type and @id are recommended. type and id are still available for backward compatibility


## built-in TCP input

## $ echo <json> | fluent-cat <tag>

<source>

  @type forward

  @id forward_input

</source>


## built-in UNIX socket input

#<source>

#  @type unix

#</source>


# HTTP input

# http://localhost:8888/<tag>?json=<json>

<source>

  @type http

  @id http_input


  port 8888

</source>


## File input

## read apache logs with tag=apache.access

#<source>

#  @type tail

#  format apache

#  path /var/log/httpd-access.log

#  tag apache.access

#</source>


# Listen HTTP for monitoring

# http://localhost:24220/api/plugins

# http://localhost:24220/api/plugins?type=TYPE

# http://localhost:24220/api/plugins?tag=MYTAG

<source>

  @type monitor_agent

  @id monitor_agent_input


  port 24220

</source>


# Listen DRb for debug

<source>

  @type debug_agent

  @id debug_agent_input


  bind 127.0.0.1

  port 24230

</source>


## match tag=apache.access and write to file

#<match apache.access>

#  @type file

#  path /var/log/fluent/access

#</match>


## match tag=debug.** and dump to console

<match debug.**>

  @type stdout

  @id stdout_output

</match>


# match tag=system.** and forward to another fluent server

<match system.**>

  @type forward

  @id forward_output


  <server>

    host 192.168.0.11

  </server>

  <secondary>

    <server>

      host 192.168.0.12

    </server>

  </secondary>

</match>


## match tag=myapp.** and forward and write to file

#<match myapp.**>

#  @type copy

#  <store>

#    @type forward

#    buffer_type file

#    buffer_path /var/log/fluent/myapp-forward

#    retry_limit 50

#    flush_interval 10s

#    <server>

#      host 192.168.0.13

#    </server>

#  </store>

#  <store>

#    @type file

#    path /var/log/fluent/myapp

#  </store>

#</match>


## match fluent's internal events

#<match fluent.**>

#  @type null

#</match>


## match not matched logs and write to file

#<match **>

#  @type file

#  path /var/log/fluent/else

#  compress gz

#</match>




fluent-cat를 이용해 동작 여부를 확인한다.



$ echo '{"json":"message"}' | fluent-cat debug.test



$ fluentd -c ./fluent/fluent.conf -vv

...

2017-08-16 19:52:03.309664000 +0900 debug.test: {"json":"message"}





fluent/fluent.conf 파일을 참조해서 실제로 동작하는지 테스트해본다.


 debug와 system 태그로 시작될 때에만 콘솔에 출력된다.


# HTTP input

# http://localhost:8888/<tag>?json=<json>

<source>

  @type http

  @id http_input


  port 8888

</source>
..

## match tag=debug.** and dump to console

<match debug.**>

  @type stdout

  @id stdout_output

</match>


# match tag=system.** and forward to another fluent server

<match system.**>

  @type forward

  @id forward_output


  <server>

    host 192.168.0.11

  </server>

  <secondary>

    <server>

      host 192.168.0.12

    </server>

  </secondary>

</match>




http로 사용한다.



$ curl -v http://localhost:8888/debug.test -F 'json={"hello":"world"}'

*   Trying 127.0.0.1...

* Connected to localhost (127.0.0.1) port 8888 (#0)

> POST /debug.http HTTP/1.1

> Host: localhost:8888

> User-Agent: curl/7.43.0

> Accept: */*

> Content-Length: 156

> Expect: 100-continue

> Content-Type: multipart/form-data; boundary=------------------------5bc2e845e167b296

>

< HTTP/1.1 100 Continue

< HTTP/1.1 200 OK

< Content-Type: text/plain

< Connection: Keep-Alive

< Content-Length: 0

<

* Connection #0 to host localhost left intact





fluent 로그에 전달한 json이 출력된다.


2017-08-16 19:55:47.099363000 +0900 debug.test: {"hello":"world"}




그러나 매개 변수가 json 규격에 잘 맞지 않으면 로그가 발생하지 않는다. 내부적으로 파싱하고 있는 듯 하다. 쌍따옴표를 없애면 파싱 구문만 제외하고 나온다




curl  -d 'json=afdafd'  http://localhost:8888/debug.test

(결과 안나옴)


curl  -d 'json={"hello":"world}'  http://localhost:8888/debug.test

(결과 : 2017-08-16 19:59:21.074761000 +0900 debug.test: "hello")

...





curl  -d 'json={"hello":"world}'  http://localhost:8888/debug1.test

(결과 : 

2017-08-16 20:00:39 +0900 [warn]: #0 fluent/log.rb:336:call: no patterns matched tag="debug1.test" )




fluent-logger를 설치하면 pry를 통해 fluentd에 전달할 수 있다. 


$ gem i fluent-logger --no-ri --no-rdoc

Fetching: fluent-logger-0.7.1.gem (100%)

Successfully installed fluent-logger-0.7.1

1 gem installed

$ pry

[1] pry(main)> require 'fluent-logger'

=> true

[2] pry(main)> Fluent::Logger::FluentLogger.open(nil, :host => 'localhost', :port => 24224)

=> #<Fluent::Logger::FluentLogger:0x007fc0892dbad0

 @buffer_overflow_handler=nil,

 @con=#<TCPSocket:fd 10>,

 @connect_error_history=[],

 @factory=#<MessagePack::Factory:0x007fc0892db918>,

 @host="localhost",

 @last_error={},

 @limit=8388608,

 @log_reconnect_error_threshold=13,

 @logged_reconnect_error=false,

 @logger=

  #<Logger:0x007fc0892db670

   @default_formatter=#<Logger::Formatter:0x007fc0892db648 @datetime_format=nil>,

   @formatter=nil,

   @level=1,

   @logdev=

    #<Logger::LogDevice:0x007fc0892db5a8

     @dev=#<IO:<STDERR>>,

     @filename=nil,

     @mutex=#<Logger::LogDevice::LogDeviceMutex:0x007fc0892db580 @mon_count=0, @mon_mutex=#<Mutex:0x007fc0892db530>, @mon_owner=nil>,

     @shift_age=nil,

     @shift_size=nil>,

   @progname=nil>,

 @mon=#<Monitor:0x007fc0892db760 @mon_count=0, @mon_mutex=#<Mutex:0x007fc0892db710>, @mon_owner=nil>,

 @nanosecond_precision=nil,

 @packer=#<MessagePack::Packer:0x007fc0892db8f0>,

 @pending=nil,

 @port=24224,

 @socket_path=nil,

 @tag_prefix=nil>

[3] pry(main)> Fluent::Logger.post("debug.test", { "id" => "1", "name" => "samuel" })

=> true



잘 나온다.


$ fluentd -c ./fluent/fluent.conf -vv

...


2017-08-16 20:03:59.000000000 +0900 debug.test: {"id":"1","name":"samuel"}




설정 파일 문법

https://docs.fluentd.org/articles/config-file#v1-format



tail log 문법

https://docs.fluentd.org/articles/in_tail



한글 착한 문서


http://blog.seulgi.kim/2014/04/fluentd-pluggable-log-collector.html

https://docs.google.com/presentation/d/1e6PXtPS_eQn7vY5hDhHlDVpCk1U6eKARoRqInoDiUkw/edit#slide=id.g271a4ef8f_018




과거에는 fluentd가 nanosecond 이슈가 있었다고 하나, 0.14부터는 nanosecond를 잘 보여주고 있다. 




https://www.fluentd.org/blog/fluentd-v0.14.9-has-been-released



time_as_integer true


out_forward

Since this version, time_as_integer parameter is now false. It means v0.14.9's out_forward can't forward data to v0.12's in_forward by default. You need to set time_as_integer true explicitly. We have already mentioned this point in v0.14.0 release, so we hope this change doesn't break your v0.14 to v0.12 forwarding.



'Cloud' 카테고리의 다른 글

[펌] fluentd 성능  (0) 2017.08.21
[td-agent] td-agent 설치 및 테스트  (0) 2017.08.18
[펌] 한국 오픈 스택 2017 자료 올라옴  (0) 2017.08.16
[펌] fluentd 사용 사례  (0) 2017.08.15
처음 본 오픈스택 Neutron  (0) 2017.07.24
Posted by '김용환'
,


한국 오픈 스택 2017 자료 올라옴


http://event.openstack.or.kr/2017/program.html




'Cloud' 카테고리의 다른 글

[td-agent] td-agent 설치 및 테스트  (0) 2017.08.18
fluentd 공부  (0) 2017.08.16
[펌] fluentd 사용 사례  (0) 2017.08.15
처음 본 오픈스택 Neutron  (0) 2017.07.24
처음 본 오픈스택 Swift  (0) 2017.07.24
Posted by '김용환'
,