ansible-galaxy

Ansible-Puppet-Chef 2019. 1. 14. 14:12



깃허브 사용자인 bennojoy가 작성한 ntp 롤을 설치하고 싶다고 가정하자. 이는 시간을  NTP 서버와 동기화하도록 호스트를 설정하는 롤이다.


다음 설치 커맨드로 롤을 설치할 수 있다.



$ ansible-galaxy install --roles-path ./roles bennojoy.ntp


결과는 다음과 같다.


- downloading role 'ntp', owned by bennojoy

- downloading role from https://github.com/bennojoy/ntp/archive/master.tar.gz

- extracting bennojoy.ntp to /Users/samuel.kim/dev/commerce/111/roles/bennojoy.ntp

- bennojoy.ntp (master) was installed successfully

'Ansible-Puppet-Chef' 카테고리의 다른 글

ansible-vault 간단 커맨드  (0) 2019.01.19
[ansible] copy mode 주의사항  (0) 2019.01.14
[ansible] ubuntu 16에 no_proxy가 안먹는 이슈가  (0) 2019.01.09
ansible 설치 (virtualenv)  (0) 2018.12.18
[ansible] lineinfile  (0) 2018.07.05
Posted by '김용환'
,

sqoop 성능 튜닝

hadoop 2019. 1. 11. 18:33



sqoop에서 무거운 DB덤프 잡을 빨리 하려면 다음 옵션을  고려하길 바란다. 확실히 빨라진다. 10분 배치를 1분대로..



1)  mapper 메모리는 크게


           -Dmapreduce.map.memory.mb=(크게, 그러나 적절하게) -Dmapreduce.map.java.opts=-Xmx(크게, 그러나 적절하게)



2) mapper 개수는 많이 


        --num-mappers (크게, 그러나 적절하게)                                                




3) split-by와 $CONDITIONS



--split-by id : 쪼개는 컬럼 이름

$CONDITIONS : 내부 튜닝 값




https://sqoop.apache.org/docs/1.4.2/SqoopUserGuide.html


If you want to import the results of a query in parallel, then each map task will need to execute a copy of the query, with results partitioned by bounding conditions inferred by Sqoop. Your query must include the token $CONDITIONS which each Sqoop process will replace with a unique condition expression. You must also select a splitting column with --split-by.

For example:

$ sqoop import \
  --query 'SELECT a.*, b.* FROM a JOIN b on (a.id == b.id) WHERE $CONDITIONS' \
  --split-by a.id --target-dir /user/foo/joinresults

Alternately, the query can be executed once and imported serially, by specifying a single map task with -m 1:

$ sqoop import \
  --query 'SELECT a.*, b.* FROM a JOIN b on (a.id == b.id) WHERE $CONDITIONS' \
  -m 1 --target-dir /user/foo/joinresults





4) --boundary-query <sql 문>


전체를 덤프를 뜨려고 하면 속도가 통 나지 않는다. split-by id를 사용할 때 index가 있는 id를 기반으로 경계문을 전송하면 빠르게 쿼리 결과를 받을 수 있다.


Posted by '김용환'
,



spark 애플리케이션-haoop(yarn)  연동 잡을 실행하던 중에 


애플리케이션을 종료하려면.. 스파크 스케줄러(또는 hadoop 스케줄러)에서 


인스턴스 id인 application_11123123131321을 얻은 후,


yarn 커맨드의 kill 커맨드에 인스턴스 id를 추가한다.  



yarn application -kill application_11123123131321 





Posted by '김용환'
,



특정 장비에서 mysql DB로 


telnet은 접속이 안되었지만, 아래와 같은 mysql client 에러가 발생해 mysql에서 따로 deny하고 있는 줄 알았는데..



ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 104



알고보니 방화벽 ACL이었다..


Posted by '김용환'
,

yarn-spark 구조를 설명하려 할 때 도움되는 ㄷ그림.



출처 : https://hywelzhang.github.io/2018/12/06/Spark-Spark-Running-Architecture.html




Posted by '김용환'
,



맥 OS 탐색기에서 숨은 파일을 찾으려면 

shift + command + 점(마침표)를 선택하면 숨은 파일이 나타난다.

'Tool' 카테고리의 다른 글

