fluentd에서 [error]: exec failed to emit error="queue size exceeds limit" error_class="Fluent::BufferQueueLimitError" tag="google.plus" 이라는 에러가 발생한다면,

버퍼 설정이 어떻게 되어 있는지 확인한다. 



type설정만 forward로 되어 있다.



type forward 

flush_interval 10s



forward 설정이 기본 memory기반이고 기본적으로 큐 크기가 64, 청크 크기는 8mb(큐에 데이터 쌓는 사이즈)인데,

flush 간격 10초 동안 생성된 로그가 큐 크기를 넘어섰다. 



https://docs.fluentd.org/v0.12/articles/out_forward#buffer_queue_limit,-buffer_chunk_limit


buffer_queue_limit, buffer_chunk_limit

The length of the chunk queue and the size of each chunk, respectively. Please see the Buffer Plugin Overview article for the basic buffer structure. The default values are 64 and 8m, respectively. The suffixes “k” (KB), “m” (MB), and “g” (GB) can be used for buffer_chunk_limit.



memory의 제약 사항이 있기 때문에 임시파일을 생성해서 bulk로 flush하는 형태를 사용하면 된다. 



  buffer_type file

  buffer_path /var/log/td-agent/buffer/fluentd.buffer

  buffer_chunk_limit 16m

  buffer_queue_limit 128

  

  

*** 

buffer_type을 주지 않으면 메모리 기반이고, 저장 용량이 작기 때문에 로그 내용이 drop 될 수 있다. 


Posted by '김용환'
,


3개의 커밋을 하나로 합쳐본다.



$ git log --pretty=oneline

aae3f8afa5c7e97d8974525994f100b93258baf3 commit 3

2c24df186d7b779a87882e0968503fb019866d62 commit 2

ae08eead7cf187b85fd73d5a2ceb3f0a256c99b1 commit 1


3번 commit/push했고 이를 하나의 commit 메시지로 만들고 싶을 때 사용할 수 있는 git 커맨드를 소개한다. 



최신 3개의 commit을 rebase로 하나로 합쳐 본다. -i는 대화형 모드를 의미한다. 


$ git rebase -i HEAD~3

  

pick ae08eea commit 1

pick 2c24df1 commit 2

pick aae3f8a commit 3


# Rebase acf9816..aae3f8a onto acf9816 (3 command(s))

#

# Commands:

# p, pick = use commit

# r, reword = use commit, but edit the commit message

# e, edit = use commit, but stop for amending

# s, squash = use commit, but meld into previous commit

# f, fixup = like "squash", but discard this commit's log message

# x, exec = run command (the rest of the line) using shell

# d, drop = remove commit

#




아래와 같이 수정한다. 

commit 1은 그대로. commit 2와 commit 3의 pick을 squash또는 s로 변경한다. 


pick ae08eea commit 1

squash 2c24df1 commit 2

squash aae3f8a commit 3


# Rebase acf9816..aae3f8a onto acf9816 (3 command(s))

#

# Commands:

# p, pick = use commit

# r, reword = use commit, but edit the commit message

# e, edit = use commit, but stop for amending

# s, squash = use commit, but meld into previous commit

# f, fixup = like "squash", but discard this commit's log message

# x, exec = run command (the rest of the line) using shell

# d, drop = remove commit

#


저장하고 종료하면 squash 화면이 나타난다. 

여기에서 commit1 앞에 REDIS-1을 추가해본다. 


다음 화면이 나타나고 쉘로 나온다. 



 3 files changed, 0 insertions(+), 0 deletions(-)

 create mode 100644 1

 create mode 100644 2

 create mode 100644 3

Successfully rebased and updated refs/heads/master.



3개의 commit이 하나의 commit으로 나타난다. 


$ git log --pretty=oneline

7dca124e20dea4a4248be52eae50081580ac329d REDIS-1 commit 1

acf9816e316d960df3a99c6bb9c0ee40ac31dee0 Initial commit



해당 commit을 확인해보면 commit 1, commit 2, commit 3 모두 존재한다.


$ git log -p 1

commit 7dca124e20dea4a4248be52eae50081580ac329d

Author: knight76@gmail.com

Date:   Tue Oct 24 19:27:43 2017 +0900


    REDIS-1 commit 1


    commit 2


    commit 3


diff --git a/1 b/1

new file mode 100644

index 0000000..e69de29




이미 remote repository에 저장했기 때문에 git push --force를 실행해서 서버에도 반영한다.






만약, push를 하지 않은 상태라면 git reset --soft HEAD~3 커맨드를 사용하면 된다. 



$ git log --pretty=oneline

13a9d0da6ebf8f0ab2d78761cd26bad3136c5cec commit 3

