https://github.com/coreos/etcd/releases/ 을 접근하니 3.2.6이 최신이다. 

os 버전별로 바이너리를 다운받고 압축을 푼 디렉토리 밑에 실행하면 된다.



ETCDCTL_API의 값이 설정되야 잘 돌아간다. 

$ ETCDCTL_API=3


또는 .bash_xx에 추가한다. 

EXPORT ETCDCTL_API=3 




version을 확인한다. 


$ ./etcdctl version

etcdctl version: 3.2.6

API version: 3.2




2.x에서 사용되던 ls는 안먹힌다.. 조금씩 바꾼 형태이다. 

$ ./etcdctl ls /

Error: unknown command "ls" for "etcdctl"

Run 'etcdctl --help' for usage.

Error:  unknown command "ls" for "etcdctl"



put, get 예제


$ /etcdctl put foo bar

OK


$ ./etcdctl get foo

foo

bar



from-key 예제



$ ./etcdctl put foo bar

OK


$ ./etcdctl put foo bar

OK


$ ./etcdctl put foo1 bar1

OK


$ ./etcdctl put foo2 bar2

OK


$ ./etcdctl put foo3 bar3

OK


$ ./etcdctl get foo

foo

bar

$ ./etcdctl get --from-key foo1

foo1

bar1

foo2

bar2

foo3

bar3

$ ./etcdctl get foo1 foo3

foo1

bar1

foo2

bar2







etcd 2.x의 ls 와 비슷한 커맨드 from-key


$ ./etcdctl put x y

OK

$ ./etcdctl put y 1

OK

$ ./etcdctl get --from-key ''

x

y

y

1






delete 예제



$ ./etcdctl del foo

1

$ ./etcdctl get foo




$ ./etcdctl put key val

OK

$ ./etcdctl del --prev-kv key

1

key

val

$ ./etcdctl get key




$ ./etcdctl put a 123

OK

$ ./etcdctl put b 456

OK

$ ./etcdctl put z 789

OK

$ ./etcdctl del --from-key a

6

$ ./etcdctl get --from-key a




 ./etcdctl put zoo val

OK

$ ./etcdctl put zoo1 val1

OK

$ ./etcdctl put zoo2 val2

OK

$ ./etcdctl del --prefix zoo

3

$ ./etcdctl get zoo2





원자잭 트랙잭션 txn 예제



$ ./etcdctl txn -i

compares:

mod("key1") > "0"


success requests (get, put, delete):

put key1 "111"

put key2 "222"


failure requests (get, put, delete):


SUCCESS


OK


OK

$ ./etcdctl get key1

key1

111

$ ./etcdctl get key2

key2

222




클러스터 모드롤 실행할 때는 로컬이 아닌 3대의 장비에서 실행시키는 것이 좋다..




Posted by '김용환'
,


fluentd에서 http query의 모든 매개변수 값을 key,value로 포함시키려면 


fluent-plugin-extract_query_params를 설치하고 @type extract_query_params를 활용한다. 




참고 

https://github.com/kentaro/fluent-plugin-extract_query_params


Imagin you have a config as below:

<filter test.**>
  @type extract_query_params

  key            url
  only           foo, baz
</match>

And you feed such a value into fluentd:

"test" => {
  "url" => "http://example.com/?foo=bar&baz=qux&hoge=fuga"
}

Then you'll get re-emmited tag/record-s below:

"extracted.test" => {
  "url" => "http://example.com/?foo=bar&baz=qux&hoge=fuga"
  "foo" => "bar",
  "baz" => "qux"
}


'Cloud' 카테고리의 다른 글

[openstack] Rally + Tempest  (0) 2017.09.02
[etcd] etcd 설치와 간단 예제  (0) 2017.08.23
[펌] fluentd 성능  (0) 2017.08.21
[td-agent] td-agent 설치 및 테스트  (0) 2017.08.18
fluentd 공부  (0) 2017.08.16
Posted by '김용환'
,




