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 '김용환'
,

* iterm2에서 소리 안나게 하는 방법


Preferences -> Profiles -> Terminal tab -> Check "Silence bell"



Posted by '김용환'
,


etcd 실행(2.2.5 기준)




$ curl -L  https://github.com/coreos/etcd/releases/download/v2.2.5/etcd-v2.2.5-darwin-amd64.zip -o etcd-v2.2.5-darwin-amd64.zip


$ unzip etcd-v2.2.5-darwin-amd64.zip



$ cd etcd-v2.2.5-darwin-amd64

$ ./etcd




커맨드 사용 방법


$ ./etcdctl ls -h

NAME:

   ./etcdctl ls - retrieve a directory


USAGE:

   ./etcdctl ls [command options] [arguments...]


OPTIONS:

   --sort returns result in sorted order

   --recursive returns all key names recursively for the given path

   -p append slash (/) to directories





간단한 dml 작업들 예제이다.

(ls, mkdir, set, get)



$ ./etcdctl ls


$ ./etcdctl mkdir /a/b

$ ./etcdctl ls /a

/a/b


$ ./etcdctl set /a/b/os ubuntu-16.04

ubuntu-16.04



$ ./etcdctl mkdir /a/b

$ ./etcdctl ls /a

/a/b

$ ./etcdctl set /a/b/os ubuntu-16.04

ubuntu-16.04

$ ./etcdctl get /a/b/os

ubuntu-16.04


$ ./etcdctl set /a/b/test samuel


$ ./etcdctl ls /a --recursive

/a/b

/a/b/os

/a/b/test




변경 방법이다. 


$ ./etcdctl update /a/b/os centos7


$ ./etcdctl get /a/b/os

centos6



간단한 노드 삭제 방법이다.


$ ./etcdtl rm /a/b/test


$ ./etcdctl rm /a/b/test

PrevNode.Value: samuel

$ ./etcdctl ls /a --recursive

/a/b

/a/b/os



구 zk(3.2.x 이전 버전)처럼 디렉토리를 지우기 전에 먼저 노드를 삭제해야 한다. 



$ ./etcdctl rmdir /a

Error:  108: Directory not empty (/a) [16540]

$ ./etcdctl rmdir /a/b

Error:  108: Directory not empty (/a/b) [16540]

$ ./etcdctl rm /a/b/os

PrevNode.Value: centos7

$ ./etcdctl rmdir /a/b/

$ ./etcdctl rmdir /a





모든 노드를 모두 보기


$ ./etcdctl ls --recursive



ttl 를 줄 수 있다.


$ ./etcdctl mkdir /a --ttl 3


3초 뒤에는 a가 사라져 있다.



http 관련 메소드는 따로 둔다. 


$ curl http://localhost:2379/xxx -XGET

404 page not found




백업하기


$ ps -ef | grep etcd

/opt/etcd/current/etcd --name master --data-dir /opt/etcd/data ...


$ ./etcdctl backup --data-dir /opt/etcd/data --backup-dir=/tmp/backup


$ ls -R /tmp/backup/

/tmp/backup/:

member


/tmp/backup/member:

snap  wal


/tmp/backup/member/snap:

000000000000022b-00000000062b232c.snap


/tmp/backup/member/wal:

0000000000000000-0000000000000000.wal





Posted by '김용환'
,





옵테인(optane)기술 


http://www.itworld.co.kr/news/104121


http://www.bodnara.co.kr/bbs/article.html?num=138616




클리앙 얘기


https://www.clien.net/service/board/park/10513177?po=0&od=T31&sk=title&sv=optane&category=&groupCd=&articlePeriod=2017


https://www.clien.net/service/board/park/10661561?po=0&od=T31&sk=title&sv=optane&category=&groupCd=&articlePeriod=2017


Posted by '김용환'
,

[openstack] nova cli 공부

Cloud 2017. 10. 13. 15:57

현재 테넌트의 목록을 본다.


$ nova list


테넌트에서 사용할 수 있는 flavor를 선택한다. 


$ nova flavor-list

+--------------------------------------+--------------------------------+-----------+------+-----------+------+-------+-------------+-----------+

| ID                                   | Name                           | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |

+--------------------------------------+--------------------------------+-----------+------+-----------+------+-------+-------------+-----------+

| 0f485230-0e9e-47ec-8291-cdd68fb7d3a9 | m1.small                       | 1024      | 50   | 0         |      | 1     | 1.0         | True      |

| 0fdf9fff-fdba-4176-9855-b819211fdd80 | m1.medium                      | 4096      | 50   | 0         |      | 4     | 1.0         | True      |

..

+--------------------------------------+--------------------------------+-----------+------+-----------+------+-------+-------------+-----------+



새로운 가상 장비를 생성한다.


$ nova boot myserver --image ubuntu-16.04 --flavor m1.medium