628a2b89c35e134aeccd0e26dc90dc78575f2493 commit 2

e8630d725e97f8f11e8036d303abe4812f956dea commit 1

acf9816e316d960df3a99c6bb9c0ee40ac31dee0 Initial commit


$ git reset --soft HEAD~3


$ git status

On branch master

Your branch is up-to-date with 'origin/master'.

Changes to be committed:

  (use "git reset HEAD <file>..." to unstage)


new file:   1

new file:   2

new file:   3


$ git log --pretty=oneline

acf9816e316d960df3a99c6bb9c0ee40ac31dee0 Initial commit


$ git add .

$ git commit -m 'REDIS-1 commit 1'

[master a3eaa44] REDIS-1 commit 1

 3 files changed, 0 insertions(+), 0 deletions(-)

 create mode 100644 1

 create mode 100644 2

 create mode 100644 3

$ git push


Posted by '김용환'
,

geminabox 설치/실행

Ruby 2017. 10. 24. 09:56



https://github.com/geminabox/geminabox






geminabox는 사내(inhouse)에서 custom plugin을 설치하는데 도움을 준다.


설치(최신 geminabox는 루비 2.2.2가 필요하다)


$ sudo gem install geminabox




config.ru 파일을 생성한다. 데이터 저장위치도 잘 선택한다.


require "rubygems"

require "geminabox"

Geminabox.data = "/home/www/geminabox/gems"

run Geminabox::Server




geminabox 데몬을 시작하는 스크립트이다. rackup을 사용한다. -p는 포트이고, -E는 개발환경을 의미한다. -E production을 주지 않으면 로컬에서만 확인할 수 있다. -D는 데몬으로 동작하도록 알린다.


rackup -p 3000 -E production -D



데몬을 중지하려면 다음을 실행한다.



PID=`ps -ef | grep 'rackup' | grep -v grep | awk '{print $2}'`

if [ -z $PID ]; then

  echo "no process"

else 

  kill -9 $PID

  echo "killed .. done"

fi



'Ruby' 카테고리의 다른 글

gem 설치 디버깅하기  (0) 2017.10.20
ruby zookeeper  (0) 2017.02.07
[ruby] http call 예시  (0) 2017.01.06
[capistrano] 다른 task 호출하기  (0) 2016.12.07
ruby on rails 애플리케이션 실행하기  (0) 2016.10.12
Posted by '김용환'
,



네임스페이스를 줄 수 있다. 



$ ip netns add ns1



또 실행하면 실제 network namespace의 위치를 알려주는 에러(?!)가 발생한다.


$ ip netns add ns1

Cannot create namespace file "/var/run/netns/ns1": File exists



확인한다.


$ ip netns

ns1

$ ip netns list

ns1

$ ip netns list ns1

ns1



삭제하려면 다음 커맨드를 실행한다. 


$ ip netns delete ns1

$ ip netns list




하나의 가상 ethernet을 생성하고 peer로 하나 생성한다.


$ ip link add vireth0 type veth peer name virteth1

$ ip link list

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 50000

    link/ether fa:16:3e:77:ea:d4 brd ff:ff:ff:ff:ff:ff

3: virteth1@vireht0: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000

    link/ether c2:d7:7a:23:90:7b brd ff:ff:ff:ff:ff:ff

4: vireht0@virteth1: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000

    link/ether 56:48:fa:8d:53:58 brd ff:ff:ff:ff:ff:ff

    

    


만약 실수 했다면 ip link del로 삭제할 수 있다. 


$ ip link del vireth0


네트워크 namespace 에는 단지 virtual Ethernet(veth)만 할당할 수 있다.


이전에 추가한 네임스페이스에 vireth0을 연동한다. 


$ ip link set vireth0 netns ns1



ip link list를 실행하면 vireth0이 안보인다. 글로벌 공간에서 ns1로 이동했다. virteth1만 남아 있다. 


$ ip link list

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 50000

    link/ether fa:16:3e:77:ea:d4 brd ff:ff:ff:ff:ff:ff

3: virteth1@if12: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000

    link/ether aa:35:8b:aa:ae:62 brd ff:ff:ff:ff:ff:ff link-netnsid 0

    



ip netns list를 실행하면 먼가가 바뀌었다. id가 0이다. 


$ ip netns list

ns1 (id: 0)



ns1에서 ip link list를 실행한다. 여기에 vireth0이 있다. 


$ ip netns exec ns1 ip link list

1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

3: vireth0@if11: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000

    link/ether 52:eb:a4:5b:33:d3 brd ff:ff:ff:ff:ff:ff link-netnsid 0

    

    