일래스틱서치는 인덱스의 필드 데이터의 데이터 타입을 지정하지 않으면 자동으로 데이터 타입 매핑을 한다. 그러나 데이터 오류 또는 일래스틱서치 내부 동작에 의해 좀더 큰(broader) 타입으로 자동 매핑을 하지 않도록 동적으로 일래스틱서치의 필드에 타입을 지정하는 기능이다. 



예를 들어, integer 값 필드를 일래스틱서치 내부적으로 integer 타입로 받아들이다가 데이터 일부가 오류가 생겨서 1.1이 오면 모두 double로 변경될 수 있다. 자동 타입 변경이 되지 않도록 설정할 수 있는 기능이라 할 수 있다. 



https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-templates.html#dynamic-templates


 "dynamic_templates": [
    {
      "my_template_name": { 
        ...  match conditions ... 
        "mapping": { ... } 


Posted by '김용환'
,


elasticsearch과 hadoop을 바인딩해서 사용할 수 있다.


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



요구사항은 다음과 같다. 특이점음 1.x부터 5.5까지 하위 호환성은 유지시켜 준닥.


https://www.elastic.co/guide/en/elasticsearch/hadoop/5.5/requirements.html





하이브 주요 내용은 다음과 같다.

https://www.elastic.co/guide/en/elasticsearch/hadoop/current/hive.html



다음과 비슷하게 hive 테이블을 생성할 수 있다.


CREATE EXTERNAL TABLE IF NOT EXISTS artists (...)

STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'

TBLPROPERTIES('es.resource' = 'radio/artists',

              'es.index.auto.create' = 'false') ;




주요 하이브 테이블 설정은 다음과 같다. 


https://www.elastic.co/guide/en/elasticsearch/hadoop/current/configuration.html




1. 'es.resource'=하둡 디렉토리


2. 'es.input.json` = 'yes'

json 입력을 가능케 해준다. 기본값은 false이다. 문서에는 true가 아니라 'yes'라고 입력되어 있다.


es.input.json (default false)
Whether the input is already in JSON format or not (the default). Please see the appropriate section of each integration for more details about using JSON directly.



3. 'es.nodes'='${target_es_dns}'

elasticsearch node는 대부분 클러스터이기 때문에. es.node를 사용할 때는 해당 노드로 저장케 한다.



es.nodes (default localhost)
List of Elasticsearch nodes to connect to. When using Elasticsearch remotely, do set this option. Note that the list does not have to contain every node inside the Elasticsearch cluster; these are discovered automatically by elasticsearch-hadoop by default (see below). Each node can also have its HTTP/REST port specified individually (e.g. mynode:9600).


4. 'es.mapping.id' = did


document ID 로 사용한 다큐먼트 필드/프로퍼티

es.mapping.id (default none)
The document field/property name containing the document id.


5. 'es.query' = '?q=me*'

쿼리 결과도 저장할 수 있다. 



6. batch 관련 설정

'es.batch.write.refresh'='false'

'es.batch.size.bytes'='10mb'

'es.batch.size.entries'='0'




es.batch.size.bytes (default 1mb)
Size (in bytes) for batch writes using Elasticsearch bulk API. Note the bulk size is allocated per taskinstance. Always multiply by the number of tasks within a Hadoop job to get the total bulk size at runtime hitting Elasticsearch.
es.batch.size.entries (default 1000)
Size (in entries) for batch writes using Elasticsearch bulk API - (0 disables it). Companion to es.batch.size.bytes, once one matches, the batch update is executed. Similar to the size, this setting is per task instance; it gets multiplied at runtime by the total number of Hadoop tasks running.
es.batch.write.refresh (default true)
Whether to invoke an index refresh or not after a bulk update has been completed. Note this is called only after the entire write (meaning multiple bulk updates) have been executed.
es.batch.write.retry.count (default 3)
Number of retries for a given batch in case Elasticsearch is overloaded and data is rejected. Note that only the rejected data is retried. If there is still data rejected after the retries have been performed, the Hadoop job is cancelled (and fails). A negative value indicates infinite retries; be careful in setting this value as it can have unwanted side effects.





Posted by '김용환'
,