새로 생성한 서버를 본다. 


 $ nova show myserver

+--------------------------------------+----------------------------------------------------------+

| Property                             | Value                                                    |

+--------------------------------------+----------------------------------------------------------+

| OS-DCF:diskConfig                    | MANUAL                                                   |

| OS-EXT-AZ:availability_zone          |                                                          |

| OS-EXT-SRV-ATTR:host                 |                                                          |

| OS-EXT-SRV-ATTR:hypervisor_hostname  |                                                          |

| OS-EXT-SRV-ATTR:instance_name        |                                                          |

| OS-EXT-STS:power_state               | 1                                                        |

| OS-EXT-STS:task_state                | -                                                        |

| OS-EXT-STS:vm_state                  | active                                                   |

| OS-SRV-USG:launched_at               | 2017-10-13T16:37:01.000000                               |

| OS-SRV-USG:terminated_at             | -   

| id                                   | 8c09a701-e2ed-4882-a4dd-4c6ac3fd5587                    |

...                                              |

+--------------------------------------+----------------------------------------------------------+


현재 테넌트의 인스턴스 목록 중 새로 만든 vm 장비를 확인한다.


$ nova list | grep myserver

| 667ad7ab-c488-4d93-9c49-12cbc5678ace | myserver             | ACTIVE | -          | Running     | .. |



myserver vm 장비를 삭제한다.


$ nova delete myserver

Request to delete server myserver has been accepted.



전체 테먼트를 본다.



$ nova list --all-tenants 

+----+------+-----------+--------+------------+-------------+----------+

| ID | Name | Tenant ID | Status | Task State | Power State | Networks |

+----+------+-----------+--------+------------+-------------+----------+

...

+----+------+-----------+--------+------------+-------------+----------+


전체 테넌트 중 특정 테넌트를 살펴본다. 알아서 패턴매칭한다.




$ nova list --all-tenants --name samuel.kim

+----+------+-----------+--------+------------+-------------+----------+

| ID | Name | Tenant ID | Status | Task State | Power State | Networks |

+----+------+-----------+--------+------------+-------------+----------+

...

+----+------+-----------+--------+------------+-------------+----------+



 

 전체 테넌트 목록 보기.

$ keystone tenant-list

+----------------------------------+-------------------------------------------------+---------+

|                id                |                       name                      | enabled |

+----------------------------------+-------------------------------------------------+---------+

| 5bb41814075847989d9d1d0988290091 |                   test_test_t                   |   True  |

....




테넌트 목록에서 인스턴스가 속한 테넌트를 본다.


$ keystone tenant-list | grep 9949006f512f49c8baed5b89aa902924

| 9949006f512f49c8baed5b89aa902924 |                    samuel.kim                   |   True  |




콘솔 로그를 본다.

 

$ nova console-log 8c09a701-e2ed-4882-a4dd-4c6ac3fd5587  | tail

[   91.616224] rc.local[2369]: Selecting previously unselected package python-six.

[   91.624910] rc.local[2369]: Preparing to unpack .../python-six_1.10.0-3_all.deb ...

 ..



재시작한다. 


$ nova reboot 8c09a701-e2ed-4882-a4dd-4c6ac3fd5587

Request to reboot server <Server: myserver> has been accepted.



모르면 nova help 실행하기.



참조

https://docs.openstack.org/python-openstackclient/latest/

https://docs.openstack.org/python-novaclient/pike/cli/nova.html



예를 들어 available zone을 보려면 다음을 참고해서 실행한다. 

https://docs.openstack.org/python-openstackclient/latest/cli/command-objects/availability-zone.html#availability-zone-list




$ openstack availability zone list




커맨드 실패시 다음과 같은 디버그 옵션을 줄 수 있다. 


nova --debug xxxx


Posted by '김용환'
,


ceph에는 장애 복구 툴이 존재한다.


http://docs.ceph.com/docs/jewel/cephfs/disaster-recovery/



Posted by '김용환'
,


Intel VT-X option이 BIOS에서 활성화되는지 리눅스에서 확인하는 방법이다. 



$ sudo apt-get install -y cpu-checker



$ kvm-ok

INFO: /dev/kvm exists

KVM acceleration can be used


사용할 수 있다!!




해당 패키지로 bios에서 NX 비트를 지원하는지 확인할 수 있다. (https://ko.wikipedia.org/wiki/NX_%EB%B9%84%ED%8A%B8)


$ check-bios-nx

modprobe: ERROR: could not insert 'msr': Operation not permitted



'unix and linux' 카테고리의 다른 글

Argument list too long 해결하기  (0) 2017.10.20
numactl 커맨드  (0) 2017.10.19
tcpCurrEstab  (0) 2017.09.19
유닉스/리눅스에서 위험한 명령어 : rm, crontab  (0) 2017.09.15
[ssh] tunneling 예제  (0) 2017.09.08
Posted by '김용환'
,