새로운 ip를 부여한다. 


$ ip netns exec ns1 ifconfig vireth0 192.168.1.1/24 up



확인한다. DOWN 상태에서 LOWERLAYERDOWN 상태로 바뀌었다. 


$ ip netns exec ns1 ip link list

1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default qlen 1

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

12: vireth0@if11: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN mode DEFAULT group default qlen 1000

    link/ether 52:eb:a4:5b:33:d3 brd ff:ff:ff:ff:ff:ff link-netnsid 0

    


ip 주소를 확인하면 192.168.1.1로 되어 있음을 확인할 수 있다. 


$ ip netns exec ns1 ip addr list

1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

12: vireth0@if11: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000

    link/ether 52:eb:a4:5b:33:d3 brd ff:ff:ff:ff:ff:ff link-netnsid 0

    inet 192.168.1.1/24 brd 192.168.1.255 scope global vireth0

       valid_lft forever preferred_lft forever




ns1의 vireth0과 글로벌의 virteth1을 서로 짝이라서 virteth1의 네트워크를 설정한다. 


$ ifconfig virteth1 192.168.1.2/24 up


이제 글로벌영역에서 가상 네임 네트워크 ns1으로 ping을 실행할 수 있다. 


$ ping 192.168.1.1

PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.

64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.043 ms

64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.039 ms



Posted by '김용환'
,




java9을 설치하니 Spring Tool Suite가 동작이 되지 않는다. 


!ENTRY org.eclipse.e4.ui.workbench 4 0 2017-10-20 19:29:56.365

!MESSAGE FrameworkEvent ERROR

!STACK 0

java.lang.NoClassDefFoundError: javax/annotation/PreDestroy

        at org.eclipse.e4.core.internal.di.InjectorImpl.disposed(InjectorImpl.java:426)

        at org.eclipse.e4.core.internal.di.Requestor.disposed(Requestor.java:154)

        at org.eclipse.e4.core.internal.contexts.ContextObjectSupplier$ContextInjectionListener.update(ContextObjectSupplier.java:78)

        at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.update(TrackableComputationExt.java:111)

        at org.eclipse.e4.core.internal.contexts.TrackableComputationExt.handleInvalid(TrackableComputationExt.java:74)

        at org.eclipse.e4.core.internal.contexts.EclipseContext.dispose(EclipseContext.java:176)

        at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.dispose(EclipseContextOSGi.java:106)

        at org.eclipse.e4.core.internal.contexts.osgi.EclipseContextOSGi.bundleChanged(EclipseContextOSGi.java:139)

        at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903)

        at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)

        at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)

        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213)

        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120)

        at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112)

        at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156)

        at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)

        at org.eclipse.osgi.container.Module.doStop(Module.java:634)

        at org.eclipse.osgi.container.Module.stop(Module.java:498)

        at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:191)

        at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:165)

        at java.base/java.lang.Thread.run(Thread.java:844)

Caused by: java.lang.ClassNotFoundException: javax.annotation.PreDestroy cannot be found by org.eclipse.e4.core.di_1.6.0.v20160319-0612

        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:398)

        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:361)

        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:353)

        at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)

        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)

        ... 21 more





STS.ini에서 -vmargs 라인을 찾고 다음을 추가한다.


-vmargs

--add-modules=java.se.ee



참고로 STS.ini 파일은 STS.app/Contents/Eclipse에 위치한다. 



Posted by '김용환'
,

gem 설치 디버깅하기

Ruby 2017. 10. 20. 18:45



--debug --backtrace --verbose 옵션를 추가한다.



예)


gem install --debug --backtrace --verbose  fluent-plugin-force-encoding  -v 0.0.5

'Ruby' 카테고리의 다른 글

geminabox 설치/실행  (0) 2017.10.24
ruby zookeeper  (0) 2017.02.07
[ruby] http call 예시  (0) 2017.01.06
[capistrano] 다른 task 호출하기  (0) 2016.12.07
ruby on rails 애플리케이션 실행하기  (0) 2016.10.12
Posted by '김용환'
,

docker 내부에서 호스트 이름을 얻는 방법은 다음과 같다. 



# cat /etc/hostname

b84d97a03afc


# hostname

b84d97a03afc


# env  | grep HOSTNAME

HOSTNAME=b84d97a03afc




docker 내부에서 호스트 ip를 얻는 방법은 다음과 같다. 


$ ip addr

...

17: eth0@if18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default

    link/ether 02:42:c0:a8:05:02 brd ff:ff:ff:ff:ff:ff

    inet 192.168.5.2/24 scope global eth0

       valid_lft forever preferred_lft forever


# ip route  | grep src