td-agent 모니터링  (0) 2019.10.28
java.lang.NoSuchMethodError: No such DSL method 'withMaven' found among steps 에러  (0) 2019.03.11
tmux 사용 방법  (0) 2018.12.19
[git] no kex alg 이슈  (0) 2018.06.20
[intellij] 2018.1 lombok 설정  (0) 2018.06.19
Posted by '김용환'
,



ubuntu 16 에서 apt-get install을 이용해 설치하다가 다음과 같은 에러가 발생하면 ..



E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)

E: Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?  




다음과 같이 설치한다.



sudo rm /var/lib/apt/lists/lock

sudo rm /var/cache/apt/archives/lock

sudo rm /var/lib/dpkg/lock



 sudo dpkg --configure -a




Posted by '김용환'
,



ubuntu 16에 no_proxy가 안먹는 이슈가 있을 수 있다. 


https://bugs.launchpad.net/ubuntu/+source/apt/+bug/1575877



$ vi /etc/profile


setproxy() {

...

}





따라서 필요하다면 apt-get update와 install을 아래와 같이 설치해야 할 수도 있다.



- name: Update cache

  shell: "source /etc/profile && setproxy sudo -E apt-get update"

  args:

    chdir: /kakao/source

    executable: /bin/bash


- name: Install Nginx

  shell: "source /etc/profile && setproxy sudo -E apt-get install nginx"

  args:

    chdir: /kakao/source

    executable: /bin/bash






'Ansible-Puppet-Chef' 카테고리의 다른 글

[ansible] copy mode 주의사항  (0) 2019.01.14
ansible-galaxy  (0) 2019.01.14
ansible 설치 (virtualenv)  (0) 2018.12.18
[ansible] lineinfile  (0) 2018.07.05
[ansible] 배포될 서버의 호스트명 얻는 방법  (0) 2018.04.02
Posted by '김용환'
,



git 저장소의 도메인이 다른 경우 이사하고 싶은 경우가 있다.


기존에 사용하던 기존 환경(브랜치, pull, refs)과 동일하게 하고 싶다면, 


기존 저장소의 url을 사용해 git clone --mirror url 로 로컬로 다운받은 후, 


새로운 저장소에 push하면 된다.





git clone 방식은 3방식으로 우선 확인하면 명확하게 이해를 얻을 수 있다.


git clone url git_general


git clone --bare url git_bare


git clone --mirror url git_mirror






diff를 통해서 확인해보면 명확하게 이해할 수 있다. deep하게 모든 내용을 다운받는 것은 mirror 밖에 없다.



나머지에 대한 자세한 내용은 아래 링크를 참조한다.


http://pinocc.tistory.com/138

Posted by '김용환'
,



파이썬 3 예제이다.


파이썬 2의 subprocess의 결과는 이전에는 string이었지만 python2.6? 또는 python 3부터는 bytes로 리턴한다.

TypeError: startswith first arg must be bytes or a tuple of bytes, not str 이런 에러가 난다면 이슈이다.



이해가 되는 예시이다. 



>>> print(subprocess.Popen("echo hellow", shell=True, stdout=subprocess.PIPE))

b'hellow\n'


>>> print(subprocess.Popen("echo hellow", shell=True, stdout=subprocess.PIPE))

<subprocess.Popen object at 0x10cfb2908>


>>> print(subprocess.Popen("echo hellow", shell=True, stdout=subprocess.PIPE).communicate())

(b'hellow\n', None)


>>> print(subprocess.Popen("echo hellow", shell=True, stdout=subprocess.PIPE, universal_newlines=True).communicate()[0])

hellow



>>> print(subprocess.Popen("echo hellow", shell=True,stdout=subprocess.PIPE).communicate()[0].decode('utf-8').strip())

hellow





마찬가지로..subprocess 모듈의 check_out도 바이트이기에..


status = subprocess.check_output(cmd.split()).rstrip() 코드는




print(subprocess.check_output(cmd.split()).decode('utf-8').rstrip()) 로 변경하면 string으로 리턴한다.







<참고 예시>


import subprocess

import paramiko

cmd = "vagrant ssh-config vagrant2"

p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, universal_newlines=True)

config = paramiko.SSHConfig()

config.parse(p.stdout)

config.lookup("vagrant2")



Posted by '김용환'
,