192.168.5.0/24 dev eth0  proto kernel  scope link  src 192.168.5.2



Posted by '김용환'
,


cp (rm, mv 포함) 커맨드 실행시 파일 개수가 너무 많으면, 매개 변수 개수 제한 에러가 발생한다.


$ cp /src/dir/* /dst/dir/

-bash: /bin/cp: Argument list too long



해결 방법으로는 다음 방법이 있을 것 같다. 


1. rsync


2. find 


find /src/dir/ -type f -exec cp {} /dst/dir \;



3. ls | xargs


4. for ls..




Posted by '김용환'
,

numactl 커맨드

unix and linux 2017. 10. 19. 22:06


numa 아키텍처(Non-Uniform Memory Access, NUMA)는 멀티프로세서 시스템에서 사용되고 있는 컴퓨터 메모리 설계 방법중의 하나로, 메모리에 접근하는 시간이 메모리와 프로세서간의 상대적인 위치에 따라 달라진다. NUMA구조에서 프로세서는 자기의 로컬 메모리에 접근할 때가 원격 메모리에 접근할 때보다 더 빠르다. 원격 메모리는 다른 프로세서에 연결되어 있는 메모리를 말하고 로컬 메모리는 자기 프로세서에 연결되어 있는 메모리를 말한다.


https://ko.wikipedia.org/wiki/%EB%B6%88%EA%B7%A0%EC%9D%BC_%EA%B8%B0%EC%96%B5_%EC%9E%A5%EC%B9%98_%EC%A0%91%EA%B7%BC



numa를 잘 활용해야 훨씬 빠르게 메모리를 관리할 수 있다. 




https://github.com/numactl/numactl


numa 아키텍처에서 지원하는 간단한 AP로서 numa 아키텍처에서 동작하는 java daemon을 실행할 때 자주 사용될 수 있다. elasticsearch나 cassandra에 사용한다면 성능 효과를 얻을 수 있다. 




https://www.slideshare.net/slidunder/numa-and-java-databases





numactl은 공유 메모리 또는 파일에 대한 정책을 지정할 수 있다. 





예를 들어 간단한 numactl 커맨드가 있다.


$ numactl --interleave=all /home/www/elasticsearch-5.3/bin/elasticsearch -d


interleave 모드를 사용하면 라운드 로빈으로 메모리를 노드에 할당하게 한다. numa 아키텍처를 활용해 빠르게 접근하게 한다!





https://linux.die.net/man/8/numactl



--interleave=nodes, -i nodes
Set a memory interleave policy. Memory will be allocated using round robin on nodes. When memory cannot be allocated on the current interleave target fall back to other nodes. Multiple nodes may be specified on --interleave, --membind and --cpunodebind. You may specify "all", which means all nodes in the current cpuset. nodes may be specified as N,N,N or N-N or N,N-N or N-N,N-N and so forth. Relative nodes may be specifed as +N,N,N or +N-N or +N,N-N and so forth. The + indicates that the node numbers are relative to the process' set of allowed nodes in its current cpuset. A !N-N notation indicates the inverse of N-N, in other words all nodes except N-N. If used with + notation, specify !+N-N.



자바와 NUMA 아키텍처와 관련된 설명은 다음을 참조한다.

https://www.slideshare.net/slidunder/numa-and-java-databases


이 슬라이드는 numctl과 cassandra 간의 조심스러움을 표현하고 있다. 


NUMA and Java Databases from Raghavendra Prabhu






Posted by '김용환'
,

[docker] aufs

docker 2017. 10. 19. 21:46


docker info 커맨드를 실행하면 다음 스토리지 드라이버로 aufs가 나타난다.  


...

Storage Driver: aufs

 Root Dir: /var/lib/docker/aufs

 Backing Filesystem: extfs

 Dirs: 98

 Dirperm1 Supported: true




docker의 내부 스택이 바로 aufs로 되어 있다.

(출처 : https://docs.docker.com)






따라서 docker containerization을 지원하는 형태는 mesos는 지원하는 당연히 aufs 파일 시스템을 지원한다. 

ubuntu랑도 docker가 잘 궁합이 맞는 것도 그런 드 하다. 



http://mesos.apache.org/documentation/latest/container-image/


AUFS

The reason AUFS is introduced is because overlayfs support hasn’t been merged until kernel 3.18 and Docker’s default storage backend for ubuntu 14.04 is AUFS.

Like overlayfs, AUFS is also a unioned file system, which is very stable, has a lot of real-world deployments, and has strong community support.

Some Linux distributions do not support AUFS. This is usually because AUFS is not included in the mainline (upstream) Linux kernel.

For more information of AUFS, please refer to here.


Posted by '김용환'
,